Files

93 lines
2.5 KiB
Lua

copter={
name="copter",
hab=7,
x=9,
y=2,
w=96,
h=80,
flip=false,
frame=0,
wait=0,
step=0,
energy=_energy,
max_energy = _energy,
hit=zombie.hit,
update=zombie.update_normal,
draw=zombie.draw,
jumpfwd=false,
anim={},
bb={x=16,y=3,w=80,h=29},
can_warp=false,
warping=false,
shrink=1,
d_shrink=1,
angle=0,
d_angle=15,
dying=false,
death_time=40,
enabled=true,
disable_reason="",
enabled=true,
rider = nil,
gir = {}
}
function copter.init(rider)
if rider==nil then
local world_x, world_y = coords.room_to_world(copter.hab,copter.x,copter.y)
copter.x=world_x
copter.y=world_y
else
copter.rider = rider
copter.hab = rider.hab
copter.x = rider.x-32
copter.y = rider.y-32
copter.y = copter.y-16
end
copter.gir[1] = math.random(8)-1
copter.gir[2] = math.random(4)-1
copter.gir[3] = math.random(8)-1
copter.gir[4] = math.random(6)-1
copter.gir[5] = math.random(8)-1
copter.gir[6] = math.random(4)-1
end
function copter.draw()
-- local curr_sf = surf.source()
surf.source.push(tiles2)
local scr_x, scr_y = viewp:screen_coords( copter.x, copter.y )
draw.surf(0,0,copter.w,copter.h,scr_x,scr_y,copter.w,copter.h,copter.flip)
if copter.wait==0 or copter.wait==32 then
copter.gir[1] = math.random(8)-1
copter.gir[2] = math.random(4)-1
copter.gir[3] = math.random(8)-1
copter.gir[4] = math.random(6)-1
copter.gir[5] = math.random(8)-1
copter.gir[6] = math.random(4)-1
end
if copter.wait>=0 and copter.wait<8 then
draw.line(scr_x+47,scr_y+16,scr_x+14,scr_y+17+copter.gir[6],16)
draw.line(scr_x+49,scr_y+23,scr_x+49+copter.gir[1],scr_y+40,16)
draw.line(scr_x+51,scr_y+22,scr_x+93,scr_y+27+copter.gir[2],16)
elseif copter.wait>=8 then
draw.line(scr_x+49,scr_y+23,scr_x+19+copter.gir[3],scr_y+41,16)
draw.line(scr_x+51,scr_y+23,scr_x+64+copter.gir[4],scr_y+38,16)
draw.line(scr_x+47,scr_y+16,scr_x+43+copter.gir[5],scr_y+8,16)
end
-- surf.source(curr_sf)
surf.source.pop()
end
function copter.update()
copter.step = copter.step +1
copter.wait = copter.wait +1
if copter.wait==16 then
copter.wait = 0
end
if copter.rider~=nil then
copter.hab = copter.rider.hab
copter.x = copter.rider.x-32
copter.y = copter.rider.y-32
copter.y = copter.y-16
end
end