changeset 336:c8fd82ff0c71

Hook up fire buttons to attack functions. Use correct check for tails. Add skeleton for projectiles.
author Simon Cross <hodgestar@gmail.com>
date Sat, 09 Apr 2011 12:29:34 +0200
parents c6552e9fc2e1
children 95dd2898f6d6
files skaapsteker/sprites/base.py skaapsteker/sprites/enemies.py skaapsteker/sprites/player.py skaapsteker/sprites/projectiles.py
diffstat 4 files changed, 44 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/skaapsteker/sprites/base.py	Sat Apr 09 12:15:19 2011 +0200
+++ b/skaapsteker/sprites/base.py	Sat Apr 09 12:29:34 2011 +0200
@@ -218,7 +218,7 @@
         OpenDialog.post(self)
 
 
-class Projectile(GameSprite):
+class Projectile(AnimatedGameSprite):
     gravitates = False
 
 
--- a/skaapsteker/sprites/enemies.py	Sat Apr 09 12:15:19 2011 +0200
+++ b/skaapsteker/sprites/enemies.py	Sat Apr 09 12:29:34 2011 +0200
@@ -27,3 +27,7 @@
             else:
                 self.facing = 'left'
         Monster.start_attack(self, player)
+
+
+class FireballOni(RedOni):
+    pass # TODO
--- a/skaapsteker/sprites/player.py	Sat Apr 09 12:15:19 2011 +0200
+++ b/skaapsteker/sprites/player.py	Sat Apr 09 12:29:34 2011 +0200
@@ -234,19 +234,32 @@
         elif self._me.item is not None:
             self.drop_item()
 
+    def _bite_attack(self):
+        print 'ninja bite attack'
+        self.attacking = 2
+        self._last_time = time.time() # Reset the animation clock
+
+    def _fireball_attack(self):
+        print 'ninja fireball attack attack attack'
+        self.attacking = 2
+        self._last_time = time.time() # Reset the animation clock
+
+    def _lightning_attack(self):
+        print 'thunderbolts and lightning'
+        self.attacking = 2
+        self._last_time = time.time() # Reset the animation clock
 
     def action_fire1(self):
-        # FIXME: Use the correct tail properties for this
-        if len(self._me.tails) < 2:
-            # Only have a bite attack
-            print 'attacking'
-            self.attacking = 2
-            # Reset the animation clock
-            self._last_time = time.time()
-        print "F1"
+        if "fireball" not in self._me.tails:
+            self._bite_attack()
+        else:
+            self._fireball_attack()
 
     def action_fire2(self):
-        print "F2"
+        if "lightning" not in self._me.tails:
+            self._bite_attack()
+        else:
+            self._lightning_attack()
 
     def _get_action(self):
         if self.attacking:
@@ -361,7 +374,5 @@
     def add_actionable(self, actionable):
         self._touching_actionables.append(actionable)
 
-
     def eat_aburage(self):
         self._me.tofu += 1
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/skaapsteker/sprites/projectiles.py	Sat Apr 09 12:29:34 2011 +0200
@@ -0,0 +1,17 @@
+"""Things people throw at each other."""
+
+from .sprites import Projectile
+
+class Fireball(Projectile):
+
+    gravitates = True
+
+    image_dir = 'sprites/fireball'
+    animation_regexes = [
+        ("raining_death", r"^fireball-\d+.png$"),
+    ]
+
+    def collided_player(self, player):
+        print "%s went boom with player" % self
+
+