Mercurial > fife-parpg
comparison demos/shooter/scripts/ships/player.py @ 448:5e2ec84902a7
Did a little re-factoring.
Introduced the scene graph for collision detection.
Changed the time scale to be accurate.
author | prock@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Thu, 01 Apr 2010 17:03:34 +0000 |
parents | 64676ea55472 |
children | 1cf56403347a |
comparison
equal
deleted
inserted
replaced
447:64676ea55472 | 448:5e2ec84902a7 |
---|---|
25 from scripts.ships.shipbase import Ship | 25 from scripts.ships.shipbase import Ship |
26 from scripts.common.helpers import Rect | 26 from scripts.common.helpers import Rect |
27 | 27 |
28 | 28 |
29 class Player(Ship): | 29 class Player(Ship): |
30 def __init__(self, scene, shipName, layer): | 30 def __init__(self, model, playerName, layer): |
31 super(Player, self).__init__(scene, shipName, layer, True) | 31 super(Player, self).__init__(model, playerName, layer) |
32 self._bounds = Rect(-100,-100,200,200) | 32 self._bounds = Rect(-100,-100,200,200) |
33 | 33 |
34 def update(self, timedelta, keystate, camera): | 34 def update(self, timedelta, keystate, camera): |
35 key = False | 35 key = False |
36 | 36 |
37 oldpos = self.location | 37 oldpos = self.location |
38 | 38 |
39 if keystate['UP']: | 39 if keystate['UP']: |
40 self.applyThrust(fife.DoublePoint(0,-0.075), timedelta) | 40 self.applyThrust(fife.DoublePoint(0,-0.0075), timedelta) |
41 key = True | 41 key = True |
42 if keystate['DOWN']: | 42 if keystate['DOWN']: |
43 self.applyThrust(fife.DoublePoint(0,0.075), timedelta) | 43 self.applyThrust(fife.DoublePoint(0,0.0075), timedelta) |
44 key = True | 44 key = True |
45 if keystate['LEFT']: | 45 if keystate['LEFT']: |
46 self.applyThrust(fife.DoublePoint(-0.075,0), timedelta) | 46 self.applyThrust(fife.DoublePoint(-0.0075,0), timedelta) |
47 key = True | 47 key = True |
48 if keystate['RIGHT']: | 48 if keystate['RIGHT']: |
49 self.applyThrust(fife.DoublePoint(0.075,0), timedelta) | 49 self.applyThrust(fife.DoublePoint(0.0075,0), timedelta) |
50 key = True | 50 key = True |
51 | 51 |
52 if not key and self._velocity.length() > 0: | 52 if not key and self._velocity.length() > 0: |
53 self.applyBrake(0.075) | 53 self.applyBrake(0.0075, timedelta) |
54 | 54 |
55 super(Player, self).update(timedelta) | 55 super(Player, self).update(timedelta) |
56 | 56 |
57 #set up the players camera bounds | 57 #set up the players camera bounds |
58 #TODO: grab screen resolution from somewhere | 58 #TODO: grab screen resolution from somewhere |