Mercurial > fife-parpg
annotate demos/rpg/scripts/rpg.py @ 656:99e3ef63495b
* The RPG and Shooter demos now clear the screen when in OpenGL mode
* Small update to the soundmanager to stop the stack overflow problem.
author | prock@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Fri, 22 Oct 2010 16:01:57 +0000 |
parents | 90d369c788c0 |
children | 46258f467c8c |
rev | line source |
---|---|
509
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
1 #!/usr/bin/env python |
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
2 |
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
3 # -*- coding: utf-8 -*- |
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
4 |
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
5 # #################################################################### |
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
6 # Copyright (C) 2005-2010 by the FIFE team |
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
7 # http://www.fifengine.net |
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
8 # This file is part of FIFE. |
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
9 # |
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
10 # FIFE is free software; you can redistribute it and/or |
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
11 # modify it under the terms of the GNU Lesser General Public |
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
12 # License as published by the Free Software Foundation; either |
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
13 # version 2.1 of the License, or (at your option) any later version. |
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
14 # |
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
15 # This library is distributed in the hope that it will be useful, |
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
18 # Lesser General Public License for more details. |
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
19 # |
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
20 # You should have received a copy of the GNU Lesser General Public |
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
21 # License along with this library; if not, write to the |
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
22 # Free Software Foundation, Inc., |
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
23 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
24 # #################################################################### |
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
25 |
512
6ddb1eb9dfa6
Added the Scene which loads the town map. It is no longer a black screen demo.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
510
diff
changeset
|
26 import sys, os, re, math, random, shutil, time |
6ddb1eb9dfa6
Added the Scene which loads the town map. It is no longer a black screen demo.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
510
diff
changeset
|
27 from datetime import datetime |
509
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
28 |
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
29 from fife import fife |
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
30 from fife.extensions import * |
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
31 from scripts.gamecontroller import GameController |
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
32 from fife.extensions.basicapplication import ApplicationBase |
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
33 from fife.extensions import pychan |
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
34 from fife.extensions.pychan import widgets |
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
35 from fife.extensions.fife_utils import getUserDataDirectory |
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
36 |
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
37 class KeyFilter(fife.IKeyFilter): |
550
d0282579668c
Added QuestManager. The player can now move from map to map and the state of the quests remains persistent. Both quests the NPC gives you are now completable. Still have to clean up the quest loading code.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
38 """ |
d0282579668c
Added QuestManager. The player can now move from map to map and the state of the quests remains persistent. Both quests the NPC gives you are now completable. Still have to clean up the quest loading code.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
39 This is the implementation of the fife.IKeyFilter class. |
d0282579668c
Added QuestManager. The player can now move from map to map and the state of the quests remains persistent. Both quests the NPC gives you are now completable. Still have to clean up the quest loading code.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
40 |
d0282579668c
Added QuestManager. The player can now move from map to map and the state of the quests remains persistent. Both quests the NPC gives you are now completable. Still have to clean up the quest loading code.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
41 Prevents any filtered keys from being consumed by guichan. |
d0282579668c
Added QuestManager. The player can now move from map to map and the state of the quests remains persistent. Both quests the NPC gives you are now completable. Still have to clean up the quest loading code.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
42 """ |
509
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
43 def __init__(self, keys): |
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
44 fife.IKeyFilter.__init__(self) |
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
45 self._keys = keys |
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
46 |
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
47 def isFiltered(self, event): |
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
48 return event.getKey().getValue() in self._keys |
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
49 |
512
6ddb1eb9dfa6
Added the Scene which loads the town map. It is no longer a black screen demo.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
510
diff
changeset
|
50 class ApplicationListener(fife.IKeyListener, fife.ICommandListener, fife.ConsoleExecuter): |
550
d0282579668c
Added QuestManager. The player can now move from map to map and the state of the quests remains persistent. Both quests the NPC gives you are now completable. Still have to clean up the quest loading code.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
51 """ |
d0282579668c
Added QuestManager. The player can now move from map to map and the state of the quests remains persistent. Both quests the NPC gives you are now completable. Still have to clean up the quest loading code.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
52 Listens for window commands, console commands and keyboard input. |
d0282579668c
Added QuestManager. The player can now move from map to map and the state of the quests remains persistent. Both quests the NPC gives you are now completable. Still have to clean up the quest loading code.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
53 |
d0282579668c
Added QuestManager. The player can now move from map to map and the state of the quests remains persistent. Both quests the NPC gives you are now completable. Still have to clean up the quest loading code.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
54 Does not process game related input. |
d0282579668c
Added QuestManager. The player can now move from map to map and the state of the quests remains persistent. Both quests the NPC gives you are now completable. Still have to clean up the quest loading code.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
55 """ |
509
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
56 def __init__(self, engine, gamecontroller): |
550
d0282579668c
Added QuestManager. The player can now move from map to map and the state of the quests remains persistent. Both quests the NPC gives you are now completable. Still have to clean up the quest loading code.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
57 """ |
d0282579668c
Added QuestManager. The player can now move from map to map and the state of the quests remains persistent. Both quests the NPC gives you are now completable. Still have to clean up the quest loading code.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
58 Initializes all listeners and registers itself with the eventmanager. |
d0282579668c
Added QuestManager. The player can now move from map to map and the state of the quests remains persistent. Both quests the NPC gives you are now completable. Still have to clean up the quest loading code.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
59 """ |
509
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
60 self._engine = engine |
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
61 self._gamecontroller = gamecontroller |
512
6ddb1eb9dfa6
Added the Scene which loads the town map. It is no longer a black screen demo.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
510
diff
changeset
|
62 self._eventmanager = self._engine.getEventManager() |
509
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
63 |
512
6ddb1eb9dfa6
Added the Scene which loads the town map. It is no longer a black screen demo.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
510
diff
changeset
|
64 fife.IKeyListener.__init__(self) |
6ddb1eb9dfa6
Added the Scene which loads the town map. It is no longer a black screen demo.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
510
diff
changeset
|
65 self._eventmanager.addKeyListener(self) |
6ddb1eb9dfa6
Added the Scene which loads the town map. It is no longer a black screen demo.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
510
diff
changeset
|
66 |
6ddb1eb9dfa6
Added the Scene which loads the town map. It is no longer a black screen demo.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
510
diff
changeset
|
67 fife.ICommandListener.__init__(self) |
6ddb1eb9dfa6
Added the Scene which loads the town map. It is no longer a black screen demo.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
510
diff
changeset
|
68 self._eventmanager.addCommandListener(self) |
509
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
69 |
512
6ddb1eb9dfa6
Added the Scene which loads the town map. It is no longer a black screen demo.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
510
diff
changeset
|
70 fife.ConsoleExecuter.__init__(self) |
6ddb1eb9dfa6
Added the Scene which loads the town map. It is no longer a black screen demo.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
510
diff
changeset
|
71 self._engine.getGuiManager().getConsole().setConsoleExecuter(self) |
6ddb1eb9dfa6
Added the Scene which loads the town map. It is no longer a black screen demo.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
510
diff
changeset
|
72 |
6ddb1eb9dfa6
Added the Scene which loads the town map. It is no longer a black screen demo.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
510
diff
changeset
|
73 keyfilter = KeyFilter([fife.Key.ESCAPE, fife.Key.BACKQUOTE, fife.Key.PRINT_SCREEN]) |
6ddb1eb9dfa6
Added the Scene which loads the town map. It is no longer a black screen demo.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
510
diff
changeset
|
74 keyfilter.__disown__() |
6ddb1eb9dfa6
Added the Scene which loads the town map. It is no longer a black screen demo.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
510
diff
changeset
|
75 |
6ddb1eb9dfa6
Added the Scene which loads the town map. It is no longer a black screen demo.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
510
diff
changeset
|
76 self._eventmanager.setKeyFilter(keyfilter) |
6ddb1eb9dfa6
Added the Scene which loads the town map. It is no longer a black screen demo.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
510
diff
changeset
|
77 |
509
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
78 self.quit = False |
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
79 |
512
6ddb1eb9dfa6
Added the Scene which loads the town map. It is no longer a black screen demo.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
510
diff
changeset
|
80 def keyPressed(self, event): |
550
d0282579668c
Added QuestManager. The player can now move from map to map and the state of the quests remains persistent. Both quests the NPC gives you are now completable. Still have to clean up the quest loading code.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
81 """ |
d0282579668c
Added QuestManager. The player can now move from map to map and the state of the quests remains persistent. Both quests the NPC gives you are now completable. Still have to clean up the quest loading code.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
82 Processes any non game related keyboar input. |
d0282579668c
Added QuestManager. The player can now move from map to map and the state of the quests remains persistent. Both quests the NPC gives you are now completable. Still have to clean up the quest loading code.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
83 """ |
d0282579668c
Added QuestManager. The player can now move from map to map and the state of the quests remains persistent. Both quests the NPC gives you are now completable. Still have to clean up the quest loading code.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
84 if event.isConsumed(): |
d0282579668c
Added QuestManager. The player can now move from map to map and the state of the quests remains persistent. Both quests the NPC gives you are now completable. Still have to clean up the quest loading code.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
85 return |
d0282579668c
Added QuestManager. The player can now move from map to map and the state of the quests remains persistent. Both quests the NPC gives you are now completable. Still have to clean up the quest loading code.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
86 |
512
6ddb1eb9dfa6
Added the Scene which loads the town map. It is no longer a black screen demo.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
510
diff
changeset
|
87 keyval = event.getKey().getValue() |
6ddb1eb9dfa6
Added the Scene which loads the town map. It is no longer a black screen demo.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
510
diff
changeset
|
88 keystr = event.getKey().getAsString().lower() |
6ddb1eb9dfa6
Added the Scene which loads the town map. It is no longer a black screen demo.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
510
diff
changeset
|
89 |
509
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
90 if keyval == fife.Key.ESCAPE: |
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
91 self.quit = True |
512
6ddb1eb9dfa6
Added the Scene which loads the town map. It is no longer a black screen demo.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
510
diff
changeset
|
92 event.consume() |
6ddb1eb9dfa6
Added the Scene which loads the town map. It is no longer a black screen demo.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
510
diff
changeset
|
93 elif keyval == fife.Key.BACKQUOTE: |
510
cd959b05a262
There is now a main menu. You can also view the credits. Taking a screenshot and opening the console should also work.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
509
diff
changeset
|
94 self._engine.getGuiManager().getConsole().toggleShowHide() |
512
6ddb1eb9dfa6
Added the Scene which loads the town map. It is no longer a black screen demo.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
510
diff
changeset
|
95 event.consume() |
6ddb1eb9dfa6
Added the Scene which loads the town map. It is no longer a black screen demo.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
510
diff
changeset
|
96 elif keyval == fife.Key.PRINT_SCREEN: |
6ddb1eb9dfa6
Added the Scene which loads the town map. It is no longer a black screen demo.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
510
diff
changeset
|
97 self._engine.getRenderBackend().captureScreen(time.strftime("%Y%m%d_%H%M%S", time.localtime()) + ".png") |
6ddb1eb9dfa6
Added the Scene which loads the town map. It is no longer a black screen demo.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
510
diff
changeset
|
98 event.consume() |
6ddb1eb9dfa6
Added the Scene which loads the town map. It is no longer a black screen demo.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
510
diff
changeset
|
99 |
6ddb1eb9dfa6
Added the Scene which loads the town map. It is no longer a black screen demo.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
510
diff
changeset
|
100 def keyReleased(self, event): |
6ddb1eb9dfa6
Added the Scene which loads the town map. It is no longer a black screen demo.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
510
diff
changeset
|
101 pass |
509
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
102 |
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
103 def onCommand(self, command): |
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
104 self.quit = (command.getCommandType() == fife.CMD_QUIT_GAME) |
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
105 if self.quit: |
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
106 command.consume() |
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
107 |
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
108 def onConsoleCommand(self, command): |
534
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
513
diff
changeset
|
109 result = "" |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
513
diff
changeset
|
110 |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
513
diff
changeset
|
111 args = command.split(" ") |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
513
diff
changeset
|
112 cmd = [] |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
513
diff
changeset
|
113 for arg in args: |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
513
diff
changeset
|
114 arg = arg.strip() |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
513
diff
changeset
|
115 if arg != "": |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
513
diff
changeset
|
116 cmd.append(arg) |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
513
diff
changeset
|
117 |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
513
diff
changeset
|
118 if cmd[0].lower() in ('quit', 'exit'): |
509
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
119 self.quit = True |
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
120 result = 'quitting' |
534
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
513
diff
changeset
|
121 elif cmd[0].lower() in ( 'help' ): |
513
edf5c0cf52f3
Added the Actor and Player classes. Actor is the base class that the player and all enemies + NPCs will inherit.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
512
diff
changeset
|
122 helptextfile = self._gamecontroller.settings.get("RPG", "HelpText", "misc/help.txt") |
edf5c0cf52f3
Added the Actor and Player classes. Actor is the base class that the player and all enemies + NPCs will inherit.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
512
diff
changeset
|
123 self._engine.getGuiManager().getConsole().println( open( helptextfile, 'r' ).read() ) |
534
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
513
diff
changeset
|
124 result = "--OK--" |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
513
diff
changeset
|
125 elif cmd[0].lower() in ( 'eval' ): |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
513
diff
changeset
|
126 try: |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
513
diff
changeset
|
127 result = str(eval(command.lstrip(cmd[0]))) |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
513
diff
changeset
|
128 except: |
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
513
diff
changeset
|
129 result = "Invalid eval statement..." |
509
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
130 else: |
510
cd959b05a262
There is now a main menu. You can also view the credits. Taking a screenshot and opening the console should also work.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
509
diff
changeset
|
131 result = self._gamecontroller.onConsoleCommand(command) |
534
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
513
diff
changeset
|
132 |
509
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
133 if not result: |
513
edf5c0cf52f3
Added the Actor and Player classes. Actor is the base class that the player and all enemies + NPCs will inherit.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
512
diff
changeset
|
134 result = 'Command Not Found...' |
534
65a92a2449d5
Doing some re-factoring.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
513
diff
changeset
|
135 |
509
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
136 return result |
512
6ddb1eb9dfa6
Added the Scene which loads the town map. It is no longer a black screen demo.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
510
diff
changeset
|
137 |
6ddb1eb9dfa6
Added the Scene which loads the town map. It is no longer a black screen demo.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
510
diff
changeset
|
138 def onToolsClick(self): |
6ddb1eb9dfa6
Added the Scene which loads the town map. It is no longer a black screen demo.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
510
diff
changeset
|
139 print "No tools set up yet" |
509
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
140 |
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
141 class RPGApplication(ApplicationBase): |
550
d0282579668c
Added QuestManager. The player can now move from map to map and the state of the quests remains persistent. Both quests the NPC gives you are now completable. Still have to clean up the quest loading code.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
142 """ |
d0282579668c
Added QuestManager. The player can now move from map to map and the state of the quests remains persistent. Both quests the NPC gives you are now completable. Still have to clean up the quest loading code.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
143 The main application. It inherits fife.extensions.ApplicationBase. |
d0282579668c
Added QuestManager. The player can now move from map to map and the state of the quests remains persistent. Both quests the NPC gives you are now completable. Still have to clean up the quest loading code.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
144 |
d0282579668c
Added QuestManager. The player can now move from map to map and the state of the quests remains persistent. Both quests the NPC gives you are now completable. Still have to clean up the quest loading code.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
145 Implements ApplicationBase._pump(). |
d0282579668c
Added QuestManager. The player can now move from map to map and the state of the quests remains persistent. Both quests the NPC gives you are now completable. Still have to clean up the quest loading code.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
146 """ |
509
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
147 def __init__(self, TDS): |
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
148 super(RPGApplication,self).__init__(TDS) |
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
149 self._settings = TDS |
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
150 |
656
99e3ef63495b
* The RPG and Shooter demos now clear the screen when in OpenGL mode
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
566
diff
changeset
|
151 self.engine.getRenderBackend().setClearBackBuffer(True) |
99e3ef63495b
* The RPG and Shooter demos now clear the screen when in OpenGL mode
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
566
diff
changeset
|
152 |
509
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
153 self._gamecontroller = GameController(self, self.engine, self._settings) |
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
154 |
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
155 def createListener(self): |
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
156 """ |
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
157 @note: This function had to be overloaded otherwise the default |
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
158 listener would have been created. |
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
159 """ |
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
160 self._listener = ApplicationListener(self.engine, self._gamecontroller) |
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
161 return self._listener |
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
162 |
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
163 def requestQuit(self): |
550
d0282579668c
Added QuestManager. The player can now move from map to map and the state of the quests remains persistent. Both quests the NPC gives you are now completable. Still have to clean up the quest loading code.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
164 """ |
d0282579668c
Added QuestManager. The player can now move from map to map and the state of the quests remains persistent. Both quests the NPC gives you are now completable. Still have to clean up the quest loading code.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
165 Sends the quit command to the application's listener. We could set |
d0282579668c
Added QuestManager. The player can now move from map to map and the state of the quests remains persistent. Both quests the NPC gives you are now completable. Still have to clean up the quest loading code.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
166 self.quitRequested to true also but this is a good example on how |
d0282579668c
Added QuestManager. The player can now move from map to map and the state of the quests remains persistent. Both quests the NPC gives you are now completable. Still have to clean up the quest loading code.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
167 to build and dispatch a fife.Command. |
d0282579668c
Added QuestManager. The player can now move from map to map and the state of the quests remains persistent. Both quests the NPC gives you are now completable. Still have to clean up the quest loading code.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
168 """ |
509
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
169 cmd = fife.Command() |
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
170 cmd.setSource(None) |
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
171 cmd.setCommandType(fife.CMD_QUIT_GAME) |
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
172 self.engine.getEventManager().dispatchCommand(cmd) |
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
173 |
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
174 def _pump(self): |
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
175 if self._listener.quit: |
550
d0282579668c
Added QuestManager. The player can now move from map to map and the state of the quests remains persistent. Both quests the NPC gives you are now completable. Still have to clean up the quest loading code.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
176 self._gamecontroller.endGame() |
560
69d50e751c9a
Lots of changes.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
550
diff
changeset
|
177 self.quit() |
509
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
178 else: |
3951042a701e
Adding the RPG demo. This is basically empty at the moment. Currently it will start with a black screen.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
179 self._gamecontroller.pump() |
536
1afe46247ab1
Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
534
diff
changeset
|
180 |
1afe46247ab1
Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
534
diff
changeset
|
181 |
1afe46247ab1
Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
534
diff
changeset
|
182 def _getLogManager(self): |
1afe46247ab1
Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
534
diff
changeset
|
183 return self._log |
1afe46247ab1
Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
534
diff
changeset
|
184 |
1afe46247ab1
Some misc code cleanup.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
534
diff
changeset
|
185 logger = property(_getLogManager) |