Changeset 409:ed26bbfec03a


Ignore:
Timestamp:
04/09/11 15:26:25 (12 years ago)
Author:
Neil Muller <drnlmuller@…>
Branch:
default
Phase:
public
Rebase:
34306437306166386435636333383531316164643036303234313638316330363533613265326661
Message:

Add up-down 'Fying' Oni

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • data/levels/celestial_plane.json

    r387 r409  
    3838    ],
    3939    "enemies": [
    40         {"type": "RedOni", "pos": [26, 7], "direction": "left" },
    41         {"type": "RedOni", "pos": [13, 10], "direction": "right" },
    42         {"type": "RedOni", "pos": [18, 10], "direction": "left" },
    43         {"type": "RedOni", "pos": [18, 24], "direction": "right" },
    44         {"type": "RedOni", "pos": [12, 28], "direction": "left" },
    45         {"type": "RedOni", "pos": [18, 28], "direction": "right" },
    46         {"type": "RedOni", "pos": [24, 28], "direction": "left" }
     40        {"type": "FlyingOni", "pos": [26, 7], "direction": "left" },
     41        {"type": "FlyingOni", "pos": [13, 10], "direction": "right" },
     42        {"type": "FlyingOni", "pos": [18, 10], "direction": "left" },
     43        {"type": "FlyingOni", "pos": [18, 24], "direction": "right" },
     44        {"type": "FlyingOni", "pos": [12, 28], "direction": "left" },
     45        {"type": "FlyingOni", "pos": [18, 28], "direction": "right" },
     46        {"type": "FlyingOni", "pos": [24, 28], "direction": "left" }
    4747    ],
    4848    "doorways": {
  • skaapsteker/sprites/base.py

    r400 r409  
    232232        if (other.block or other.floor) and other.collide_rect.bottom <= self.collide_rect.bottom:
    233233            # Change direction
    234             if self.facing == 'left':
    235                 self.facing = 'right'
    236                 self._update_image(True)
    237             else:
    238                 self.facing = 'left'
    239                 self._update_image(True)
     234            self.change_facing()
     235
     236    def change_facing(self):
     237        if self.facing == 'left':
     238            self.facing = 'right'
     239            self._update_image(True)
     240        else:
     241            self.facing = 'left'
     242            self._update_image(True)
    240243
    241244    def check_floors(self, floors):
     
    249252        if self.facing == 'left':
    250253            if self.collide_rect.centerx < floor.collide_rect.centerx:
    251                 self.facing = 'right'
    252                 self._update_image(True)
     254                self.change_facing()
    253255        else:
    254256            if self.collide_rect.centerx > floor.collide_rect.centerx:
    255                 self.facing = 'left'
    256                 self._update_image(True)
     257                self.change_facing()
    257258
    258259class NPC(AnimatedGameSprite):
  • skaapsteker/sprites/enemies.py

    r373 r409  
    3636class PatrollingOni(RedOni, PatrollingMonster):
    3737    pass
     38
     39class FlyingOni(PatrollingOni):
     40
     41
     42    gravitates = False
     43
     44    patrol_velocity = (0, 200)
     45
     46    def setup(self, direction):
     47        PatrollingOni.setup(self, direction)
     48        self.heading = 'up'
     49
     50    def update(self):
     51        PatrollingOni.update(self)
     52        if self._animation == 'running':
     53            if self.heading == 'up':
     54                self.velocity = (0, -self.patrol_velocity[1])
     55            else:
     56                self.velocity = (0, self.patrol_velocity[1])
     57
     58    def check_floors(self, floors):
     59        pass
     60
     61    def collided(self, other):
     62        if not other.block or not other.floor:
     63            return
     64        if other.collide_rect.bottom < self.collide_rect.bottom:
     65            # We're colliding with something above us
     66            if self.heading == 'up':
     67                self.change_facing()
     68        else:
     69            if self.heading == 'down':
     70                self.change_facing()
     71
     72    def change_facing(self):
     73        if self.heading == 'up':
     74            self.heading = 'down'
     75        else:
     76            self.heading = 'up'
     77
     78
Note: See TracChangeset for help on using the changeset viewer.