changeset 414:f14b4da859c4

merge
author Adrianna Pińska <adrianna.pinska@gmail.com>
date Sat, 09 Apr 2011 17:36:48 +0200
parents 5f896e2f78c4 (current diff) 8ac5b3d619fe (diff)
children cfbf1bf9a54c
files
diffstat 7 files changed, 124 insertions(+), 45 deletions(-) [+]
line wrap: on
line diff
--- a/data/levels/celestial_plane.json	Sat Apr 09 17:36:31 2011 +0200
+++ b/data/levels/celestial_plane.json	Sat Apr 09 17:36:48 2011 +0200
@@ -37,15 +37,15 @@
         "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
     ],
     "enemies": [
-        {"type": "RedOni", "pos": [26, 7], "direction": "left" },
-        {"type": "RedOni", "pos": [13, 10], "direction": "right" },
-        {"type": "RedOni", "pos": [18, 10], "direction": "left" },
-        {"type": "RedOni", "pos": [18, 24], "direction": "right" },
-        {"type": "RedOni", "pos": [12, 28], "direction": "left" },
-        {"type": "RedOni", "pos": [18, 28], "direction": "right" },
-        {"type": "RedOni", "pos": [24, 28], "direction": "left" }
+        {"type": "FlyingOni", "pos": [26, 7], "direction": "left" },
+        {"type": "FlyingOni", "pos": [13, 10], "direction": "right" },
+        {"type": "FlyingOni", "pos": [18, 10], "direction": "left" },
+        {"type": "FlyingOni", "pos": [18, 24], "direction": "right" },
+        {"type": "FlyingOni", "pos": [12, 28], "direction": "left" },
+        {"type": "FlyingOni", "pos": [18, 28], "direction": "right" },
+        {"type": "FlyingOni", "pos": [24, 28], "direction": "left" }
     ],
     "doorways": {
         "starting": {"type": "Doorway", "pos": [16, 4], "facing": "right", "leadsto": "town.to_celestial_plane"}
     }
-}
\ No newline at end of file
+}
--- a/skaapsteker/constants.py	Sat Apr 09 17:36:31 2011 +0200
+++ b/skaapsteker/constants.py	Sat Apr 09 17:36:48 2011 +0200
@@ -58,11 +58,5 @@
     HEALTH_HEIGHT = 160
     HEALTH_WIDTH = 20
 
-    RECHARGE_BACKGROUND = pygame.Color(64, 128, 0, 128)
-    RECHARGE_FOREGROUND = pygame.Color(64, 255, 0, 196)
-    RECHARGE_TOP = 220
-    RECHARGE_WIDTH = 50
-    RECHARGE_HEIGHT = 15
-
-    SCROLL_TOP = 240
-    TOFU_TOP = 270
+    SCROLL_TOP = 220
+    TOFU_TOP = 250
--- a/skaapsteker/levelscene.py	Sat Apr 09 17:36:31 2011 +0200
+++ b/skaapsteker/levelscene.py	Sat Apr 09 17:36:48 2011 +0200
@@ -254,14 +254,6 @@
         bar.bottomleft = health_bottom
         pygame.draw.rect(self._level_surface, fox_hud.HEALTH_FOREGROUND, bar)
 
-        # Draw fire recharge bar
-        recharge = pygame.Rect(self._clip_rect.right - 55,
-                               self._clip_rect.top + fox_hud.RECHARGE_TOP,
-                               fox_hud.RECHARGE_WIDTH, fox_hud.RECHARGE_HEIGHT)
-        pygame.draw.rect(self._level_surface, fox_hud.RECHARGE_BACKGROUND, recharge)
-        recharge.width = int(fox_hud.RECHARGE_WIDTH * self._player.recharge_level())
-        pygame.draw.rect(self._level_surface, fox_hud.RECHARGE_FOREGROUND, recharge)
-
         # Draw scroll count
         pos = self._clip_rect.right - 20, self._clip_rect.top + fox_hud.SCROLL_TOP + 5
         count = Text("%s" % len(fox.scrolls), pos)
--- a/skaapsteker/sprites/base.py	Sat Apr 09 17:36:31 2011 +0200
+++ b/skaapsteker/sprites/base.py	Sat Apr 09 17:36:48 2011 +0200
@@ -190,6 +190,8 @@
         self._done_attack = True
 
     def start_attack(self, player):
+        if player.invisible:
+            return
         if self._animation == 'attacking':
             return # We're already attacking
         elif self.attack_frame is not None:
@@ -231,12 +233,15 @@
         # Check if the object we've collided with is the same height our higher than us
         if (other.block or other.floor) and other.collide_rect.bottom <= self.collide_rect.bottom:
             # Change direction
-            if self.facing == 'left':
-                self.facing = 'right'
-                self._update_image(True)
-            else:
-                self.facing = 'left'
-                self._update_image(True)
+            self.change_facing()
+
+    def change_facing(self):
+        if self.facing == 'left':
+            self.facing = 'right'
+            self._update_image(True)
+        else:
+            self.facing = 'left'
+            self._update_image(True)
 
     def check_floors(self, floors):
         """If we're only on 1 floor tile, and our centre is beyond half way,
@@ -248,12 +253,10 @@
 
         if self.facing == 'left':
             if self.collide_rect.centerx < floor.collide_rect.centerx:
-                self.facing = 'right'
-                self._update_image(True)
+                self.change_facing()
         else:
             if self.collide_rect.centerx > floor.collide_rect.centerx:
-                self.facing = 'left'
-                self._update_image(True)
+                self.change_facing()
 
 class NPC(AnimatedGameSprite):
 
@@ -343,7 +346,6 @@
 
 
     def player_action(self, player):
-        print "Player touched %s" % self
         player.take_item(self)
 
 
--- a/skaapsteker/sprites/enemies.py	Sat Apr 09 17:36:31 2011 +0200
+++ b/skaapsteker/sprites/enemies.py	Sat Apr 09 17:36:48 2011 +0200
@@ -35,3 +35,44 @@
 
 class PatrollingOni(RedOni, PatrollingMonster):
     pass
+
+class FlyingOni(PatrollingOni):
+
+
+    gravitates = False
+
+    patrol_velocity = (0, 200)
+
+    def setup(self, direction):
+        PatrollingOni.setup(self, direction)
+        self.heading = 'up'
+
+    def update(self):
+        PatrollingOni.update(self)
+        if self._animation == 'running':
+            if self.heading == 'up':
+                self.velocity = (0, -self.patrol_velocity[1])
+            else:
+                self.velocity = (0, self.patrol_velocity[1])
+
+    def check_floors(self, floors):
+        pass
+
+    def collided(self, other):
+        if not other.block or not other.floor:
+            return
+        if other.collide_rect.bottom < self.collide_rect.bottom:
+            # We're colliding with something above us
+            if self.heading == 'up':
+                self.change_facing()
+        else:
+            if self.heading == 'down':
+                self.change_facing()
+
+    def change_facing(self):
+        if self.heading == 'up':
+            self.heading = 'down'
+        else:
+            self.heading = 'up'
+
+
--- a/skaapsteker/sprites/items.py	Sat Apr 09 17:36:31 2011 +0200
+++ b/skaapsteker/sprites/items.py	Sat Apr 09 17:36:48 2011 +0200
@@ -112,10 +112,52 @@
 class Kindling(Item):
     image_file = 'props/kindling.png'
 
+    def player_action(self, player):
+        if player.has_item('oil'):
+            set_fire(player, self)
+        else:
+            player.take_item(self)
+
 
 class Oil(Item):
     image_file = 'props/oil.png'
 
+    def player_action(self, player):
+        if player.has_item('kindling'):
+            set_fire(player, self)
+        else:
+            player.take_item(self)
+
+
+
+# TODO: Finish this thing's behaviour
+class SignalFire(Item):
+    image_file = 'dummy.png'
+
+    def setup(self, litness, **opts):
+        super(SignalFire, self).setup(**opts)
+
+
+    def player_action(self, player):
+        if self._me.litness == 'set':
+            if player.has_item('kindling'):
+                notify('You put the kindling in the fire.')
+            elif player.has_item('oil'):
+                notify('You pour the oil on the fire.')
+            else:
+                return
+            player.discard_item()
+            self._me.litness = 'kindled'
+        elif self._me.litness == 'kindled':
+            if player.has_item('kindling'):
+                notify('You put the kindling in the fire and light it.')
+            elif player.has_item('oil'):
+                notify('You pour the oil on the fire and light it.')
+            else:
+                return
+            player.discard_item()
+            self._me.litness = 'burning'
+            self.world.missions.fire_started_on_road = True
 
 
 ##################################################
--- a/skaapsteker/sprites/player.py	Sat Apr 09 17:36:31 2011 +0200
+++ b/skaapsteker/sprites/player.py	Sat Apr 09 17:36:48 2011 +0200
@@ -12,7 +12,6 @@
 
 from pygame.constants import BLEND_RGBA_MULT
 
-
 class Player(Sprite):
 
     collision_layer = PC_LAYER
@@ -31,7 +30,10 @@
         self._soundsystem.load_sound('yelp', 'sounds/yelp.ogg')
         self._animation_frame = 0.0
         self._last_time = time.time()
-        self._last_fired = time.time()
+        self._last_attacked = {
+                'fireball': time.time(),
+                'lightning': time.time(),
+        }
         self._inv_cache = {}
         # State flags and such
         self.attacking = 0
@@ -240,7 +242,6 @@
         self.flying = 1
         self._max_flight_time = float(len(self._me.tails))
         self._flight_start_time = time.time()
-
     def action_invisible(self):
         if self.invisible > 0 or 'invisibility' not in self._me.tails:
             return
@@ -300,6 +301,7 @@
             self.drop_item()
 
     def _bite_attack(self):
+        self.invisible = 0
         self.attacking = 2
         self._last_time = time.time() # Reset the animation clock
 
@@ -312,17 +314,23 @@
         AddSpriteEvent.post(projectile)
 
     def _fireball_attack(self):
+        if not self.check_fire_rate('fireball'):
+            return
+        self.invisible = 0
         self.attacking = 2
         self._last_time = time.time() # Reset the animation clock
         self._launch_projectile(Fireball)
 
     def _lightning_attack(self):
+        if not self.check_fire_rate('lightning'):
+            return
+        self.invisible = 0
         self.attacking = 2
         self._last_time = time.time() # Reset the animation clock
         self._launch_projectile(Lightning)
 
     def action_fire1(self):
-        if self._me.shape != 'fox' or not self.check_fire_rate():
+        if self._me.shape != 'fox':
             return
         if "fireball" not in self._me.tails:
             self._bite_attack()
@@ -330,21 +338,21 @@
             self._fireball_attack()
 
     def action_fire2(self):
-        if self._me.shape != 'fox' or not self.check_fire_rate():
+        if self._me.shape != 'fox':
             return
         if "lightning" not in self._me.tails:
             self._bite_attack()
         else:
             self._lightning_attack()
 
-    def check_fire_rate(self):
-        if self.recharge_level() < 1:
+    def check_fire_rate(self, attack):
+        if self.recharge_level(attack) < 1:
             return False
-        self._last_fired = time.time()
+        self._last_attacked[attack] = time.time()
         return True
 
-    def recharge_level(self):
-        return min((time.time() - self._last_fired) / RECHARGE_TIME, 1)
+    def recharge_level(self, attack):
+        return min((time.time() - self._last_attacked[attack]) / RECHARGE_TIME, 1)
 
     def _get_action(self):
         if self.attacking: