aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author1029chris <1029chris@gmail.com>2016-04-28 21:24:07 -0700
committer1029chris <1029chris@gmail.com>2016-04-28 21:24:07 -0700
commit82182f3118df586721f71d1a31f371f5e43aefea (patch)
tree8620bed07b56ed93866759e8be97f24e680a581f
parent83547c6ef44dd1588b8a2ace29b451ed7ad50b6f (diff)
Virus ship can shoot
-rw-r--r--assets.lua8
-rw-r--r--assets/bullet_green.pngbin0 -> 246 bytes
-rw-r--r--virus1.lua70
3 files changed, 73 insertions, 5 deletions
diff --git a/assets.lua b/assets.lua
index fbb4076..5aa78f0 100644
--- a/assets.lua
+++ b/assets.lua
@@ -119,6 +119,14 @@ function loadAssets()
v1.c.chat.msg = ""
v1.c.chat.sp = 0.5
v1.c.chat.char = 0
+ v1.turret = {}
+ v1.turret[1] = {r=math.rad(30),x=0,y=0,rt=math.rad(30)}
+ v1.turret[2] = {r=math.rad(15),x=0,y=0,rt=math.rad(15)}
+ v1.turret[3] = {r=math.rad(-15),x=0,y=0,rt=math.rad(-15)}
+ v1.turret[4] = {r=math.rad(-30),x=0,y=0,rt=math.rad(-30)}
+ v1.bullets = {}
+ v1.bullet = love.graphics.newImage("assets/bullet_green.png")
+ v1.bulletTimer = 0
v1.c.idle = {}
v1.c.idle.fs = {}
v1.c.idle.pic = love.graphics.newImage("assets/virus1_idle_noeye.png")
diff --git a/assets/bullet_green.png b/assets/bullet_green.png
new file mode 100644
index 0000000..74c92cd
--- /dev/null
+++ b/assets/bullet_green.png
Binary files differ
diff --git a/virus1.lua b/virus1.lua
index 097fe5d..169b764 100644
--- a/virus1.lua
+++ b/virus1.lua
@@ -116,8 +116,37 @@ function drawVirusFight1()
v1.c.yd = v1.c.y
v1.c.load = true
end
- love.graphics.setColor(0,0,0,100)
- playAnimation(v1.c.idle, true, v1.c.x+40, v1.c.y+40, v1.c.r, v1.c.s, 100, 100, 0.5)
+ if v1.c.chat.msgs > 30 then
+ for i=1,4 do
+ v1.turret[i].rt = math.atan2((win[4].y+win[4].h/2 - v1.turret[i].y), (win[4].x+win[4].w/2 - v1.turret[i].x))-math.rad(90)
+ if v1.turret[i].r > v1.turret[i].rt then
+ if v1.turret[i].r - math.rad(2) < v1.turret[i].rt then
+ v1.turret[i].r = v1.turret[i].rt
+ else
+ v1.turret[i].r = v1.turret[i].r - math.rad(2)
+ end
+ elseif v1.turret[i].r < v1.turret[i].rt then
+ if v1.turret[i].r + math.rad(2) > v1.turret[i].rt then
+ v1.turret[i].r = v1.turret[i].rt
+ else
+ v1.turret[i].r = v1.turret[i].r + math.rad(2)
+ end
+ end
+ end
+ end
+ if v1.c.chat.msgs > 28 then
+ v1.turret[2].x = v1.c.x-120
+ v1.turret[2].y = v1.c.y+200-100
+ v1.turret[3].x = v1.c.x+120
+ v1.turret[3].y = v1.c.y+200-100
+ love.graphics.draw(v1.turret1, v1.turret[2].x, v1.turret[2].y, v1.turret[2].r, v1.c.s, v1.c.s, 42, 42)
+ love.graphics.draw(v1.turret1, v1.turret[3].x, v1.turret[3].y, v1.turret[3].r, v1.c.s, v1.c.s, 42, 42)
+ love.graphics.draw(v1.shipBack, v1.c.x-615/2, v1.c.y-100+20, 0, v1.c.s)
+ end
+ if v1.c.chat.msgs < 29 then
+ love.graphics.setColor(0,0,0,100)
+ playAnimation(v1.c.idle, true, v1.c.x+40, v1.c.y+40, v1.c.r, v1.c.s, 100, 100, 0.5)
+ end
love.graphics.setColor(255,255,255)
love.graphics.draw(v1.c.eye, v1.c.x-32, v1.c.y-50, v1.c.r, v1.c.s*0.9, v1.c.s*1.1)
if v1.c.chat.msgs < 3 or v1.c.chat.msgs == 26 or v1.c.chat.msgs == 7 or v1.c.chat.msgs == 11 or v1.c.chat.msgs == 15 then
@@ -145,8 +174,13 @@ function drawVirusFight1()
love.graphics.draw(v1.c.pupil, v1.c.x+7+v1.c.eyex+math.random(0,0.5), v1.c.y-28+v1.c.eyey+math.random(0,0.5), v1.c.r, v1.c.s*1.2, v1.c.s*1.2, 3, 11)
playAnimation(v1.c.idle, true, v1.c.x, v1.c.y, v1.c.r, v1.c.s, 100, 100, 0.5)
if v1.c.chat.msgs > 28 then
- love.graphics.draw(v1.ufoBottom, v1.c.x-368/2*1.2+5, v1.c.y-110+60, 0, v1.c.s*1.2)
- love.graphics.draw(v1.ufoTop, v1.c.x-368/2*1.2+5, v1.c.y-110+60, 0, v1.c.s*1.2)
+ v1.turret[1].x = v1.c.x-615/2-10
+ v1.turret[1].y = v1.c.y+95-100+20
+ v1.turret[4].x = v1.c.x+615/2+10
+ v1.turret[4].y = v1.c.y+95-100+20
+ love.graphics.draw(v1.shipFront, v1.c.x-615/2, v1.c.y-100+20, 0, v1.c.s)
+ love.graphics.draw(v1.turret2, v1.turret[1].x, v1.turret[1].y, v1.turret[1].r, v1.c.s, v1.c.s, 59/2, 40)
+ love.graphics.draw(v1.turret2, v1.turret[4].x, v1.turret[4].y, v1.turret[4].r, v1.c.s, v1.c.s, 59/2, 40)
end
if v1.c.chat.msgs == 2 then
v1.c.xd = sys.w/2
@@ -169,7 +203,7 @@ function drawVirusFight1()
v1.c.yd = -500
v1.c.xd = sys.w/2
elseif v1.c.chat.msgs == 29 then
- v1.c.yd = 140
+ v1.c.yd = 180
v1.c.xd = sys.w/2
end
if v1.c.shine.s < -50 and v1.msgs[v1.c.chat.msgs] ~= nil then
@@ -216,6 +250,16 @@ function drawVirusFight1()
v1.c.chat.char = 0
v1.c.chat.msg = ""
end
+ if v1.c.chat.msgs > 32 and v1.bulletTimer > 1 then
+ local x = math.cos(v1.turret[1].r+math.rad(90))*(v1.turret[1].x+148-v1.turret[1].x)
+ -math.sin(v1.turret[1].r+math.rad(90))*(v1.turret[1].y-v1.turret[1].y)+v1.turret[1].x
+ local y = math.sin(v1.turret[1].r+math.rad(90))*(v1.turret[1].x+148-v1.turret[1].x)
+ +math.cos(v1.turret[1].r+math.rad(90))*(v1.turret[1].y-v1.turret[1].y)+v1.turret[1].y
+ addBullet(x,y,v1.turret[1].r+math.rad(90),25,"v1")
+ v1.bulletTimer = 0
+ elseif v1.c.chat.msgs > 32 and v1.bulletTimer < 2 then
+ v1.bulletTimer = v1.bulletTimer + delta
+ end
v1.c.sp = math.sqrt(math.abs(v1.c.xd - v1.c.x)*2 + math.abs(v1.c.yd - v1.c.y)*2)/5
if v1.c.chat.msgs == 8 then
v1.c.sp = v1.c.sp*2
@@ -321,8 +365,24 @@ function addBullet(x,y,a,s,t)
if t == "av" then
table.insert(av.bullets, 1, {x=x,y=y,a=a,s=s,spx=0,spy=0,rm=false})
end
+ if t == "v1" then
+ table.insert(v1.bullets, 1, {x=x,y=y,a=a,s=s,spx=0,spy=0,rm=false})
+ end
end
function drawBullets()
+ for i=1,#v1.bullets do
+ v1.bullets[i].spx = v1.bullets[i].s * math.cos(v1.bullets[i].a)
+ v1.bullets[i].spy = v1.bullets[i].s * math.sin(v1.bullets[i].a)
+ v1.bullets[i].x = v1.bullets[i].x + v1.bullets[i].spx
+ v1.bullets[i].y = v1.bullets[i].y + v1.bullets[i].spy
+ love.graphics.draw(v1.bullet, v1.bullets[i].x, v1.bullets[i].y, v1.bullets[i].a, 1.5, 1.5, 23/2, 7)
+ if v1.bullets[i].x < 0 or v1.bullets[i].x > sys.w or v1.bullets[i].y < 0 or v1.bullets[i].y > sys.h then
+ v1.bullets[i].rm = true
+ end
+ if v1.bullets[i].rm == true then
+ table.remove(v1.bullets, i)
+ end
+ end
for i=1,#av.bullets do
av.bullets[i].spx = av.bullets[i].s * math.cos(av.bullets[i].a)
av.bullets[i].spy = av.bullets[i].s * math.sin(av.bullets[i].a)