annotate demos/shooter/scripts/scene.py @ 489:0324a3533988

Updated the Shooter demo credits.txt file and added the LICENSE file for all media included in the demo. Cleaned up some print statements in the shooter demo.
author prock@33b003aa-7bff-0310-803a-e67f0ece8222
date Wed, 05 May 2010 14:29:37 +0000
parents 7f1c42b66aa4
children c4168eb47a44
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
481
1f37adc9a685 Added a SoundEmitter class that encapsulates the FIFE sound emitter. The SoundManager is now a factory for SoundEmitters. Also working on getting a callback going for when the sound is finished playing.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 480
diff changeset
72
1f37adc9a685 Added a SoundEmitter class that encapsulates the FIFE sound emitter. The SoundManager is now a factory for SoundEmitters. Also working on getting a callback going for when the sound is finished playing.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 480
diff changeset
73 self._music = 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
74
4d0aa75a82f1 Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 465
diff changeset
75 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
76 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
77 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
78
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 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
80 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
81 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
82 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
83
4d0aa75a82f1 Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 465
diff changeset
84 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
85 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
86 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
87 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
88 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
89 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
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 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
92
4d0aa75a82f1 Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 465
diff changeset
93 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
94 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
95 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
96
448
5e2ec84902a7 Did a little re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 447
diff changeset
97 def initScene(self, mapobj):
459
302a69c5141d Player death is now handled a bit nicer.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 458
diff changeset
98 #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
99 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
100 self._nodes.append(SceneNode())
302a69c5141d Player death is now handled a bit nicer.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 458
diff changeset
101
454
bd7e8f708adf Time is now managed by the Scene object.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 453
diff changeset
102 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
103 self._player.init()
454
bd7e8f708adf Time is now managed by the Scene object.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 453
diff changeset
104 self._player.start()
459
302a69c5141d Player death is now handled a bit nicer.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 458
diff changeset
105
302a69c5141d Player death is now handled a bit nicer.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 458
diff changeset
106 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
107 powerups = list()
448
5e2ec84902a7 Did a little re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 447
diff changeset
108
459
302a69c5141d Player death is now handled a bit nicer.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 458
diff changeset
109 temp = self._layer.getInstances('dodge1')
302a69c5141d Player death is now handled a bit nicer.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 458
diff changeset
110 enemies.extend(temp)
302a69c5141d Player death is now handled a bit nicer.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 458
diff changeset
111
302a69c5141d Player death is now handled a bit nicer.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 458
diff changeset
112 temp = self._layer.getInstances('dodge2')
302a69c5141d Player death is now handled a bit nicer.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 458
diff changeset
113 enemies.extend(temp)
302a69c5141d Player death is now handled a bit nicer.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 458
diff changeset
114
302a69c5141d Player death is now handled a bit nicer.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 458
diff changeset
115 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
116 enemies.extend(temp)
302a69c5141d Player death is now handled a bit nicer.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 458
diff changeset
117
302a69c5141d Player death is now handled a bit nicer.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 458
diff changeset
118 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
119 enemies.extend(temp)
302a69c5141d Player death is now handled a bit nicer.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 458
diff changeset
120
302a69c5141d Player death is now handled a bit nicer.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 458
diff changeset
121 temp = self._layer.getInstances("streaker")
302a69c5141d Player death is now handled a bit nicer.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 458
diff changeset
122 enemies.extend(temp)
302a69c5141d Player death is now handled a bit nicer.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 458
diff changeset
123
467
4d0aa75a82f1 Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 465
diff changeset
124 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
125 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
126
ab28994820dd Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 478
diff changeset
127 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
128 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
129
ab28994820dd Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 478
diff changeset
130 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
131 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
132
448
5e2ec84902a7 Did a little re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 447
diff changeset
133 for instance in enemies:
459
302a69c5141d Player death is now handled a bit nicer.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 458
diff changeset
134 objectName = instance.getId()
448
5e2ec84902a7 Did a little re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 447
diff changeset
135
459
302a69c5141d Player death is now handled a bit nicer.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 458
diff changeset
136 if objectName == "dodge1":
463
ac0f62a07a3e Added enemy explosions and other animations.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 462
diff changeset
137 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
138 elif objectName == "dodge2":
463
ac0f62a07a3e Added enemy explosions and other animations.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 462
diff changeset
139 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
140 elif objectName == "diag_top_right":
463
ac0f62a07a3e Added enemy explosions and other animations.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 462
diff changeset
141 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
142 elif objectName == "diag_bottom_right":
463
ac0f62a07a3e Added enemy explosions and other animations.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 462
diff changeset
143 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
144 elif objectName == "streaker":
463
ac0f62a07a3e Added enemy explosions and other animations.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 462
diff changeset
145 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
146 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
147 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
148 else:
463
ac0f62a07a3e Added enemy explosions and other animations.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 462
diff changeset
149 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
150
449
1cf56403347a Added object bounding boxes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 448
diff changeset
151 enemy.start()
451
f463ab431cc0 Movement shouldn't be dependent on framerate anymore.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 450
diff changeset
152
f463ab431cc0 Movement shouldn't be dependent on framerate anymore.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 450
diff changeset
153 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
154 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
155 enemy.scenenodeid = nodeindex
448
5e2ec84902a7 Did a little re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 447
diff changeset
156 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
157
479
ab28994820dd Added some powerups including a spread weapon and an extra life.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 478
diff changeset
158 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
159 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
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
483
82d44c471959 Modified the SoundManager to not create unique FIFE sound emitters for each object. There is now only one FIFE emitter per unique sound.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 481
diff changeset
178 self._music = self._soundmanager.loadSoundClip("music/waynesmind2.ogg")
485
d365eb58f3d6 SoundClip can now fire a callback after a sound has completed being played (i.e. the duration of the sound has passed by). I have added an example of this with the scene music. [t:346]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 483
diff changeset
179 self._music.callback = self.musicHasFinished
483
82d44c471959 Modified the SoundManager to not create unique FIFE sound emitters for each object. There is now only one FIFE emitter per unique sound.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 481
diff changeset
180 self._music.looping = True
82d44c471959 Modified the SoundManager to not create unique FIFE sound emitters for each object. There is now only one FIFE emitter per unique sound.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 481
diff changeset
181 self._soundmanager.playClip(self._music)
480
85fa5fa486a8 Added a simple sound manager.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 479
diff changeset
182
467
4d0aa75a82f1 Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 465
diff changeset
183 self.startCamera()
485
d365eb58f3d6 SoundClip can now fire a callback after a sound has completed being played (i.e. the duration of the sound has passed by). I have added an example of this with the scene music. [t:346]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 483
diff changeset
184
d365eb58f3d6 SoundClip can now fire a callback after a sound has completed being played (i.e. the duration of the sound has passed by). I have added an example of this with the scene music. [t:346]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 483
diff changeset
185 def musicHasFinished(self):
487
7f1c42b66aa4 Moved the shooter demo Timer() class to helpers.py.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 485
diff changeset
186 print self._music.name + " has finished playing. Starting it again...\n"
467
4d0aa75a82f1 Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 465
diff changeset
187
455
e686b82d93d0 Added the ability to pause the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 454
diff changeset
188 def pause(self, time):
e686b82d93d0 Added the ability to pause the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 454
diff changeset
189 self._pausedtime = time
e686b82d93d0 Added the ability to pause the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 454
diff changeset
190 self._paused = True
e686b82d93d0 Added the ability to pause the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 454
diff changeset
191
e686b82d93d0 Added the ability to pause the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 454
diff changeset
192 def unpause(self, time):
e686b82d93d0 Added the ability to pause the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 454
diff changeset
193 self._timemod += time - self._pausedtime
e686b82d93d0 Added the ability to pause the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 454
diff changeset
194 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
195
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 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
197 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
198
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
199 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
200 self._gameover = True
483
82d44c471959 Modified the SoundManager to not create unique FIFE sound emitters for each object. There is now only one FIFE emitter per unique sound.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 481
diff changeset
201 self._soundmanager.stopClip(self._music)
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
202 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
203
4d0aa75a82f1 Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 465
diff changeset
204 def endLevel(self):
483
82d44c471959 Modified the SoundManager to not create unique FIFE sound emitters for each object. There is now only one FIFE emitter per unique sound.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 481
diff changeset
205 self._soundmanager.stopClip(self._music)
467
4d0aa75a82f1 Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 465
diff changeset
206 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
207
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
208 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
209 self._objectstodelete.append(obj)
455
e686b82d93d0 Added the ability to pause the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 454
diff changeset
210
451
f463ab431cc0 Movement shouldn't be dependent on framerate anymore.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 450
diff changeset
211 def getObjectsInNode(self, nodeindex):
f463ab431cc0 Movement shouldn't be dependent on framerate anymore.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 450
diff changeset
212 return self._nodes[nodeindex].instances
448
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 def getObjectsInRange(self, rangeL, rangeR):
5e2ec84902a7 Did a little re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 447
diff changeset
215 objects = list()
5e2ec84902a7 Did a little re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 447
diff changeset
216
5e2ec84902a7 Did a little re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 447
diff changeset
217 for i in range(rangeL, rangeR):
5e2ec84902a7 Did a little re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 447
diff changeset
218 objects.extend(self._nodes[i].spaceobjects)
5e2ec84902a7 Did a little re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 447
diff changeset
219
5e2ec84902a7 Did a little re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 447
diff changeset
220 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
221
cf53848fb187 Scene now gets updated when an object moves from one node to another.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 452
diff changeset
222 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
223 #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
224 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
225 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
226
477
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
227 if nodeindex >= 0:
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
228 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
229 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
230 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
231 else:
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
232 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
233
cf53848fb187 Scene now gets updated when an object moves from one node to another.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 452
diff changeset
234 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
235 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
236 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
237
477
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
238 if nodeindex >= 0:
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
239 if nodeindex != obj.scenenodeid:
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
240 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
241 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
242
477
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
243 self._nodes[nodeindex].spaceobjects.append(obj)
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
244
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
245 obj.scenenodeid = nodeindex
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
246 else:
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
247 self.queueObjectForRemoval(obj)
471
7a79dc2a0592 Adding the credits window (still needs to be written)
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 470
diff changeset
248
450
ba6817013343 Added score keeping ability.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 449
diff changeset
249 def removeObjectFromScene(self, obj):
ba6817013343 Added score keeping ability.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 449
diff changeset
250 for node in self._nodes:
ba6817013343 Added score keeping ability.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 449
diff changeset
251 if obj in node.spaceobjects:
477
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
252 if obj.instance:
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
253 self._layer.deleteInstance(obj.instance)
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
254 obj.instance = None
450
ba6817013343 Added score keeping ability.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 449
diff changeset
255 node.spaceobjects.remove(obj)
477
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
256 break
448
5e2ec84902a7 Did a little re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 447
diff changeset
257
446
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
258 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
259 self._camera = cam
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
260 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
261
4d0aa75a82f1 Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 465
diff changeset
262 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
263 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
264
467
4d0aa75a82f1 Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 465
diff changeset
265 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
266 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
267
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
268 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
269 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
270 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
271
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
272 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
273
446
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
274 def update(self, time, keystate):
455
e686b82d93d0 Added the ability to pause the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 454
diff changeset
275 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
276 self._timedelta = timedelta
455
e686b82d93d0 Added the ability to pause the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 454
diff changeset
277 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
278
cf53848fb187 Scene now gets updated when an object moves from one node to another.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 452
diff changeset
279 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
280
477
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
281
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
282 #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
283 self.collectGarbage()
477
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
284
446
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
285 #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
286 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
287 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
288 #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
289 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
290 loc.setExactLayerCoordinates(exactloc)
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
291 self._camera.setLocation(loc)
448
5e2ec84902a7 Did a little re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 447
diff changeset
292
5e2ec84902a7 Did a little re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 447
diff changeset
293 topleft = self._camera.toMapCoordinates(fife.ScreenPoint(0,0))
5e2ec84902a7 Did a little re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 447
diff changeset
294 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
295
449
1cf56403347a Added object bounding boxes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 448
diff changeset
296 #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
297 leftnode = int(topleft.x)
450
ba6817013343 Added score keeping ability.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 449
diff changeset
298 rightnode = int(bottomright.x) + 1
448
5e2ec84902a7 Did a little re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 447
diff changeset
299
450
ba6817013343 Added score keeping ability.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 449
diff changeset
300 #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
301 if leftnode < 0:
5e2ec84902a7 Did a little re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 447
diff changeset
302 leftnode = 0
5e2ec84902a7 Did a little re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 447
diff changeset
303 if rightnode > self._maxnodes:
5e2ec84902a7 Did a little re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 447
diff changeset
304 rightnode = self._maxnodes
449
1cf56403347a Added object bounding boxes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 448
diff changeset
305 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
306
450
ba6817013343 Added score keeping ability.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 449
diff changeset
307 #update objects on the screen
ba6817013343 Added score keeping ability.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 449
diff changeset
308 for obj in screenlist:
477
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
309 if obj.type == SHTR_LASTBOSS:
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
310 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
311 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
312
477
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
313 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
314 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
315
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
316 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
317 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
318
477
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
319 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
320 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
321 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
322 #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
323 #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
324 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
325 #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
326 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
327 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
328 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
329 obj.applyPowerUp(self._player)
477
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
330
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
331 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
332
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
333 #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
334 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
335 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
336 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
337
477
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
338 #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
339 #use a range to be sure.
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
340 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
341
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
342 for o in pcollide:
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
343 #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
344 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
345 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
346 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
347 o.applyHit(obj.damage)
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
348 #check if enemy ship was destroyed
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
349 if not o.running:
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
350 self._player.applyScore(o.scorevalue)
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
351 obj.destroy()
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
352 elif o == self._player:
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
353 #player got hit by a projectile
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
354 if not self._player.invulnerable:
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
355 self.playerHit(obj.damage)
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
356 obj.destroy()
460
5e1d6e40d19d Fixed bounding boxes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 459
diff changeset
357
477
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
358 #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
359 if not obj.running:
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
360 self.queueObjectForRemoval(obj)
450
ba6817013343 Added score keeping ability.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 449
diff changeset
361
477
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
362 # self._world.renderBoundingBox(obj)
6b33d80b468b Projectiles are now part of the scene.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 476
diff changeset
363
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
364
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 _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
367 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
368
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
369 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
370 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
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 _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
373 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
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 _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
376 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
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 _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
379 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
380
cf53848fb187 Scene now gets updated when an object moves from one node to another.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 452
diff changeset
381 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
382 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
383
cf53848fb187 Scene now gets updated when an object moves from one node to another.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 452
diff changeset
384 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
385 return self._timedelta
455
e686b82d93d0 Added the ability to pause the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 454
diff changeset
386
e686b82d93d0 Added the ability to pause the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 454
diff changeset
387 def _getPaused(self):
e686b82d93d0 Added the ability to pause the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 454
diff changeset
388 return self._paused
483
82d44c471959 Modified the SoundManager to not create unique FIFE sound emitters for each object. There is now only one FIFE emitter per unique sound.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 481
diff changeset
389
82d44c471959 Modified the SoundManager to not create unique FIFE sound emitters for each object. There is now only one FIFE emitter per unique sound.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 481
diff changeset
390 def _getSoundManager(self):
82d44c471959 Modified the SoundManager to not create unique FIFE sound emitters for each object. There is now only one FIFE emitter per unique sound.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 481
diff changeset
391 return self._soundmanager
82d44c471959 Modified the SoundManager to not create unique FIFE sound emitters for each object. There is now only one FIFE emitter per unique sound.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 481
diff changeset
392
446
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
393 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
394 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
395 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
396 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
397 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
398 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
399 timedelta = property(_getTimeDelta)
483
82d44c471959 Modified the SoundManager to not create unique FIFE sound emitters for each object. There is now only one FIFE emitter per unique sound.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 481
diff changeset
400 paused = property(_getPaused)
82d44c471959 Modified the SoundManager to not create unique FIFE sound emitters for each object. There is now only one FIFE emitter per unique sound.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 481
diff changeset
401 soundmanager = property(_getSoundManager)