|
@@ -7,8 +7,9 @@
|
|
-- script: lua
|
|
-- script: lua
|
|
|
|
|
|
t=0
|
|
t=0
|
|
-x=96
|
|
|
|
-y=24
|
|
|
|
|
|
+
|
|
|
|
+local player_fire_cooldown = 3
|
|
|
|
+local player_bullet_speed = 5
|
|
|
|
|
|
local player = {
|
|
local player = {
|
|
screenx=110,
|
|
screenx=110,
|
|
@@ -18,8 +19,10 @@ local player = {
|
|
flip=0,
|
|
flip=0,
|
|
cnt_run=0,
|
|
cnt_run=0,
|
|
cnt_fire=0,
|
|
cnt_fire=0,
|
|
|
|
+ cdn_fire=0,
|
|
frames_run={258,260,262,260},
|
|
frames_run={258,260,262,260},
|
|
frame_slide=266,
|
|
frame_slide=266,
|
|
|
|
+ bullets={},
|
|
}
|
|
}
|
|
|
|
|
|
function BOOT()
|
|
function BOOT()
|
|
@@ -40,9 +43,14 @@ function update()
|
|
is_running = true
|
|
is_running = true
|
|
end
|
|
end
|
|
if btn(4) then
|
|
if btn(4) then
|
|
- player.cnt_fire = 10
|
|
|
|
|
|
+ if player.cdn_fire <= 0 then
|
|
|
|
+ player.cnt_fire = 10
|
|
|
|
+ player.cdn_fire = player_fire_cooldown
|
|
|
|
+ spawn_bullet()
|
|
|
|
+ end
|
|
else
|
|
else
|
|
player.cnt_fire = player.cnt_fire - 1
|
|
player.cnt_fire = player.cnt_fire - 1
|
|
|
|
+ player.cdn_fire = player.cdn_fire - 1
|
|
end
|
|
end
|
|
|
|
|
|
-- reset run counter if not pressing a button
|
|
-- reset run counter if not pressing a button
|
|
@@ -60,6 +68,30 @@ function update()
|
|
player.spr = player.spr + 32
|
|
player.spr = player.spr + 32
|
|
end
|
|
end
|
|
|
|
|
|
|
|
+ for key, bullet in ipairs(player.bullets) do
|
|
|
|
+ player.bullets[key].x = bullet.x + bullet.spd
|
|
|
|
+ if bullet.x < -8 or bullet.x > 248 then
|
|
|
|
+ table.remove(player.bullets, key)
|
|
|
|
+ end
|
|
|
|
+ end
|
|
|
|
+end
|
|
|
|
+
|
|
|
|
+function spawn_bullet()
|
|
|
|
+ local bullet_speed = player_bullet_speed
|
|
|
|
+ local bullet_x = player.screenx + 11
|
|
|
|
+ if player.flip == 1 then
|
|
|
|
+ bullet_speed = bullet_speed * -1
|
|
|
|
+ bullet_x = player.screenx
|
|
|
|
+ end
|
|
|
|
+
|
|
|
|
+ bullet = {
|
|
|
|
+ x = bullet_x,
|
|
|
|
+ y = player.screeny+7,
|
|
|
|
+ spd = bullet_speed,
|
|
|
|
+ spr = 286,
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ table.insert(player.bullets, bullet)
|
|
end
|
|
end
|
|
|
|
|
|
function draw_player(colorkey)
|
|
function draw_player(colorkey)
|
|
@@ -71,6 +103,11 @@ function draw_player(colorkey)
|
|
spr(270, player.screenx+8, player.screeny+2, colorkey, 1, player.flip)
|
|
spr(270, player.screenx+8, player.screeny+2, colorkey, 1, player.flip)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
+
|
|
|
|
+ -- draw bullets
|
|
|
|
+ for key, bullet in ipairs(player.bullets) do
|
|
|
|
+ spr(bullet.spr, bullet.x, bullet.y, colorkey, 1)
|
|
|
|
+ end
|
|
end
|
|
end
|
|
|
|
|
|
function TIC()
|
|
function TIC()
|