diff pytouhou/game/player.py @ 380:c25530efea3b

Replace player position in game zone right after its move; fix shots offsets at boundaries.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Fri, 07 Sep 2012 12:54:38 +0200
parents e0e284fcb288
children 690b5faaa0e6
line wrap: on
line diff
--- a/pytouhou/game/player.py
+++ b/pytouhou/game/player.py
@@ -197,6 +197,15 @@ class Player(object):
             self.state.x += dx
             self.state.y += dy
 
+            if self.state.x < 8.:
+                self.state.x = 8.
+            if self.state.x > self._game.width - 8:
+                self.state.x = self._game.width - 8.
+            if self.state.y < 16.:
+                self.state.y = 16.
+            if self.state.y > self._game.height - 16:
+                self.state.y = self._game.height -16.
+
             if not self.state.focused and keystate & 4:
                 self.start_focusing()
             elif self.state.focused and not keystate & 4: