|
@@ -0,0 +1,127 @@
|
|
|
+-- title: untitled shmup
|
|
|
+-- author: game developer
|
|
|
+-- desc: something like Gradius/Nemesis/Salamander/Life Force
|
|
|
+-- script: lua
|
|
|
+
|
|
|
+t=0
|
|
|
+
|
|
|
+local bullet_speed = 6
|
|
|
+local bullet_timer = 0
|
|
|
+local bullet_timer_start = 10
|
|
|
+
|
|
|
+local player_bullets = {}
|
|
|
+
|
|
|
+local player = {
|
|
|
+ x=0,y=0,
|
|
|
+ vx=0,vy=0,
|
|
|
+ speed=1.5,
|
|
|
+ sp=256,
|
|
|
+ fire_t=0,
|
|
|
+ fire_held=false,
|
|
|
+}
|
|
|
+
|
|
|
+-- TODO: various types
|
|
|
+function add_bullet()
|
|
|
+ sfx(0, 'D-6', 10, 0, 11, 4)
|
|
|
+ table.insert(player_bullets, {
|
|
|
+ x=player.x + 10,
|
|
|
+ y=player.y + 5,
|
|
|
+ vx = 0,
|
|
|
+ vy = 0,
|
|
|
+ })
|
|
|
+end
|
|
|
+
|
|
|
+function draw_player()
|
|
|
+ spr(player.sp, player.x, player.y, 0, 1, 0, 0, 2, 2)
|
|
|
+end
|
|
|
+
|
|
|
+function draw_bullets()
|
|
|
+ for key,val in ipairs(player_bullets) do
|
|
|
+ spr(258, val.x, val.y, 0)
|
|
|
+ end
|
|
|
+end
|
|
|
+
|
|
|
+function handle_input()
|
|
|
+ player.vx = 0
|
|
|
+ player.vy = 0
|
|
|
+ if btn(0) then
|
|
|
+ player.vy=-player.speed
|
|
|
+ end
|
|
|
+ if btn(1) then
|
|
|
+ player.vy=player.speed
|
|
|
+ end
|
|
|
+ if btn(2) then
|
|
|
+ player.vx=-player.speed
|
|
|
+ end
|
|
|
+ if btn(3) then
|
|
|
+ player.vx=player.speed
|
|
|
+ end
|
|
|
+
|
|
|
+ -- slow down diagonal movements
|
|
|
+ if player.vx * player.vy ~= 0 then
|
|
|
+ player.vx = player.vx * 0.707
|
|
|
+ player.vy = player.vy * 0.707
|
|
|
+ end
|
|
|
+
|
|
|
+ player.x = player.x + player.vx
|
|
|
+ player.y = player.y + player.vy
|
|
|
+
|
|
|
+ player.fire_held = false
|
|
|
+ if btn(4) then
|
|
|
+ if player.fire_t <= 0 then
|
|
|
+ player.fire_t = bullet_timer_start
|
|
|
+ add_bullet()
|
|
|
+ else
|
|
|
+ player.fire_t = player.fire_t - 1
|
|
|
+ end
|
|
|
+ player.fire_held = true
|
|
|
+ else
|
|
|
+ player.fire_t = 0
|
|
|
+ end
|
|
|
+end
|
|
|
+
|
|
|
+function TIC()
|
|
|
+ handle_input()
|
|
|
+
|
|
|
+ for key,val in ipairs(player_bullets) do
|
|
|
+ val.x = val.x + bullet_speed
|
|
|
+ if val.x > 240 then
|
|
|
+ table.remove(player_bullets, key)
|
|
|
+ end
|
|
|
+ end
|
|
|
+
|
|
|
+ cls(0)
|
|
|
+ draw_player()
|
|
|
+ draw_bullets()
|
|
|
+
|
|
|
+ dbg(tostring(player.fire_t), 0)
|
|
|
+ dbg(tostring(player.fire_held), 1)
|
|
|
+ dbg(tostring(player.vx), 2)
|
|
|
+ dbg(tostring(player.vy), 3)
|
|
|
+ t=t+1
|
|
|
+end
|
|
|
+
|
|
|
+function dbg(msg, line_no)
|
|
|
+ print(msg, 5, line_no * 7, 5, true, 1, true)
|
|
|
+end
|
|
|
+
|
|
|
+-- <SPRITES>
|
|
|
+-- 000:00000000000000000000000000000000ede00000ecdef0000edddef00fcccc8b
|
|
|
+-- 001:000000000000000000000000000000000000000000000000000000009cde0000
|
|
|
+-- 002:0000000000000000000000004040440030303300000000000000000000000000
|
|
|
+-- 016:cf9edd99dfb8eeee00db8ddd00008cce00000000000000000000000000000000
|
|
|
+-- 017:aaeddcefeeeccde0ccde00000000000000000000000000000000000000000000
|
|
|
+-- </SPRITES>
|
|
|
+
|
|
|
+-- <WAVES>
|
|
|
+-- 000:123345667889abbcdeff1fedcba86642
|
|
|
+-- </WAVES>
|
|
|
+
|
|
|
+-- <SFX>
|
|
|
+-- 000:00d050808060c040d020e020f010f010f000f000f000f000f000f000f000f000f000f000f000f000f000f000f000f000f000f000f000f000f000f000502000000000
|
|
|
+-- </SFX>
|
|
|
+
|
|
|
+-- <PALETTE>
|
|
|
+-- 000:1a1c2c5d275db13e53ef7d57ffcd75a7f07038b76425717929366f3b5dc941a6f673eff7f4f4f494b0c2566c86333c57
|
|
|
+-- </PALETTE>
|
|
|
+
|