# HG changeset patch # User prock@33b003aa-7bff-0310-803a-e67f0ece8222 # Date 1270156463 0 # Node ID f463ab431cc03ac822b67ebb4bbe233bf2c1aff7 # Parent ba6817013343f36a416a5f2d8d036c499cad289e Movement shouldn't be dependent on framerate anymore. Some minor tweaks. diff -r ba6817013343 -r f463ab431cc0 demos/shooter/scripts/common/baseobject.py --- a/demos/shooter/scripts/common/baseobject.py Thu Apr 01 19:26:56 2010 +0000 +++ b/demos/shooter/scripts/common/baseobject.py Thu Apr 01 21:14:23 2010 +0000 @@ -33,7 +33,7 @@ self._xscale = self._layer.getCellGrid().getXScale() self._yscale = self._layer.getCellGrid().getYScale() self._velocity = fife.DoublePoint(0,0) - self._maxvelocity = 1 + self._maxvelocity = 1.25 self._timedelta = 0 self._boundingBox = Rect(0,0,0,0) self._running = False @@ -54,11 +54,11 @@ shiploc = self.location exactloc = shiploc.getExactLayerCoordinates() - exactloc.x += self._velocity.x - exactloc.y += self._velocity.y + exactloc.x += self._velocity.x * (timedelta/1000.0)/self._xscale + exactloc.y += self._velocity.y * (timedelta/1000.0)/self._yscale - self._boundingBox.x = exactloc.x - self._boundingBox.w/2 - self._boundingBox.y = exactloc.y - self._boundingBox.h/2 + self._boundingBox.x = (exactloc.x - self._boundingBox.w/2) * self._xscale + self._boundingBox.y = (exactloc.y - self._boundingBox.h/2) * self._yscale shiploc.setExactLayerCoordinates(exactloc) self.location = shiploc @@ -82,7 +82,7 @@ def applyBrake(self, brakingForce, timedelta): - if self._velocity.length() <= .001: + if self._velocity.length() <= .01: self._velocity.x = 0 self._velocity.y = 0 return diff -r ba6817013343 -r f463ab431cc0 demos/shooter/scripts/scene.py --- a/demos/shooter/scripts/scene.py Thu Apr 01 19:26:56 2010 +0000 +++ b/demos/shooter/scripts/scene.py Thu Apr 01 21:14:23 2010 +0000 @@ -50,6 +50,8 @@ self._nodes = list() self._player = Player(self._model, 'player', self._layer) + self._player.width = 0.075 + self._player.height = 0.075 self._player.start() self._projectiles = list() @@ -68,23 +70,22 @@ self._nodes.append(SceneNode()) for instance in enemies: - loc = instance.getLocation().getExactLayerCoordinates() - objectName = instance.getObject().getId() print objectName enemy = Ship(self._model, 'enemy', self._layer, False) enemy.instance = instance - enemy.width = 0.5 - enemy.height = 0.5 - enemy.velocity.x = -0.013 + enemy.width = 0.075 + enemy.height = 0.075 + enemy.velocity.x = -0.13 enemy.start() - + + loc = instance.getLocation().getExactLayerCoordinates() nodeindex = int(loc.x * xscale) self._nodes[nodeindex].spaceobjects.append(enemy) - def getObjectsInNode(self, node): - return self._nodes[node].instances + def getObjectsInNode(self, nodeindex): + return self._nodes[nodeindex].instances def getObjectsInRange(self, rangeL, rangeR): objects = list() diff -r ba6817013343 -r f463ab431cc0 demos/shooter/scripts/ships/player.py --- a/demos/shooter/scripts/ships/player.py Thu Apr 01 19:26:56 2010 +0000 +++ b/demos/shooter/scripts/ships/player.py Thu Apr 01 21:14:23 2010 +0000 @@ -29,7 +29,7 @@ class Player(Ship): def __init__(self, model, playerName, layer): super(Player, self).__init__(model, playerName, layer) - self._bounds = Rect(-100,-100,200,200) + self._score = 0 def _getScore(self): @@ -44,20 +44,20 @@ oldpos = self.location if keystate['UP']: - self.applyThrust(fife.DoublePoint(0,-0.075), timedelta) + self.applyThrust(fife.DoublePoint(0,-0.75), timedelta) key = True if keystate['DOWN']: - self.applyThrust(fife.DoublePoint(0,0.075), timedelta) + self.applyThrust(fife.DoublePoint(0,0.75), timedelta) key = True if keystate['LEFT']: - self.applyThrust(fife.DoublePoint(-0.075,0), timedelta) + self.applyThrust(fife.DoublePoint(-0.75,0), timedelta) key = True if keystate['RIGHT']: - self.applyThrust(fife.DoublePoint(0.075,0), timedelta) + self.applyThrust(fife.DoublePoint(0.75,0), timedelta) key = True if not key and self._velocity.length() > 0: - self.applyBrake(0.075, timedelta) + self.applyBrake(0.75, timedelta) super(Player, self).update(timedelta) @@ -69,28 +69,21 @@ camrect = Rect(topleft.x, topleft.y, bottomright.x - topleft.x, bottomright.y - topleft.y) #player bounding box - #TODO: make this configurable xscale = self._layer.getCellGrid().getXScale() yscale = self._layer.getCellGrid().getYScale() - pos = self.location.getExactLayerCoordinates() - bbox = Rect() - bbox.x = pos.x*xscale - 0.175 - bbox.y = pos.y*yscale - 0.175 - bbox.w = 0.25 - bbox.h = 0.25 + #add the padding to the edge - camrect.x += bbox.w - camrect.y += bbox.h - camrect.w -= 2*bbox.w - camrect.h -= 2*bbox.h - + camrect.x += self._boundingBox.w + camrect.y += self._boundingBox.h + camrect.w -= 2*self._boundingBox.w + camrect.h -= 2*self._boundingBox.h - if not bbox.intersects(camrect): - if (bbox.x + bbox.w) < camrect.x: + if not self._boundingBox.intersects(camrect): + if (self._boundingBox.x + self._boundingBox.w) < camrect.x: #pos.x = (bbox.x + bbox.w/2 + 0.1) / xscale #oldpos.setExactLayerCoordinates(pos) - self._velocity.x = (timedelta * 0.001) / xscale + self._velocity.x = (timedelta * 0.01) / xscale # elif (bbox.y + bbox.h) < camrect.y or (bbox.y - bbox.h) > camrect.y: # pos.x += self._velocity.x * (timedelta/1000.0) diff -r ba6817013343 -r f463ab431cc0 demos/shooter/scripts/ships/shipbase.py --- a/demos/shooter/scripts/ships/shipbase.py Thu Apr 01 19:26:56 2010 +0000 +++ b/demos/shooter/scripts/ships/shipbase.py Thu Apr 01 21:14:23 2010 +0000 @@ -32,7 +32,6 @@ def __init__(self, model, name, layer, findInstance=True): super(Ship, self).__init__(model, name, layer, findInstance) - self._maxvelocity = 0.025/sqrt(self._xscale * self._yscale) self._timedelta = 0 self._weapon = None diff -r ba6817013343 -r f463ab431cc0 demos/shooter/scripts/weapons.py --- a/demos/shooter/scripts/weapons.py Thu Apr 01 19:26:56 2010 +0000 +++ b/demos/shooter/scripts/weapons.py Thu Apr 01 21:14:23 2010 +0000 @@ -75,13 +75,13 @@ self._ship = ship self._firerate = firerate self._lastfired = 0 - self._projectileVelocity = fife.DoublePoint(0.075,0) + self._projectileVelocity = fife.DoublePoint(0.75,0) def fire(self, curtime): if (curtime - self._lastfired) > self._firerate: pjctl = Projectile(self._model, "bullet1", self._layer, 2000 ) - pjctl.width = 0.05 - pjctl.height = 0.05 + pjctl.width = 0.025 + pjctl.height = 0.025 pjctl.run(fife.DoublePoint(self._projectileVelocity.x,self._projectileVelocity.y), self._ship.location, curtime) self._lastfired = curtime return pjctl diff -r ba6817013343 -r f463ab431cc0 demos/shooter/scripts/world.py --- a/demos/shooter/scripts/world.py Thu Apr 01 19:26:56 2010 +0000 +++ b/demos/shooter/scripts/world.py Thu Apr 01 21:14:23 2010 +0000 @@ -88,7 +88,7 @@ self.mainwindow.show() #give player the default weapon - self.scene.player.weapon = Weapon(self.model, self.map.getLayer('objects'), self.scene.player, 100) + self.scene.player.weapon = Weapon(self.model, self.map.getLayer('objects'), self.scene.player, 200) self.scene.initScene(self.map) def initCameras(self):