annotate demos/shooter/scripts/scene.py @ 480:85fa5fa486a8

Added a simple sound manager. Added music to the level.
author prock@33b003aa-7bff-0310-803a-e67f0ece8222
date Wed, 28 Apr 2010 17:28:29 +0000
parents ab28994820dd
children 1f37adc9a685
rev   line source
446
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
1 # -*- coding: utf-8 -*-
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
2
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
3 # ####################################################################
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
4 # Copyright (C) 2005-2009 by the FIFE team
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
5 # http://www.fifengine.de
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
6 # This file is part of FIFE.
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
7 #
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
8 # FIFE is free software; you can redistribute it and/or
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
9 # modify it under the terms of the GNU Lesser General Public
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
10 # License as published by the Free Software Foundation; either
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
11 # version 2.1 of the License, or (at your option) any later version.
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
12 #
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
13 # This library is distributed in the hope that it will be useful,
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
16 # Lesser General Public License for more details.
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
17 #
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
18 # You should have received a copy of the GNU Lesser General Public
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
19 # License along with this library; if not, write to the
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
20 # Free Software Foundation, Inc.,
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
21 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
22 # ####################################################################
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
23
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
24 from fife import fife
477
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
25 from scripts.ships.shipbase import *
446
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
26 from scripts.ships.player import Player
452
f07d779362da Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 451
diff changeset
27 from scripts.ships.enemies import *
479
ab28994820dd Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 478
diff changeset
28 from scripts.powerups import *
446
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
29 from scripts.common.helpers import Rect
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
30
448
5e2ec84902a7 Did a little re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 447
diff changeset
31 class SceneNode(object):
5e2ec84902a7 Did a little re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 447
diff changeset
32 def __init__(self, spaceobjects = None):
5e2ec84902a7 Did a little re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 447
diff changeset
33 if not spaceobjects:
5e2ec84902a7 Did a little re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 447
diff changeset
34 self._spaceobjects = list()
5e2ec84902a7 Did a little re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 447
diff changeset
35 else:
5e2ec84902a7 Did a little re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 447
diff changeset
36 self._spaceobjects = spaceobjects
5e2ec84902a7 Did a little re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 447
diff changeset
37
5e2ec84902a7 Did a little re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 447
diff changeset
38 def _getObjects(self):
5e2ec84902a7 Did a little re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 447
diff changeset
39 return self._spaceobjects
5e2ec84902a7 Did a little re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 447
diff changeset
40
5e2ec84902a7 Did a little re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 447
diff changeset
41 def _setObjects(self, spaceobjects):
5e2ec84902a7 Did a little re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 447
diff changeset
42 self._spaceobjects = spaceobjects
5e2ec84902a7 Did a little re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 447
diff changeset
43
5e2ec84902a7 Did a little re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 447
diff changeset
44 spaceobjects = property(_getObjects, _setObjects)
447
64676ea55472 Added the ability to set the scale of the object layer. Tweaked the player controls a little bit. A little more work needs to be done to keep the player within the bounds of the camera.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 446
diff changeset
45
446
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
46 class Scene(object):
480
85fa5fa486a8 Added a simple sound manager.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 479
diff changeset
47 def __init__(self, world, engine, objectLayer, soundmanager):
446
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
48 self._engine = engine
457
597b066d5ccb Player now has 3 lives and will receive a game over message once they are used up.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 455
diff changeset
49 self._world = world
446
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
50 self._model = engine.getModel()
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
51 self._layer = objectLayer
480
85fa5fa486a8 Added a simple sound manager.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 479
diff changeset
52 self._soundmanager = soundmanager
448
5e2ec84902a7 Did a little re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 447
diff changeset
53 self._nodes = list()
446
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
54
454
bd7e8f708adf Time is now managed by the Scene object.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 453
diff changeset
55 self._player = None
476
78a1eb57c074 Changed the way instances get deleted from the scene. Instances now get removed at the end of the frame as opposed to after their explosion action is complete. The old way was causing the odd segfault because the instance was being removed before FIFE was finished with it.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 475
diff changeset
56 self._objectstodelete = list()
446
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
57
448
5e2ec84902a7 Did a little re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 447
diff changeset
58 self._maxnodes = 128
453
cf53848fb187 Scene now gets updated when an object moves from one node to another.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 452
diff changeset
59 self._xscale = 0
cf53848fb187 Scene now gets updated when an object moves from one node to another.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 452
diff changeset
60
cf53848fb187 Scene now gets updated when an object moves from one node to another.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 452
diff changeset
61 self._time = 0
cf53848fb187 Scene now gets updated when an object moves from one node to another.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 452
diff changeset
62 self._timedelta = 0
454
bd7e8f708adf Time is now managed by the Scene object.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 453
diff changeset
63 self._lasttime = 0
bd7e8f708adf Time is now managed by the Scene object.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 453
diff changeset
64
bd7e8f708adf Time is now managed by the Scene object.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 453
diff changeset
65 self._xscale = self._layer.getCellGrid().getXScale()
bd7e8f708adf Time is now managed by the Scene object.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 453
diff changeset
66 self._yscale = self._layer.getCellGrid().getYScale()
455
e686b82d93d0 Added the ability to pause the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 454
diff changeset
67
e686b82d93d0 Added the ability to pause the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 454
diff changeset
68 self._paused = False
e686b82d93d0 Added the ability to pause the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 454
diff changeset
69 self._timemod = 0
457
597b066d5ccb Player now has 3 lives and will receive a game over message once they are used up.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 455
diff changeset
70
597b066d5ccb Player now has 3 lives and will receive a game over message once they are used up.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 455
diff changeset
71 self._gameover = False
467
4d0aa75a82f1 Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 465
diff changeset
72
4d0aa75a82f1 Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 465
diff changeset
73 def destroyScene(self):
4d0aa75a82f1 Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 465
diff changeset
74 nodestodelete = list()
4d0aa75a82f1 Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 465
diff changeset
75 objtodelete = list()
4d0aa75a82f1 Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 465
diff changeset
76
4d0aa75a82f1 Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 465
diff changeset
77 for node in self._nodes:
4d0aa75a82f1 Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 465
diff changeset
78 nodestodelete.append(node)
4d0aa75a82f1 Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 465
diff changeset
79 for obj in node.spaceobjects:
4d0aa75a82f1 Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 465
diff changeset
80 objtodelete.append(node)
4d0aa75a82f1 Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 465
diff changeset
81
4d0aa75a82f1 Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 465
diff changeset
82 for obj in objtodelete:
4d0aa75a82f1 Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 465
diff changeset
83 if obj in node.spaceobjects:
478
41f7754f2a4b Fixed a small bug where projectiles wouldn't be removed from the scene after passing the far right edge of the screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 477
diff changeset
84 if obj.instance:
41f7754f2a4b Fixed a small bug where projectiles wouldn't be removed from the scene after passing the far right edge of the screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 477
diff changeset
85 self._layer.deleteInstance(obj.instance)
41f7754f2a4b Fixed a small bug where projectiles wouldn't be removed from the scene after passing the far right edge of the screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 477
diff changeset
86 obj.instance = None
467
4d0aa75a82f1 Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 465
diff changeset
87 node.spaceobjects.remove(obj)
4d0aa75a82f1 Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 465
diff changeset
88
4d0aa75a82f1 Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 465
diff changeset
89 objtodelete = list()
4d0aa75a82f1 Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 465
diff changeset
90
4d0aa75a82f1 Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 465
diff changeset
91 for node in nodestodelete:
4d0aa75a82f1 Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 465
diff changeset
92 if node in self._nodes:
4d0aa75a82f1 Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 465
diff changeset
93 self._nodes.remove(node)
4d0aa75a82f1 Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 465
diff changeset
94
448
5e2ec84902a7 Did a little re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 447
diff changeset
95 def initScene(self, mapobj):
459
302a69c5141d Player death is now handled a bit nicer.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 458
diff changeset
96 #initialize our scene array to some arbitrary size
302a69c5141d Player death is now handled a bit nicer.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 458
diff changeset
97 for i in range(0,self._maxnodes):
302a69c5141d Player death is now handled a bit nicer.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 458
diff changeset
98 self._nodes.append(SceneNode())
302a69c5141d Player death is now handled a bit nicer.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 458
diff changeset
99
454
bd7e8f708adf Time is now managed by the Scene object.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 453
diff changeset
100 self._player = Player(self, 'player')
457
597b066d5ccb Player now has 3 lives and will receive a game over message once they are used up.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 455
diff changeset
101 self._player.init()
454
bd7e8f708adf Time is now managed by the Scene object.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 453
diff changeset
102 self._player.start()
459
302a69c5141d Player death is now handled a bit nicer.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 458
diff changeset
103
302a69c5141d Player death is now handled a bit nicer.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 458
diff changeset
104 enemies = list()
479
ab28994820dd Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 478
diff changeset
105 powerups = list()
448
5e2ec84902a7 Did a little re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 447
diff changeset
106
459
302a69c5141d Player death is now handled a bit nicer.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 458
diff changeset
107 temp = self._layer.getInstances('dodge1')
302a69c5141d Player death is now handled a bit nicer.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 458
diff changeset
108 enemies.extend(temp)
302a69c5141d Player death is now handled a bit nicer.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 458
diff changeset
109
302a69c5141d Player death is now handled a bit nicer.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 458
diff changeset
110 temp = self._layer.getInstances('dodge2')
302a69c5141d Player death is now handled a bit nicer.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 458
diff changeset
111 enemies.extend(temp)
302a69c5141d Player death is now handled a bit nicer.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 458
diff changeset
112
302a69c5141d Player death is now handled a bit nicer.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 458
diff changeset
113 temp = self._layer.getInstances("diag_top_right")
302a69c5141d Player death is now handled a bit nicer.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 458
diff changeset
114 enemies.extend(temp)
302a69c5141d Player death is now handled a bit nicer.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 458
diff changeset
115
302a69c5141d Player death is now handled a bit nicer.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 458
diff changeset
116 temp = self._layer.getInstances("diag_bottom_right")
302a69c5141d Player death is now handled a bit nicer.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 458
diff changeset
117 enemies.extend(temp)
302a69c5141d Player death is now handled a bit nicer.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 458
diff changeset
118
302a69c5141d Player death is now handled a bit nicer.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 458
diff changeset
119 temp = self._layer.getInstances("streaker")
302a69c5141d Player death is now handled a bit nicer.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 458
diff changeset
120 enemies.extend(temp)
302a69c5141d Player death is now handled a bit nicer.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 458
diff changeset
121
467
4d0aa75a82f1 Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 465
diff changeset
122 temp = self._layer.getInstances("boss")
4d0aa75a82f1 Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 465
diff changeset
123 enemies.extend(temp)
479
ab28994820dd Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 478
diff changeset
124
ab28994820dd Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 478
diff changeset
125 temp = self._layer.getInstances("cannonspread5")
ab28994820dd Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 478
diff changeset
126 powerups.extend(temp)
ab28994820dd Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 478
diff changeset
127
ab28994820dd Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 478
diff changeset
128 temp = self._layer.getInstances("extralife")
ab28994820dd Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 478
diff changeset
129 powerups.extend(temp)
467
4d0aa75a82f1 Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 465
diff changeset
130
448
5e2ec84902a7 Did a little re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 447
diff changeset
131 for instance in enemies:
459
302a69c5141d Player death is now handled a bit nicer.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 458
diff changeset
132 objectName = instance.getId()
448
5e2ec84902a7 Did a little re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 447
diff changeset
133
459
302a69c5141d Player death is now handled a bit nicer.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 458
diff changeset
134 if objectName == "dodge1":
463
ac0f62a07a3e Added enemy explosions and other animations.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 462
diff changeset
135 enemy = Saucer1(self, 'enemy', instance, False)
459
302a69c5141d Player death is now handled a bit nicer.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 458
diff changeset
136 elif objectName == "dodge2":
463
ac0f62a07a3e Added enemy explosions and other animations.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 462
diff changeset
137 enemy = Saucer2(self, 'enemy', instance, False)
459
302a69c5141d Player death is now handled a bit nicer.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 458
diff changeset
138 elif objectName == "diag_top_right":
463
ac0f62a07a3e Added enemy explosions and other animations.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 462
diff changeset
139 enemy = DiagSaucer(self, 'enemy', 0, instance, False)
459
302a69c5141d Player death is now handled a bit nicer.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 458
diff changeset
140 elif objectName == "diag_bottom_right":
463
ac0f62a07a3e Added enemy explosions and other animations.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 462
diff changeset
141 enemy = DiagSaucer(self, 'enemy', 1, instance, False)
459
302a69c5141d Player death is now handled a bit nicer.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 458
diff changeset
142 elif objectName == "streaker":
463
ac0f62a07a3e Added enemy explosions and other animations.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 462
diff changeset
143 enemy = Streaker(self, 'enemy', instance, False)
467
4d0aa75a82f1 Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 465
diff changeset
144 elif objectName == "boss":
4d0aa75a82f1 Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 465
diff changeset
145 enemy = Boss(self, 'enemy', instance, False)
452
f07d779362da Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 451
diff changeset
146 else:
463
ac0f62a07a3e Added enemy explosions and other animations.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 462
diff changeset
147 enemy = Ship(self, 'enemy', instance, False)
452
f07d779362da Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 451
diff changeset
148
449
1cf56403347a Added object bounding boxes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 448
diff changeset
149 enemy.start()
451
f463ab431cc0 Movement shouldn't be dependent on framerate anymore.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 450
diff changeset
150
f463ab431cc0 Movement shouldn't be dependent on framerate anymore.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 450
diff changeset
151 loc = instance.getLocation().getExactLayerCoordinates()
453
cf53848fb187 Scene now gets updated when an object moves from one node to another.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 452
diff changeset
152 nodeindex = int(loc.x * self._xscale)
cf53848fb187 Scene now gets updated when an object moves from one node to another.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 452
diff changeset
153 enemy.scenenodeid = nodeindex
448
5e2ec84902a7 Did a little re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 447
diff changeset
154 self._nodes[nodeindex].spaceobjects.append(enemy)
453
cf53848fb187 Scene now gets updated when an object moves from one node to another.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 452
diff changeset
155
479
ab28994820dd Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 478
diff changeset
156 for instance in powerups:
ab28994820dd Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 478
diff changeset
157 objectName = instance.getId()
ab28994820dd Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 478
diff changeset
158
ab28994820dd Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 478
diff changeset
159 print objectName
ab28994820dd Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 478
diff changeset
160
ab28994820dd Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 478
diff changeset
161 if objectName == "cannonspread5":
ab28994820dd Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 478
diff changeset
162 powerup = CannonSpread5PU(self, 'cannonspread5', instance, False)
ab28994820dd Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 478
diff changeset
163 elif objectName == "extralife":
ab28994820dd Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 478
diff changeset
164 powerup = ExtraLifePU(self, 'extralife', instance, False)
ab28994820dd Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 478
diff changeset
165 else:
ab28994820dd Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 478
diff changeset
166 powerup = PowerUp(self, 'powerup', instance, False)
ab28994820dd Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 478
diff changeset
167
ab28994820dd Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 478
diff changeset
168 powerup.start()
ab28994820dd Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 478
diff changeset
169
ab28994820dd Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 478
diff changeset
170 loc = instance.getLocation().getExactLayerCoordinates()
ab28994820dd Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 478
diff changeset
171 nodeindex = int(loc.x * self._xscale)
ab28994820dd Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 478
diff changeset
172 powerup.scenenodeid = nodeindex
ab28994820dd Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 478
diff changeset
173 self._nodes[nodeindex].spaceobjects.append(powerup)
ab28994820dd Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 478
diff changeset
174
453
cf53848fb187 Scene now gets updated when an object moves from one node to another.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 452
diff changeset
175 #and finally add the player to the scene
cf53848fb187 Scene now gets updated when an object moves from one node to another.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 452
diff changeset
176 self.addObjectToScene(self._player)
457
597b066d5ccb Player now has 3 lives and will receive a game over message once they are used up.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 455
diff changeset
177
480
85fa5fa486a8 Added a simple sound manager.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 479
diff changeset
178 self._soundmanager.playSound("music/waynesmind2.ogg")
85fa5fa486a8 Added a simple sound manager.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 479
diff changeset
179
467
4d0aa75a82f1 Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 465
diff changeset
180 self.startCamera()
4d0aa75a82f1 Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 465
diff changeset
181
455
e686b82d93d0 Added the ability to pause the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 454
diff changeset
182 def pause(self, time):
e686b82d93d0 Added the ability to pause the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 454
diff changeset
183 self._pausedtime = time
e686b82d93d0 Added the ability to pause the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 454
diff changeset
184 self._paused = True
e686b82d93d0 Added the ability to pause the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 454
diff changeset
185
e686b82d93d0 Added the ability to pause the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 454
diff changeset
186 def unpause(self, time):
e686b82d93d0 Added the ability to pause the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 454
diff changeset
187 self._timemod += time - self._pausedtime
e686b82d93d0 Added the ability to pause the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 454
diff changeset
188 self._paused = False
457
597b066d5ccb Player now has 3 lives and will receive a game over message once they are used up.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 455
diff changeset
189
475
afde89c1d50b Switched to a damage system. Collisions with objects now cause 1 damage to the player.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 474
diff changeset
190 def playerHit(self, damage):
afde89c1d50b Switched to a damage system. Collisions with objects now cause 1 damage to the player.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 474
diff changeset
191 self._player.applyHit(damage)
afde89c1d50b Switched to a damage system. Collisions with objects now cause 1 damage to the player.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 474
diff changeset
192
afde89c1d50b Switched to a damage system. Collisions with objects now cause 1 damage to the player.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 474
diff changeset
193 def gameOver(self):
afde89c1d50b Switched to a damage system. Collisions with objects now cause 1 damage to the player.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 474
diff changeset
194 self._gameover = True
480
85fa5fa486a8 Added a simple sound manager.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 479
diff changeset
195 self._soundmanager.stopSound("music/waynesmind2.ogg")
475
afde89c1d50b Switched to a damage system. Collisions with objects now cause 1 damage to the player.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 474
diff changeset
196 self._world.gameOver()
467
4d0aa75a82f1 Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 465
diff changeset
197
4d0aa75a82f1 Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 465
diff changeset
198 def endLevel(self):
480
85fa5fa486a8 Added a simple sound manager.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 479
diff changeset
199 self._soundmanager.stopSound("music/waynesmind2.ogg")
467
4d0aa75a82f1 Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 465
diff changeset
200 self._world.endLevel()
458
e77ebf128a74 Fixed a small bug where projectiles are not updated when it is game over.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 457
diff changeset
201
476
78a1eb57c074 Changed the way instances get deleted from the scene. Instances now get removed at the end of the frame as opposed to after their explosion action is complete. The old way was causing the odd segfault because the instance was being removed before FIFE was finished with it.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 475
diff changeset
202 def queueObjectForRemoval(self, obj):
78a1eb57c074 Changed the way instances get deleted from the scene. Instances now get removed at the end of the frame as opposed to after their explosion action is complete. The old way was causing the odd segfault because the instance was being removed before FIFE was finished with it.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 475
diff changeset
203 self._objectstodelete.append(obj)
455
e686b82d93d0 Added the ability to pause the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 454
diff changeset
204
451
f463ab431cc0 Movement shouldn't be dependent on framerate anymore.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 450
diff changeset
205 def getObjectsInNode(self, nodeindex):
f463ab431cc0 Movement shouldn't be dependent on framerate anymore.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 450
diff changeset
206 return self._nodes[nodeindex].instances
448
5e2ec84902a7 Did a little re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 447
diff changeset
207
5e2ec84902a7 Did a little re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 447
diff changeset
208 def getObjectsInRange(self, rangeL, rangeR):
5e2ec84902a7 Did a little re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 447
diff changeset
209 objects = list()
5e2ec84902a7 Did a little re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 447
diff changeset
210
5e2ec84902a7 Did a little re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 447
diff changeset
211 for i in range(rangeL, rangeR):
5e2ec84902a7 Did a little re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 447
diff changeset
212 objects.extend(self._nodes[i].spaceobjects)
5e2ec84902a7 Did a little re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 447
diff changeset
213
5e2ec84902a7 Did a little re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 447
diff changeset
214 return objects
453
cf53848fb187 Scene now gets updated when an object moves from one node to another.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 452
diff changeset
215
cf53848fb187 Scene now gets updated when an object moves from one node to another.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 452
diff changeset
216 def addObjectToScene(self, obj):
cf53848fb187 Scene now gets updated when an object moves from one node to another.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 452
diff changeset
217 #TODO: search to ensure the object isn't already part of the scene
cf53848fb187 Scene now gets updated when an object moves from one node to another.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 452
diff changeset
218 loc = obj.instance.getLocation().getExactLayerCoordinates()
cf53848fb187 Scene now gets updated when an object moves from one node to another.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 452
diff changeset
219 nodeindex = int(loc.x * self._xscale)
471
7a79dc2a0592 Adding the credits window (still needs to be written)
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 470
diff changeset
220
477
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
221 if nodeindex >= 0:
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
222 obj.scenenodeid = nodeindex
478
41f7754f2a4b Fixed a small bug where projectiles wouldn't be removed from the scene after passing the far right edge of the screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 477
diff changeset
223 if not obj in self._nodes[nodeindex].spaceobjects:
41f7754f2a4b Fixed a small bug where projectiles wouldn't be removed from the scene after passing the far right edge of the screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 477
diff changeset
224 self._nodes[nodeindex].spaceobjects.append(obj)
477
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
225 else:
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
226 self.queueObjectForRemoval(obj)
453
cf53848fb187 Scene now gets updated when an object moves from one node to another.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 452
diff changeset
227
cf53848fb187 Scene now gets updated when an object moves from one node to another.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 452
diff changeset
228 def moveObjectInScene(self, obj):
cf53848fb187 Scene now gets updated when an object moves from one node to another.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 452
diff changeset
229 loc = obj.instance.getLocation().getExactLayerCoordinates()
cf53848fb187 Scene now gets updated when an object moves from one node to another.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 452
diff changeset
230 nodeindex = int(loc.x * self._xscale)
cf53848fb187 Scene now gets updated when an object moves from one node to another.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 452
diff changeset
231
477
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
232 if nodeindex >= 0:
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
233 if nodeindex != obj.scenenodeid:
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
234 if obj in self._nodes[obj.scenenodeid].spaceobjects:
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
235 self._nodes[obj.scenenodeid].spaceobjects.remove(obj)
471
7a79dc2a0592 Adding the credits window (still needs to be written)
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 470
diff changeset
236
477
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
237 self._nodes[nodeindex].spaceobjects.append(obj)
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
238
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
239 obj.scenenodeid = nodeindex
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
240 else:
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
241 self.queueObjectForRemoval(obj)
471
7a79dc2a0592 Adding the credits window (still needs to be written)
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 470
diff changeset
242
450
ba6817013343 Added score keeping ability.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 449
diff changeset
243 def removeObjectFromScene(self, obj):
ba6817013343 Added score keeping ability.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 449
diff changeset
244 for node in self._nodes:
ba6817013343 Added score keeping ability.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 449
diff changeset
245 if obj in node.spaceobjects:
477
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
246 if obj.instance:
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
247 self._layer.deleteInstance(obj.instance)
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
248 obj.instance = None
450
ba6817013343 Added score keeping ability.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 449
diff changeset
249 node.spaceobjects.remove(obj)
477
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
250 break
448
5e2ec84902a7 Did a little re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 447
diff changeset
251
446
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
252 def attachCamera(self, cam):
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
253 self._camera = cam
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
254 self._camera.setLocation(self._player.location)
467
4d0aa75a82f1 Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 465
diff changeset
255
4d0aa75a82f1 Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 465
diff changeset
256 def stopCamera(self):
4d0aa75a82f1 Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 465
diff changeset
257 self._cameraspeed = 0
446
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
258
467
4d0aa75a82f1 Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 465
diff changeset
259 def startCamera(self):
4d0aa75a82f1 Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 465
diff changeset
260 self._cameraspeed = 0.001
478
41f7754f2a4b Fixed a small bug where projectiles wouldn't be removed from the scene after passing the far right edge of the screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 477
diff changeset
261
41f7754f2a4b Fixed a small bug where projectiles wouldn't be removed from the scene after passing the far right edge of the screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 477
diff changeset
262 def collectGarbage(self):
41f7754f2a4b Fixed a small bug where projectiles wouldn't be removed from the scene after passing the far right edge of the screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 477
diff changeset
263 for obj in self._objectstodelete:
41f7754f2a4b Fixed a small bug where projectiles wouldn't be removed from the scene after passing the far right edge of the screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 477
diff changeset
264 self.removeObjectFromScene(obj)
41f7754f2a4b Fixed a small bug where projectiles wouldn't be removed from the scene after passing the far right edge of the screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 477
diff changeset
265
41f7754f2a4b Fixed a small bug where projectiles wouldn't be removed from the scene after passing the far right edge of the screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 477
diff changeset
266 self._objectstodelete = list()
467
4d0aa75a82f1 Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 465
diff changeset
267
446
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
268 def update(self, time, keystate):
455
e686b82d93d0 Added the ability to pause the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 454
diff changeset
269 timedelta = (time - self._timemod) - self._time
453
cf53848fb187 Scene now gets updated when an object moves from one node to another.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 452
diff changeset
270 self._timedelta = timedelta
455
e686b82d93d0 Added the ability to pause the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 454
diff changeset
271 self._time = time - self._timemod
453
cf53848fb187 Scene now gets updated when an object moves from one node to another.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 452
diff changeset
272
cf53848fb187 Scene now gets updated when an object moves from one node to another.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 452
diff changeset
273 self._keystate = keystate
446
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
274
477
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
275
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
276 #some garbage cleanup
478
41f7754f2a4b Fixed a small bug where projectiles wouldn't be removed from the scene after passing the far right edge of the screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 477
diff changeset
277 self.collectGarbage()
477
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
278
446
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
279 #update camera location
447
64676ea55472 Added the ability to set the scale of the object layer. Tweaked the player controls a little bit. A little more work needs to be done to keep the player within the bounds of the camera.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 446
diff changeset
280 loc = self._camera.getLocation()
446
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
281 exactloc = self._camera.getLocation().getExactLayerCoordinates()
453
cf53848fb187 Scene now gets updated when an object moves from one node to another.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 452
diff changeset
282 #slowly move to the right
467
4d0aa75a82f1 Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 465
diff changeset
283 exactloc.x += timedelta * self._cameraspeed
446
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
284 loc.setExactLayerCoordinates(exactloc)
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
285 self._camera.setLocation(loc)
448
5e2ec84902a7 Did a little re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 447
diff changeset
286
5e2ec84902a7 Did a little re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 447
diff changeset
287 topleft = self._camera.toMapCoordinates(fife.ScreenPoint(0,0))
5e2ec84902a7 Did a little re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 447
diff changeset
288 bottomright = self._camera.toMapCoordinates(fife.ScreenPoint(1024,768))
467
4d0aa75a82f1 Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 465
diff changeset
289
449
1cf56403347a Added object bounding boxes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 448
diff changeset
290 #which scene nodes to use to update objects
448
5e2ec84902a7 Did a little re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 447
diff changeset
291 leftnode = int(topleft.x)
450
ba6817013343 Added score keeping ability.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 449
diff changeset
292 rightnode = int(bottomright.x) + 1
448
5e2ec84902a7 Did a little re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 447
diff changeset
293
450
ba6817013343 Added score keeping ability.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 449
diff changeset
294 #get a list of objects on the screen
448
5e2ec84902a7 Did a little re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 447
diff changeset
295 if leftnode < 0:
5e2ec84902a7 Did a little re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 447
diff changeset
296 leftnode = 0
5e2ec84902a7 Did a little re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 447
diff changeset
297 if rightnode > self._maxnodes:
5e2ec84902a7 Did a little re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 447
diff changeset
298 rightnode = self._maxnodes
449
1cf56403347a Added object bounding boxes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 448
diff changeset
299 screenlist = self.getObjectsInRange(leftnode, rightnode)
453
cf53848fb187 Scene now gets updated when an object moves from one node to another.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 452
diff changeset
300
450
ba6817013343 Added score keeping ability.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 449
diff changeset
301 #update objects on the screen
ba6817013343 Added score keeping ability.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 449
diff changeset
302 for obj in screenlist:
477
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
303 if obj.type == SHTR_LASTBOSS:
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
304 if bottomright.x > ((obj.location.getExactLayerCoordinates().x * self._xscale) + 0.5):
467
4d0aa75a82f1 Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 465
diff changeset
305 self.stopCamera()
4d0aa75a82f1 Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 465
diff changeset
306
477
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
307 if not (obj.type == SHTR_PLAYER and self._gameover):
457
597b066d5ccb Player now has 3 lives and will receive a game over message once they are used up.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 455
diff changeset
308 obj.update()
597b066d5ccb Player now has 3 lives and will receive a game over message once they are used up.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 455
diff changeset
309
453
cf53848fb187 Scene now gets updated when an object moves from one node to another.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 452
diff changeset
310 if obj.changedposition:
cf53848fb187 Scene now gets updated when an object moves from one node to another.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 452
diff changeset
311 self.moveObjectInScene(obj)
447
64676ea55472 Added the ability to set the scale of the object layer. Tweaked the player controls a little bit. A little more work needs to be done to keep the player within the bounds of the camera.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 446
diff changeset
312
477
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
313 if obj.type != SHTR_PLAYER and obj.type != SHTR_PROJECTILE:
463
ac0f62a07a3e Added enemy explosions and other animations.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 462
diff changeset
314 if obj.running and obj.boundingbox.intersects(self._player.boundingbox):
479
ab28994820dd Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 478
diff changeset
315 if obj.type == SHTR_ENEMYSHIP:
ab28994820dd Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 478
diff changeset
316 #player touched an enemy. Destroy player and
ab28994820dd Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 478
diff changeset
317 #re-initialize scene
ab28994820dd Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 478
diff changeset
318 if not self._player.invulnerable:
ab28994820dd Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 478
diff changeset
319 #collision damage of 1
ab28994820dd Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 478
diff changeset
320 self.playerHit(1)
ab28994820dd Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 478
diff changeset
321 obj.applyHit(1)
ab28994820dd Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 478
diff changeset
322 elif obj.type == SHTR_POWERUP:
ab28994820dd Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 478
diff changeset
323 obj.applyPowerUp(self._player)
477
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
324
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
325 elif obj.type == SHTR_PROJECTILE:
478
41f7754f2a4b Fixed a small bug where projectiles wouldn't be removed from the scene after passing the far right edge of the screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 477
diff changeset
326
41f7754f2a4b Fixed a small bug where projectiles wouldn't be removed from the scene after passing the far right edge of the screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 477
diff changeset
327 #projectile went off the right edge of the screen. Remove it from the scene.
41f7754f2a4b Fixed a small bug where projectiles wouldn't be removed from the scene after passing the far right edge of the screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 477
diff changeset
328 if obj.scenenodeid >= rightnode:
41f7754f2a4b Fixed a small bug where projectiles wouldn't be removed from the scene after passing the far right edge of the screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 477
diff changeset
329 self.queueObjectForRemoval(obj)
41f7754f2a4b Fixed a small bug where projectiles wouldn't be removed from the scene after passing the far right edge of the screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 477
diff changeset
330 continue
41f7754f2a4b Fixed a small bug where projectiles wouldn't be removed from the scene after passing the far right edge of the screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 477
diff changeset
331
477
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
332 #could probably just get the nodes in the projectiles scenenode.
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
333 #use a range to be sure.
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
334 pcollide = self.getObjectsInRange(obj.scenenodeid - 1, obj.scenenodeid + 1)
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
335
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
336 for o in pcollide:
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
337 #cant get hit by your own bullet
479
ab28994820dd Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 478
diff changeset
338 if obj.owner != o and o.type != SHTR_PROJECTILE and o.type != SHTR_POWERUP:
477
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
339 if o.running and obj.boundingbox.intersects(o.boundingbox):
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
340 if o != self._player and obj.owner.type == SHTR_PLAYER:
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
341 o.applyHit(obj.damage)
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
342 #check if enemy ship was destroyed
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
343 if not o.running:
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
344 self._player.applyScore(o.scorevalue)
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
345 obj.destroy()
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
346 elif o == self._player:
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
347 #player got hit by a projectile
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
348 if not self._player.invulnerable:
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
349 self.playerHit(obj.damage)
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
350 obj.destroy()
460
5e1d6e40d19d Fixed bounding boxes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 459
diff changeset
351
477
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
352 #queue list of projectiles to remove (ttl expired or has been destroyed)
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
353 if not obj.running:
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
354 self.queueObjectForRemoval(obj)
450
ba6817013343 Added score keeping ability.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 449
diff changeset
355
477
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
356 # self._world.renderBoundingBox(obj)
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
357
453
cf53848fb187 Scene now gets updated when an object moves from one node to another.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 452
diff changeset
358
cf53848fb187 Scene now gets updated when an object moves from one node to another.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 452
diff changeset
359
cf53848fb187 Scene now gets updated when an object moves from one node to another.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 452
diff changeset
360 def _getPlayer(self):
cf53848fb187 Scene now gets updated when an object moves from one node to another.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 452
diff changeset
361 return self._player
446
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
362
453
cf53848fb187 Scene now gets updated when an object moves from one node to another.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 452
diff changeset
363 def _getKeyState(self):
cf53848fb187 Scene now gets updated when an object moves from one node to another.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 452
diff changeset
364 return self._keystate
cf53848fb187 Scene now gets updated when an object moves from one node to another.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 452
diff changeset
365
cf53848fb187 Scene now gets updated when an object moves from one node to another.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 452
diff changeset
366 def _getCamera(self):
cf53848fb187 Scene now gets updated when an object moves from one node to another.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 452
diff changeset
367 return self._camera
cf53848fb187 Scene now gets updated when an object moves from one node to another.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 452
diff changeset
368
cf53848fb187 Scene now gets updated when an object moves from one node to another.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 452
diff changeset
369 def _getObjectLayer(self):
cf53848fb187 Scene now gets updated when an object moves from one node to another.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 452
diff changeset
370 return self._layer
cf53848fb187 Scene now gets updated when an object moves from one node to another.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 452
diff changeset
371
cf53848fb187 Scene now gets updated when an object moves from one node to another.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 452
diff changeset
372 def _getModel(self):
cf53848fb187 Scene now gets updated when an object moves from one node to another.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 452
diff changeset
373 return self._model
cf53848fb187 Scene now gets updated when an object moves from one node to another.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 452
diff changeset
374
cf53848fb187 Scene now gets updated when an object moves from one node to another.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 452
diff changeset
375 def _getTime(self):
cf53848fb187 Scene now gets updated when an object moves from one node to another.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 452
diff changeset
376 return self._time
cf53848fb187 Scene now gets updated when an object moves from one node to another.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 452
diff changeset
377
cf53848fb187 Scene now gets updated when an object moves from one node to another.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 452
diff changeset
378 def _getTimeDelta(self):
cf53848fb187 Scene now gets updated when an object moves from one node to another.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 452
diff changeset
379 return self._timedelta
455
e686b82d93d0 Added the ability to pause the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 454
diff changeset
380
e686b82d93d0 Added the ability to pause the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 454
diff changeset
381 def _getPaused(self):
e686b82d93d0 Added the ability to pause the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 454
diff changeset
382 return self._paused
e686b82d93d0 Added the ability to pause the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 454
diff changeset
383
446
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
384 player = property(_getPlayer)
453
cf53848fb187 Scene now gets updated when an object moves from one node to another.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 452
diff changeset
385 keystate = property(_getKeyState)
cf53848fb187 Scene now gets updated when an object moves from one node to another.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 452
diff changeset
386 camera = property(_getCamera)
cf53848fb187 Scene now gets updated when an object moves from one node to another.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 452
diff changeset
387 objectlayer = property(_getObjectLayer)
cf53848fb187 Scene now gets updated when an object moves from one node to another.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 452
diff changeset
388 model = property(_getModel)
cf53848fb187 Scene now gets updated when an object moves from one node to another.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 452
diff changeset
389 time = property(_getTime)
cf53848fb187 Scene now gets updated when an object moves from one node to another.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 452
diff changeset
390 timedelta = property(_getTimeDelta)
455
e686b82d93d0 Added the ability to pause the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 454
diff changeset
391 paused = property(_getPaused)