Browse Source

apparently there are more buttons than 2

pixelbath 2 years ago
parent
commit
9ee4faf04c
1 changed files with 27 additions and 13 deletions
  1. 27 13
      einhander/einhander.lua

+ 27 - 13
einhander/einhander.lua

@@ -3,6 +3,13 @@
 -- desc:   one-handed
 -- script: lua
 
+-- TODO:
+-- configurable controls
+-- cannon: more animation when firing
+-- gun transition sprites
+-- enemy collisions
+-- ammo counting
+
 seed=12345
 player={
 	x=20, y=50,
@@ -348,19 +355,18 @@ function update()
             player.x=player.x+2
         end
     end
-    if btnp(4) then
-        player.gun_held = player.gun_held + 1
-        if player.gun_held > 6 then player.gun_held = 0 end
+    -- A: fire main gun
+    if btn(4) then
+        if player.fire == 0 then
+            player.fire = 5
+            table.insert(p_bullets, {x=player.x+10, y=player.y+2})
+        else
+            player.fire = player.fire - 1
+        end
     end
+
+    -- B: fire accessory gun
     if btn(5) then
-        --if player.gun_held == 0 then
-            if player.fire == 0 then
-                player.fire = 5
-                --table.insert(p_bullets, {x=player.x+10, y=player.y+2})
-            else
-                player.fire = player.fire - 1
-            end
-        --end
         if player.gun_held == 1 then
             player.is_firing = 1
         end
@@ -382,13 +388,21 @@ function update()
         end
     else
         player.big_gun_cooldown = 0
+        player.is_firing = 0
     end
-    if btnp(5) then
-        -- debug
+
+    -- X: switch arm
+    if btnp(6) then
         player.gun_down = not player.gun_down
         player.gun_anim = 1
     end
 
+    -- Y: swap weapon (debug)
+    if btnp(7) then
+        player.gun_held = player.gun_held + 1
+        if player.gun_held > 6 then player.gun_held = 0 end
+    end
+
     for key,val in ipairs(p_bullets) do
         p_bullets[key].x = p_bullets[key].x + 8
         if val.x > 240 then