annotate demos/shooter/scripts/world.py @ 673:32539411bf0d

fixed a minor bug in the editor when trying to switch to INSERTING mode using the keyboard shortcut.
author vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
date Tue, 09 Nov 2010 12:31:40 +0000
parents e3140f01749d
children
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 # ####################################################################
491
c4168eb47a44 Adding some comments to the shooter demo. Updated the copyright date and FIFE URL as well.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 490
diff changeset
4 # Copyright (C) 2005-2010 by the FIFE team
c4168eb47a44 Adding some comments to the shooter demo. Updated the copyright date and FIFE URL as well.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 490
diff changeset
5 # http://www.fifengine.net
446
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
460
5e1d6e40d19d Fixed bounding boxes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 457
diff changeset
25 import copy
446
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
26 import math, random
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
27 from fife.extensions import pychan
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
28 from fife.extensions.pychan import widgets
492
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 491
diff changeset
29 from fife.extensions.soundmanager import SoundManager
446
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
30
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
31 from scripts.common.eventlistenerbase import EventListenerBase
661
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 527
diff changeset
32 from fife.extensions.loaders import loadMapFile
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 527
diff changeset
33 from fife.extensions.serializers.xml_loader_tools import loadImportFile
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 527
diff changeset
34 from fife.extensions.serializers.xmlobject import XMLObjectLoader
446
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
35
456
41fd97da94d1 Moved guis to their own file.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 455
diff changeset
36 from scripts.gui.guis import *
41fd97da94d1 Moved guis to their own file.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 455
diff changeset
37
446
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
38 from scripts.ships.shipbase import Ship
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
39 from scripts.ships.player import Player
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
40 from scripts.scene import Scene
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
41
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
42 class World(EventListenerBase):
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
43 """
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
44 The world!
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
45
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
46 This class handles:
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
47 setup of map view (cameras ...)
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
48 loading the map
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
49 handles mouse/key events which aren't handled by the GUI.
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
50 ( by inheriting from EventlistenerBase )
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
51
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
52 """
496
987307d12235 Added the fife_settings.py extension. This provides a small utility class for loading and saving settings along with a dialog box for setting screen resolution and other things.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
53 def __init__(self, app, engine, setting):
490
939a4dc12ca1 Starting to add some comments.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 480
diff changeset
54 super(World, self).__init__(engine, regKeys=True)
939a4dc12ca1 Starting to add some comments.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 480
diff changeset
55
455
e686b82d93d0 Added the ability to pause the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 454
diff changeset
56 self._applictaion = app
472
3164715a0621 Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 471
diff changeset
57 self._engine = engine
496
987307d12235 Added the fife_settings.py extension. This provides a small utility class for loading and saving settings along with a dialog box for setting screen resolution and other things.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
58 self._setting = setting
472
3164715a0621 Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 471
diff changeset
59 self._timemanager = engine.getTimeManager()
3164715a0621 Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 471
diff changeset
60 self._eventmanager = engine.getEventManager()
3164715a0621 Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 471
diff changeset
61 self._model = engine.getModel()
661
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 527
diff changeset
62 self.obj_loader = XMLObjectLoader(
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 527
diff changeset
63 engine.getImagePool(),
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 527
diff changeset
64 engine.getAnimationPool(),
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 527
diff changeset
65 engine.getModel(),
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 527
diff changeset
66 engine.getVFS()
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 527
diff changeset
67 )
472
3164715a0621 Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 471
diff changeset
68 self._filename = ''
495
ae9f5383f5b1 Added a new log module called Script. This should be used by the python modules.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 494
diff changeset
69 self._keystate = { 'UP': False,
ae9f5383f5b1 Added a new log module called Script. This should be used by the python modules.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 494
diff changeset
70 'DOWN': False,
ae9f5383f5b1 Added a new log module called Script. This should be used by the python modules.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 494
diff changeset
71 'LEFT': False,
ae9f5383f5b1 Added a new log module called Script. This should be used by the python modules.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 494
diff changeset
72 'RIGHT': False,
ae9f5383f5b1 Added a new log module called Script. This should be used by the python modules.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 494
diff changeset
73 'CTRL': False,
ae9f5383f5b1 Added a new log module called Script. This should be used by the python modules.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 494
diff changeset
74 'SPACE': False, }
472
3164715a0621 Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 471
diff changeset
75 self._pump_ctr = 0
3164715a0621 Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 471
diff changeset
76 self._map = None
3164715a0621 Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 471
diff changeset
77 self._scene = None
455
e686b82d93d0 Added the ability to pause the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 454
diff changeset
78 self._paused = True
e686b82d93d0 Added the ability to pause the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 454
diff changeset
79 self._pausedtime = 0
e686b82d93d0 Added the ability to pause the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 454
diff changeset
80 self._starttime = 0
e686b82d93d0 Added the ability to pause the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 454
diff changeset
81
480
85fa5fa486a8 Added a simple sound manager.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 475
diff changeset
82 self._soundmanager = SoundManager(self._engine)
85fa5fa486a8 Added a simple sound manager.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 475
diff changeset
83
496
987307d12235 Added the fife_settings.py extension. This provides a small utility class for loading and saving settings along with a dialog box for setting screen resolution and other things.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
84 self._mainmenu = MainMenu(self, self._setting)
455
e686b82d93d0 Added the ability to pause the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 454
diff changeset
85 self.showMainMenu()
e686b82d93d0 Added the ability to pause the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 454
diff changeset
86
456
41fd97da94d1 Moved guis to their own file.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 455
diff changeset
87 self._hudwindow = HeadsUpDisplay(self)
41fd97da94d1 Moved guis to their own file.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 455
diff changeset
88 self._hudwindow.hide()
446
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
89
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: 456
diff changeset
90 self._gameover = GameOverDisplay()
460
5e1d6e40d19d Fixed bounding boxes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 457
diff changeset
91 self._gameover.hide()
5e1d6e40d19d Fixed bounding boxes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 457
diff changeset
92
464
be035dff788a Added high score window.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 462
diff changeset
93 self._highscores = HighScores(self)
be035dff788a Added high score window.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 462
diff changeset
94 self._highscores.hide()
be035dff788a Added high score window.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 462
diff changeset
95
469
5994e61cdebd Added a widget to be displayed after the player completes the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 468
diff changeset
96 self._winner = WinnerDisplay()
5994e61cdebd Added a widget to be displayed after the player completes the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 468
diff changeset
97 self._winner.hide()
5994e61cdebd Added a widget to be displayed after the player completes the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 468
diff changeset
98
471
7a79dc2a0592 Adding the credits window (still needs to be written)
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 469
diff changeset
99 self._credits = CreditsDisplay(self)
7a79dc2a0592 Adding the credits window (still needs to be written)
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 469
diff changeset
100 self._credits.hide()
7a79dc2a0592 Adding the credits window (still needs to be written)
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 469
diff changeset
101
460
5e1d6e40d19d Fixed bounding boxes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 457
diff changeset
102 self._genericrenderer = None
5e1d6e40d19d Fixed bounding boxes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 457
diff changeset
103
469
5994e61cdebd Added a widget to be displayed after the player completes the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 468
diff changeset
104 self._gamecomplete = 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
105
455
e686b82d93d0 Added the ability to pause the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 454
diff changeset
106 def showMainMenu(self):
472
3164715a0621 Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 471
diff changeset
107 if self._scene:
455
e686b82d93d0 Added the ability to pause the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 454
diff changeset
108 self._paused = True
e686b82d93d0 Added the ability to pause the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 454
diff changeset
109 cont = True
e686b82d93d0 Added the ability to pause the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 454
diff changeset
110 else:
e686b82d93d0 Added the ability to pause the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 454
diff changeset
111 cont = False
e686b82d93d0 Added the ability to pause the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 454
diff changeset
112
e686b82d93d0 Added the ability to pause the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 454
diff changeset
113 self._mainmenu.show(cont)
e686b82d93d0 Added the ability to pause the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 454
diff changeset
114
e686b82d93d0 Added the ability to pause the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 454
diff changeset
115 def showCredits(self):
471
7a79dc2a0592 Adding the credits window (still needs to be written)
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 469
diff changeset
116 self._credits.show()
455
e686b82d93d0 Added the ability to pause the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 454
diff changeset
117
e686b82d93d0 Added the ability to pause the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 454
diff changeset
118 def showHighScores(self):
464
be035dff788a Added high score window.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 462
diff changeset
119 self._highscores.show()
455
e686b82d93d0 Added the ability to pause the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 454
diff changeset
120
e686b82d93d0 Added the ability to pause the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 454
diff changeset
121 def quit(self):
e686b82d93d0 Added the ability to pause the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 454
diff changeset
122 self.reset()
480
85fa5fa486a8 Added a simple sound manager.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 475
diff changeset
123 self._soundmanager.destroy()
455
e686b82d93d0 Added the ability to pause the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 454
diff changeset
124 self._applictaion.requestQuit()
e686b82d93d0 Added the ability to pause the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 454
diff changeset
125
446
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
126 def reset(self):
472
3164715a0621 Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 471
diff changeset
127 if self._map:
3164715a0621 Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 471
diff changeset
128 self._model.deleteMap(self._map)
3164715a0621 Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 471
diff changeset
129 self._map = None
455
e686b82d93d0 Added the ability to pause the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 454
diff changeset
130
e686b82d93d0 Added the ability to pause the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 454
diff changeset
131 self.cameras = {}
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
472
3164715a0621 Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 471
diff changeset
133 if self._scene:
3164715a0621 Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 471
diff changeset
134 self._scene.destroyScene()
3164715a0621 Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 471
diff changeset
135 self._scene = 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
136
469
5994e61cdebd Added a widget to be displayed after the player completes the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 468
diff changeset
137 self._gamecomplete = False
455
e686b82d93d0 Added the ability to pause the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 454
diff changeset
138
e686b82d93d0 Added the ability to pause the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 454
diff changeset
139 def loadLevel(self, filename):
446
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
140 """
455
e686b82d93d0 Added the ability to pause the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 454
diff changeset
141 Load a xml map and setup cameras.
446
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
142 """
469
5994e61cdebd Added a widget to be displayed after the player completes the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 468
diff changeset
143
5994e61cdebd Added a widget to be displayed after the player completes the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 468
diff changeset
144 self.resetKeys()
5994e61cdebd Added a widget to be displayed after the player completes the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 468
diff changeset
145
472
3164715a0621 Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 471
diff changeset
146 self._filename = filename
446
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
147 self.reset()
502
96c4922c1c24 Added some imports to the world initialization code. I had to do this because you were not able to use the editor with the shooter demo map files without manually adding the imports to the map file. You do not have to do this now (note the TODO in the comments). I have also hard coded the camera zoom level to ensure the map editors zoom level at the time of saving the map is not used.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 496
diff changeset
148
96c4922c1c24 Added some imports to the world initialization code. I had to do this because you were not able to use the editor with the shooter demo map files without manually adding the imports to the map file. You do not have to do this now (note the TODO in the comments). I have also hard coded the camera zoom level to ensure the map editors zoom level at the time of saving the map is not used.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 496
diff changeset
149 #specific imports that needed to be added
96c4922c1c24 Added some imports to the world initialization code. I had to do this because you were not able to use the editor with the shooter demo map files without manually adding the imports to the map file. You do not have to do this now (note the TODO in the comments). I have also hard coded the camera zoom level to ensure the map editors zoom level at the time of saving the map is not used.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 496
diff changeset
150 #@todo: you should be able to add file imports via the map editor
661
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 527
diff changeset
151 loadImportFile(self.obj_loader, "objects/projectiles/bullet1/object.xml", self._engine)
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 527
diff changeset
152 loadImportFile(self.obj_loader,"objects/projectiles/fireball/object.xml", self._engine)
502
96c4922c1c24 Added some imports to the world initialization code. I had to do this because you were not able to use the editor with the shooter demo map files without manually adding the imports to the map file. You do not have to do this now (note the TODO in the comments). I have also hard coded the camera zoom level to ensure the map editors zoom level at the time of saving the map is not used.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 496
diff changeset
153
472
3164715a0621 Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 471
diff changeset
154 self._map = loadMapFile(self._filename, self._engine)
446
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
155
480
85fa5fa486a8 Added a simple sound manager.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 475
diff changeset
156 self._scene = Scene(self, self._engine, self._map.getLayer('objects'), self._soundmanager)
472
3164715a0621 Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 471
diff changeset
157 self._scene.initScene(self._map)
456
41fd97da94d1 Moved guis to their own file.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 455
diff changeset
158
454
bd7e8f708adf Time is now managed by the Scene object.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 453
diff changeset
159 self.initCameras()
455
e686b82d93d0 Added the ability to pause the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 454
diff changeset
160
e686b82d93d0 Added the ability to pause the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 454
diff changeset
161 self._hudwindow.show()
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: 456
diff changeset
162 self._gameover.hide()
469
5994e61cdebd Added a widget to be displayed after the player completes the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 468
diff changeset
163 self._winner.hide()
455
e686b82d93d0 Added the ability to pause the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 454
diff changeset
164
472
3164715a0621 Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 471
diff changeset
165 self._starttime = self._timemanager.getTime()
460
5e1d6e40d19d Fixed bounding boxes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 457
diff changeset
166
5e1d6e40d19d Fixed bounding boxes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 457
diff changeset
167 self._genericrenderer = fife.GenericRenderer.getInstance(self.cameras['main'])
5e1d6e40d19d Fixed bounding boxes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 457
diff changeset
168 self._genericrenderer.clearActiveLayers()
495
ae9f5383f5b1 Added a new log module called Script. This should be used by the python modules.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 494
diff changeset
169 self._genericrenderer.addActiveLayer(self._map.getLayer('boundingbox'))
460
5e1d6e40d19d Fixed bounding boxes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 457
diff changeset
170 self._genericrenderer.setEnabled(True)
5e1d6e40d19d Fixed bounding boxes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 457
diff changeset
171
5e1d6e40d19d Fixed bounding boxes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 457
diff changeset
172
5e1d6e40d19d Fixed bounding boxes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 457
diff changeset
173 def renderBoundingBox(self, obj):
494
e241d7553496 Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 492
diff changeset
174 """
e241d7553496 Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 492
diff changeset
175 Just a hack to render an objects bounding box.
e241d7553496 Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 492
diff changeset
176 """
e241d7553496 Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 492
diff changeset
177
460
5e1d6e40d19d Fixed bounding boxes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 457
diff changeset
178 bbox = copy.copy(obj.boundingbox)
5e1d6e40d19d Fixed bounding boxes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 457
diff changeset
179
5e1d6e40d19d Fixed bounding boxes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 457
diff changeset
180 #apply the object layer scale
5e1d6e40d19d Fixed bounding boxes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 457
diff changeset
181 bbox.x /= 0.25
5e1d6e40d19d Fixed bounding boxes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 457
diff changeset
182 bbox.y /= 0.25
5e1d6e40d19d Fixed bounding boxes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 457
diff changeset
183 bbox.w /= 0.25
5e1d6e40d19d Fixed bounding boxes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 457
diff changeset
184 bbox.h /= 0.25
5e1d6e40d19d Fixed bounding boxes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 457
diff changeset
185
5e1d6e40d19d Fixed bounding boxes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 457
diff changeset
186 obj_topleft = fife.ExactModelCoordinate(bbox.x, bbox.y)
5e1d6e40d19d Fixed bounding boxes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 457
diff changeset
187 obj_topright = fife.ExactModelCoordinate(bbox.x + bbox.w, bbox.y)
5e1d6e40d19d Fixed bounding boxes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 457
diff changeset
188 obj_bottomright = fife.ExactModelCoordinate(bbox.x + bbox.w, bbox.y + bbox.h)
5e1d6e40d19d Fixed bounding boxes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 457
diff changeset
189 obj_bottomleft = fife.ExactModelCoordinate(bbox.x, bbox.y + bbox.h)
5e1d6e40d19d Fixed bounding boxes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 457
diff changeset
190
5e1d6e40d19d Fixed bounding boxes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 457
diff changeset
191 loc_topleft = fife.Location()
472
3164715a0621 Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 471
diff changeset
192 loc_topleft.setLayer(self._map.getLayer('boundingbox'))
460
5e1d6e40d19d Fixed bounding boxes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 457
diff changeset
193 loc_topleft.setExactLayerCoordinates(obj_topleft)
5e1d6e40d19d Fixed bounding boxes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 457
diff changeset
194
5e1d6e40d19d Fixed bounding boxes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 457
diff changeset
195 loc_topright = fife.Location()
472
3164715a0621 Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 471
diff changeset
196 loc_topright.setLayer(self._map.getLayer('boundingbox'))
460
5e1d6e40d19d Fixed bounding boxes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 457
diff changeset
197 loc_topright.setExactLayerCoordinates(obj_topright)
5e1d6e40d19d Fixed bounding boxes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 457
diff changeset
198
5e1d6e40d19d Fixed bounding boxes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 457
diff changeset
199 loc_bottomright = fife.Location()
472
3164715a0621 Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 471
diff changeset
200 loc_bottomright.setLayer(self._map.getLayer('boundingbox'))
460
5e1d6e40d19d Fixed bounding boxes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 457
diff changeset
201 loc_bottomright.setExactLayerCoordinates(obj_bottomright)
5e1d6e40d19d Fixed bounding boxes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 457
diff changeset
202
5e1d6e40d19d Fixed bounding boxes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 457
diff changeset
203 loc_bottomleft = fife.Location()
472
3164715a0621 Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 471
diff changeset
204 loc_bottomleft.setLayer(self._map.getLayer('boundingbox'))
460
5e1d6e40d19d Fixed bounding boxes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 457
diff changeset
205 loc_bottomleft.setExactLayerCoordinates(obj_bottomleft)
5e1d6e40d19d Fixed bounding boxes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 457
diff changeset
206
5e1d6e40d19d Fixed bounding boxes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 457
diff changeset
207 node_topleft = fife.GenericRendererNode(loc_topleft)
5e1d6e40d19d Fixed bounding boxes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 457
diff changeset
208 node_topright = fife.GenericRendererNode(loc_topright)
5e1d6e40d19d Fixed bounding boxes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 457
diff changeset
209 node_bottomright = fife.GenericRendererNode(loc_bottomright)
5e1d6e40d19d Fixed bounding boxes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 457
diff changeset
210 node_bottomleft = fife.GenericRendererNode(loc_bottomleft)
5e1d6e40d19d Fixed bounding boxes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 457
diff changeset
211
5e1d6e40d19d Fixed bounding boxes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 457
diff changeset
212
5e1d6e40d19d Fixed bounding boxes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 457
diff changeset
213 self._genericrenderer.addLine("quads", node_topleft, node_topright, 255, 255, 255)
5e1d6e40d19d Fixed bounding boxes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 457
diff changeset
214 self._genericrenderer.addLine("quads", node_topright, node_bottomright, 255, 255, 255)
5e1d6e40d19d Fixed bounding boxes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 457
diff changeset
215 self._genericrenderer.addLine("quads", node_bottomright, node_bottomleft, 255, 255, 255)
5e1d6e40d19d Fixed bounding boxes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 457
diff changeset
216 self._genericrenderer.addLine("quads", node_bottomleft, node_topleft, 255, 255, 255)
5e1d6e40d19d Fixed bounding boxes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 457
diff changeset
217
5e1d6e40d19d Fixed bounding boxes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 457
diff changeset
218 #had to do this or it would segfault
5e1d6e40d19d Fixed bounding boxes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 457
diff changeset
219 obj_topleft.thisown = 0
5e1d6e40d19d Fixed bounding boxes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 457
diff changeset
220 obj_topright.thisown = 0
5e1d6e40d19d Fixed bounding boxes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 457
diff changeset
221 obj_bottomright.thisown = 0
5e1d6e40d19d Fixed bounding boxes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 457
diff changeset
222 obj_bottomleft.thisown = 0
5e1d6e40d19d Fixed bounding boxes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 457
diff changeset
223 loc_topleft.thisown = 0
5e1d6e40d19d Fixed bounding boxes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 457
diff changeset
224 loc_topright.thisown = 0
5e1d6e40d19d Fixed bounding boxes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 457
diff changeset
225 loc_bottomright.thisown = 0
5e1d6e40d19d Fixed bounding boxes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 457
diff changeset
226 loc_bottomleft.thisown = 0
5e1d6e40d19d Fixed bounding boxes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 457
diff changeset
227 node_topleft.thisown = 0
5e1d6e40d19d Fixed bounding boxes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 457
diff changeset
228 node_topright.thisown = 0
5e1d6e40d19d Fixed bounding boxes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 457
diff changeset
229 node_bottomright.thisown = 0
5e1d6e40d19d Fixed bounding boxes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 457
diff changeset
230 node_bottomleft.thisown = 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: 456
diff changeset
231
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: 456
diff changeset
232 def gameOver(self):
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: 456
diff changeset
233 self._gameover.show()
469
5994e61cdebd Added a widget to be displayed after the player completes the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 468
diff changeset
234 self._hudwindow.hide()
464
be035dff788a Added high score window.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 462
diff changeset
235
475
afde89c1d50b Switched to a damage system. Collisions with objects now cause 1 damage to the player.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 472
diff changeset
236 self._gamecomplete = True
467
4d0aa75a82f1 Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 465
diff changeset
237
4d0aa75a82f1 Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 465
diff changeset
238 def endLevel(self):
4d0aa75a82f1 Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 465
diff changeset
239 self._paused = True
469
5994e61cdebd Added a widget to be displayed after the player completes the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 468
diff changeset
240
5994e61cdebd Added a widget to be displayed after the player completes the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 468
diff changeset
241 #only one level so the game is over once you complete it.
5994e61cdebd Added a widget to be displayed after the player completes the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 468
diff changeset
242 self._gamecomplete = True
5994e61cdebd Added a widget to be displayed after the player completes the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 468
diff changeset
243 self._winner.show()
5994e61cdebd Added a widget to be displayed after the player completes the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 468
diff changeset
244 self._hudwindow.hide()
467
4d0aa75a82f1 Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 465
diff changeset
245
469
5994e61cdebd Added a widget to be displayed after the player completes the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 468
diff changeset
246 def saveScore(self):
5994e61cdebd Added a widget to be displayed after the player completes the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 468
diff changeset
247 self._gamecomplete = False
468
ebbb420a90b9 Fix the bug where the high score dialog box causes a crash after the player completes the level.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 467
diff changeset
248
472
3164715a0621 Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 471
diff changeset
249 if self._highscores.isHighScore(self._scene.player.score):
3164715a0621 Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 471
diff changeset
250 score = self._scene.player.score
464
be035dff788a Added high score window.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 462
diff changeset
251
467
4d0aa75a82f1 Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 465
diff changeset
252 dlg = pychan.loadXML('gui/highscoredialog.xml')
4d0aa75a82f1 Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 465
diff changeset
253 dlg.execute({ 'okay' : "Yay!" })
4d0aa75a82f1 Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 465
diff changeset
254 name = dlg.findChild(name='name').text
4d0aa75a82f1 Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 465
diff changeset
255
468
ebbb420a90b9 Fix the bug where the high score dialog box causes a crash after the player completes the level.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 467
diff changeset
256 self._highscores.addHighScore(HighScore(name, score))
ebbb420a90b9 Fix the bug where the high score dialog box causes a crash after the player completes the level.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 467
diff changeset
257 self._highscores.show()
ebbb420a90b9 Fix the bug where the high score dialog box causes a crash after the player completes the level.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 467
diff changeset
258
464
be035dff788a Added high score window.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 462
diff changeset
259
455
e686b82d93d0 Added the ability to pause the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 454
diff changeset
260 def newGame(self):
e686b82d93d0 Added the ability to pause the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 454
diff changeset
261 self.loadLevel("maps/shooter_map1.xml")
e686b82d93d0 Added the ability to pause the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 454
diff changeset
262 self._mainmenu.hide()
e686b82d93d0 Added the ability to pause the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 454
diff changeset
263 self._paused = False
e686b82d93d0 Added the ability to pause the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 454
diff changeset
264
e686b82d93d0 Added the ability to pause the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 454
diff changeset
265 def continueGame(self):
e686b82d93d0 Added the ability to pause the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 454
diff changeset
266 self._mainmenu.hide()
e686b82d93d0 Added the ability to pause the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 454
diff changeset
267 self._paused = False
446
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
268
495
ae9f5383f5b1 Added a new log module called Script. This should be used by the python modules.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 494
diff changeset
269 def pauseGame(self):
ae9f5383f5b1 Added a new log module called Script. This should be used by the python modules.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 494
diff changeset
270 self._paused = True
ae9f5383f5b1 Added a new log module called Script. This should be used by the python modules.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 494
diff changeset
271 self._mainmenu.show(True)
ae9f5383f5b1 Added a new log module called Script. This should be used by the python modules.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 494
diff changeset
272
446
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
273 def initCameras(self):
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
274 """
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
275 Before we can actually see something on screen we have to specify the render setup.
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
276 This is done through Camera objects which offer a viewport on the map.
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
277 """
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
278
472
3164715a0621 Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 471
diff changeset
279 for cam in self._map.getCameras():
446
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
280 if cam.getId() == 'main':
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
281 self.cameras['main'] = cam
490
939a4dc12ca1 Starting to add some comments.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 480
diff changeset
282
939a4dc12ca1 Starting to add some comments.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 480
diff changeset
283 #pass the camera to the scene as the scene controls the cameras position
472
3164715a0621 Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 471
diff changeset
284 self._scene.attachCamera(self.cameras['main'])
502
96c4922c1c24 Added some imports to the world initialization code. I had to do this because you were not able to use the editor with the shooter demo map files without manually adding the imports to the map file. You do not have to do this now (note the TODO in the comments). I have also hard coded the camera zoom level to ensure the map editors zoom level at the time of saving the map is not used.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 496
diff changeset
285 self.cameras['main'].setZoom(1.0)
446
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
286
469
5994e61cdebd Added a widget to be displayed after the player completes the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 468
diff changeset
287 def resetKeys(self):
472
3164715a0621 Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 471
diff changeset
288 self._keystate['UP'] = False
3164715a0621 Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 471
diff changeset
289 self._keystate['DOWN'] = False
3164715a0621 Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 471
diff changeset
290 self._keystate['LEFT'] = False
3164715a0621 Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 471
diff changeset
291 self._keystate['RIGHT'] = False
3164715a0621 Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 471
diff changeset
292 self._keystate['SPACE'] = False
3164715a0621 Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 471
diff changeset
293 self._keystate['CTRL'] = False
469
5994e61cdebd Added a widget to be displayed after the player completes the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 468
diff changeset
294
446
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
295
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
296 def keyPressed(self, evt):
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
297 keyval = evt.getKey().getValue()
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
298 keystr = evt.getKey().getAsString().lower()
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
299 if keyval == fife.Key.UP:
472
3164715a0621 Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 471
diff changeset
300 self._keystate['UP'] = True
446
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
301 elif keyval == fife.Key.DOWN:
472
3164715a0621 Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 471
diff changeset
302 self._keystate['DOWN'] = True
446
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
303 elif keyval == fife.Key.LEFT:
472
3164715a0621 Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 471
diff changeset
304 self._keystate['LEFT'] = True
446
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
305 elif keyval == fife.Key.RIGHT:
472
3164715a0621 Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 471
diff changeset
306 self._keystate['RIGHT'] = True
446
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
307 elif keyval == fife.Key.SPACE:
472
3164715a0621 Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 471
diff changeset
308 self._keystate['SPACE'] = True
455
e686b82d93d0 Added the ability to pause the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 454
diff changeset
309 elif keyval == fife.Key.P:
e686b82d93d0 Added the ability to pause the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 454
diff changeset
310 self._paused = not self._paused
472
3164715a0621 Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 471
diff changeset
311 self._pausedtime += self._timemanager.getTime()
446
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
312 elif keyval in (fife.Key.LEFT_CONTROL, fife.Key.RIGHT_CONTROL):
472
3164715a0621 Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 471
diff changeset
313 self._keystate['CTRL'] = True
446
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
314
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
315 def keyReleased(self, evt):
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
316 keyval = evt.getKey().getValue()
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
317 if keyval == fife.Key.UP:
472
3164715a0621 Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 471
diff changeset
318 self._keystate['UP'] = False
446
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
319 elif keyval == fife.Key.DOWN:
472
3164715a0621 Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 471
diff changeset
320 self._keystate['DOWN'] = False
446
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
321 elif keyval == fife.Key.LEFT:
472
3164715a0621 Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 471
diff changeset
322 self._keystate['LEFT'] = False
446
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
323 elif keyval == fife.Key.RIGHT:
472
3164715a0621 Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 471
diff changeset
324 self._keystate['RIGHT'] = False
446
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
325 elif keyval == fife.Key.SPACE:
472
3164715a0621 Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 471
diff changeset
326 self._keystate['SPACE'] = False
446
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
327 elif keyval in (fife.Key.LEFT_CONTROL, fife.Key.RIGHT_CONTROL):
472
3164715a0621 Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 471
diff changeset
328 self._keystate['CTRL'] = False
446
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
329
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
330 def pump(self):
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
331 """
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
332 Called every frame.
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
333 """
460
5e1d6e40d19d Fixed bounding boxes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 457
diff changeset
334
5e1d6e40d19d Fixed bounding boxes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 457
diff changeset
335 if self._genericrenderer:
5e1d6e40d19d Fixed bounding boxes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 457
diff changeset
336 self._genericrenderer.removeAll("quads")
5e1d6e40d19d Fixed bounding boxes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 457
diff changeset
337
490
939a4dc12ca1 Starting to add some comments.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 480
diff changeset
338 #scene hasn't been initialized. Nothing to do.
472
3164715a0621 Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 471
diff changeset
339 if not self._scene:
455
e686b82d93d0 Added the ability to pause the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 454
diff changeset
340 return
e686b82d93d0 Added the ability to pause the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 454
diff changeset
341
446
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
342 #update the scene
475
afde89c1d50b Switched to a damage system. Collisions with objects now cause 1 damage to the player.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 472
diff changeset
343 if not self._paused and not self._gamecomplete:
472
3164715a0621 Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 471
diff changeset
344 if self._scene.paused:
3164715a0621 Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 471
diff changeset
345 self._scene.unpause(self._timemanager.getTime() - self._starttime)
455
e686b82d93d0 Added the ability to pause the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 454
diff changeset
346
472
3164715a0621 Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 471
diff changeset
347 self._scene.update(self._timemanager.getTime() - self._starttime, self._keystate)
446
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
348
455
e686b82d93d0 Added the ability to pause the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 454
diff changeset
349 #update the HUD
472
3164715a0621 Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 471
diff changeset
350 avgframe = self._timemanager.getAverageFrameTime()
455
e686b82d93d0 Added the ability to pause the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 454
diff changeset
351 if avgframe > 0:
e686b82d93d0 Added the ability to pause the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 454
diff changeset
352 fps = 1 / (avgframe / 1000)
e686b82d93d0 Added the ability to pause the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 454
diff changeset
353 else:
e686b82d93d0 Added the ability to pause the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 454
diff changeset
354 fps = 0
e686b82d93d0 Added the ability to pause the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 454
diff changeset
355 fpstxt = "%3.2f" % fps
456
41fd97da94d1 Moved guis to their own file.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 455
diff changeset
356 self._hudwindow.setFPSText(unicode(fpstxt))
446
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
357
472
3164715a0621 Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 471
diff changeset
358 player = self._scene.player
455
e686b82d93d0 Added the ability to pause the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 454
diff changeset
359 exactcoords = player.location.getExactLayerCoordinates()
e686b82d93d0 Added the ability to pause the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 454
diff changeset
360 pos = "%1.2f" % exactcoords.x + ", %1.2f" % exactcoords.y
456
41fd97da94d1 Moved guis to their own file.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 455
diff changeset
361 self._hudwindow.setPositionText(unicode(pos))
446
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
362
455
e686b82d93d0 Added the ability to pause the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 454
diff changeset
363 vel = "%1.2f" % player.velocity.x + ", %1.2f" % player.velocity.y
456
41fd97da94d1 Moved guis to their own file.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 455
diff changeset
364 self._hudwindow.setVelocityText(unicode(vel))
446
2046a1f2f5f2 Adding the shooter demo. This is still a work in progress.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
365
455
e686b82d93d0 Added the ability to pause the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 454
diff changeset
366 score = unicode(str(player.score))
456
41fd97da94d1 Moved guis to their own file.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 455
diff changeset
367 self._hudwindow.setScoreText(score)
455
e686b82d93d0 Added the ability to pause the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 454
diff changeset
368
462
c4f745a566d6 Added player ship animations including flash and explode.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 460
diff changeset
369 ilives = player.lives
c4f745a566d6 Added player ship animations including flash and explode.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 460
diff changeset
370 if ilives < 0:
c4f745a566d6 Added player ship animations including flash and explode.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 460
diff changeset
371 ilives = 0
c4f745a566d6 Added player ship animations including flash and explode.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 460
diff changeset
372 lives = unicode(str(ilives))
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: 456
diff changeset
373 self._hudwindow.setLivesText(lives)
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: 456
diff changeset
374
455
e686b82d93d0 Added the ability to pause the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 454
diff changeset
375 else:
472
3164715a0621 Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 471
diff changeset
376 if not self._scene.paused:
3164715a0621 Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 471
diff changeset
377 self._scene.pause(self._timemanager.getTime() - self._starttime)
475
afde89c1d50b Switched to a damage system. Collisions with objects now cause 1 damage to the player.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 472
diff changeset
378
afde89c1d50b Switched to a damage system. Collisions with objects now cause 1 damage to the player.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 472
diff changeset
379 if self._gamecomplete:
afde89c1d50b Switched to a damage system. Collisions with objects now cause 1 damage to the player.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 472
diff changeset
380 self.saveScore()
afde89c1d50b Switched to a damage system. Collisions with objects now cause 1 damage to the player.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 472
diff changeset
381 self.reset()
467
4d0aa75a82f1 Added damage so some enemies take more than one hit to destroy.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 465
diff changeset
382
472
3164715a0621 Added the FireBallBurst and FireBallSpread weapons which are now used by the boss.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 471
diff changeset
383 self._pump_ctr += 1