Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add two weapons, gun and laser.

  • Loading branch information...
commit c5b403cc4a10ac45a47615f993222ebf4fb4d703 1 parent fe60acb
@TimothyFitz authored
Showing with 9 additions and 3 deletions.
  1. +9 −3 main.py
View
12 main.py
@@ -91,6 +91,7 @@ def main():
done = False
gun = Debounce(15)
+ laser = Debounce(60*5)
while not done:
glClear(GL_COLOR_BUFFER_BIT)
@@ -132,14 +133,19 @@ def main():
hx, hy = joy.state.hats[0]
player.x += hx*4
player.y += hy*4
+
+ keys = pygame.key.get_pressed()
- if any(joy.state.buttons):
+ if joy.state.buttons[0] or keys[pygame.K_z]:
if gun.fire():
player_bullets.load("player_basic_attack.xml", source=player, target=boss)
+
+ if joy.state.buttons[1] or keys[pygame.K_x]:
+ if laser.fire():
+ player_bullets.load("player_laser.xml", source=player, target=boss)
gun.step()
-
- keys = pygame.key.get_pressed()
+ laser.step()
if keys[pygame.K_RIGHT]:
player.x += 1
Please sign in to comment.
Something went wrong with that request. Please try again.