Changeset 400:1501d9b7f5dd


Ignore:
Timestamp:
04/09/11 14:50:54 (12 years ago)
Author:
Neil Muller <drnlmuller@…>
Branch:
default
Phase:
public
Rebase:
36653833326530633436313539313430623730396162663664396634376464636465326165353762
Message:

Don't allow patrolling monsters to walk off edges

File:
1 edited

Legend:

Unmodified
Added
Removed
  • skaapsteker/sprites/base.py

    r399 r400  
    239239                self._update_image(True)
    240240
     241    def check_floors(self, floors):
     242        """If we're only on 1 floor tile, and our centre is beyond half way,
     243           turn back"""
     244        if len(floors) > 1:
     245            return
     246
     247        floor = floors[0]
     248
     249        if self.facing == 'left':
     250            if self.collide_rect.centerx < floor.collide_rect.centerx:
     251                self.facing = 'right'
     252                self._update_image(True)
     253        else:
     254            if self.collide_rect.centerx > floor.collide_rect.centerx:
     255                self.facing = 'left'
     256                self._update_image(True)
    241257
    242258class NPC(AnimatedGameSprite):
Note: See TracChangeset for help on using the changeset viewer.