diff options
| author | 1029chris <1029chris@gmail.com> | 2016-04-19 10:41:58 -0700 |
|---|---|---|
| committer | 1029chris <1029chris@gmail.com> | 2016-04-19 10:41:58 -0700 |
| commit | 37f3f6f4a8fb8f84f46d8f31f469721604a5cc08 (patch) | |
| tree | 1376f152c403b5b5504a0475c2ae2cd7e2ee06f8 /virus1.lua | |
| parent | 6d54f2c8edbef92f04c55a7a281eb4f2713098c6 (diff) | |
Virus moves to center of the screen after first message
Diffstat (limited to 'virus1.lua')
| -rw-r--r-- | virus1.lua | 35 |
1 files changed, 35 insertions, 0 deletions
@@ -29,6 +29,8 @@ function drawVirusFight1() if v1.c.load == false then v1.c.x = win[2].x+v1.c.monitorspin.x v1.c.y = v1.c.monitorspin.y + v1.c.xd = v1.c.x + v1.c.yd = v1.c.y v1.c.load = true end love.graphics.setColor(0,0,0,100) @@ -44,6 +46,39 @@ function drawVirusFight1() v1.c.chat.msgs = v1.c.chat.msgs + 1 v1.c.chat.char = 0 end + if v1.c.chat.msgs == 2 then + v1.c.xd = sys.w/2 + v1.c.yd = sys.h/2 + end + v1.c.angle = math.atan2((v1.c.yd - v1.c.y), (v1.c.xd - v1.c.x)) + v1.c.spx = v1.c.sp * math.cos(v1.c.angle) + v1.c.spy = v1.c.sp * math.sin(v1.c.angle) + if v1.c.x > v1.c.xd then + if v1.c.x + v1.c.spx <= v1.c.xd then + v1.c.x = v1.c.xd + else + v1.c.x = v1.c.x + v1.c.spx + end + elseif v1.c.x < v1.c.xd then + if v1.c.x + v1.c.spx >= v1.c.xd then + v1.c.x = v1.c.xd + else + v1.c.x = v1.c.x + v1.c.spx + end + end + if v1.c.y > v1.c.yd then + if v1.c.y + v1.c.spy <= v1.c.yd then + v1.c.y = v1.c.yd + else + v1.c.y = v1.c.y + v1.c.spy + end + elseif v1.c.y < v1.c.yd then + if v1.c.y + v1.c.spy >= v1.c.yd then + v1.c.y = v1.c.yd + else + v1.c.y = v1.c.y + v1.c.spy + end + end if v1.msgs[v1.c.chat.msgs] ~= nil then if string.len(v1.msgs[v1.c.chat.msgs]) ~= string.len(v1.c.chat.msg) then v1.c.chat.char = v1.c.chat.char + v1.c.chat.sp*(60/love.timer.getFPS()) |
