Mercurial > fife-parpg
comparison demos/rpg/scripts/gamecontroller.py @ 517:c3a026cdd91b
Added the BaseGameObject class and put it in it's own file. All game object will inherit it. Added instance action listeners.
author | prock@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Wed, 26 May 2010 15:28:25 +0000 |
parents | d70fc46c8aa5 |
children | 14f777be6b94 |
comparison
equal
deleted
inserted
replaced
516:d70fc46c8aa5 | 517:c3a026cdd91b |
---|---|
26 | 26 |
27 import sys, os, re, math, random, shutil | 27 import sys, os, re, math, random, shutil |
28 | 28 |
29 from fife import fife | 29 from fife import fife |
30 | 30 |
31 from fife.extensions.soundmanager import SoundManager | |
32 from fife.extensions.loaders import loadImportFile | |
33 | |
31 from scripts.scene import Scene | 34 from scripts.scene import Scene |
32 from scripts.guicontroller import GUIController | 35 from scripts.guicontroller import GUIController |
33 from fife.extensions.loaders import loadImportFile | 36 |
34 | 37 |
35 class KeyState(object): | 38 class KeyState(object): |
36 def __init__(self): | 39 def __init__(self): |
37 self._keystate = { } | 40 self._keystate = { } |
38 | 41 |
52 def __init__(self, gamecontroller): | 55 def __init__(self, gamecontroller): |
53 self._engine = gamecontroller.engine | 56 self._engine = gamecontroller.engine |
54 self._gamecontroller = gamecontroller | 57 self._gamecontroller = gamecontroller |
55 self._settings = gamecontroller.settings | 58 self._settings = gamecontroller.settings |
56 self._eventmanager = self._engine.getEventManager() | 59 self._eventmanager = self._engine.getEventManager() |
60 self._soundmanager = SoundManager(self._engine) | |
57 | 61 |
58 fife.IMouseListener.__init__(self) | 62 fife.IMouseListener.__init__(self) |
59 fife.IKeyListener.__init__(self) | 63 fife.IKeyListener.__init__(self) |
60 | 64 |
61 self._attached = False | 65 self._attached = False |
99 renderer.removeAllOutlines() | 103 renderer.removeAllOutlines() |
100 else: | 104 else: |
101 return | 105 return |
102 | 106 |
103 pt = fife.ScreenPoint(event.getX(), event.getY()) | 107 pt = fife.ScreenPoint(event.getX(), event.getY()) |
104 instances = self.getInstancesAt(pt); | 108 instances = self._gamecontroller.scene.getInstancesAt(pt); |
109 | |
105 for i in instances: | 110 for i in instances: |
106 renderer.addOutlined(i, 173, 255, 47, 2) | 111 renderer.addOutlined(i, 173, 255, 47, 2) |
107 | 112 |
108 def mouseEntered(self, event): | 113 def mouseEntered(self, event): |
109 pass | 114 pass |
115 | |
110 def mouseExited(self, event): | 116 def mouseExited(self, event): |
111 pass | 117 pass |
118 | |
112 def mouseClicked(self, event): | 119 def mouseClicked(self, event): |
113 pass | 120 pass |
121 | |
114 def mouseWheelMovedUp(self, event): | 122 def mouseWheelMovedUp(self, event): |
115 pass | 123 pass |
124 | |
116 def mouseWheelMovedDown(self, event): | 125 def mouseWheelMovedDown(self, event): |
117 pass | 126 pass |
118 def mouseMoved(self, event): | 127 |
119 pass | |
120 def mouseDragged(self, event): | 128 def mouseDragged(self, event): |
121 pass | 129 pass |
130 | |
122 def keyPressed(self, event): | 131 def keyPressed(self, event): |
123 keyval = event.getKey().getValue() | 132 keyval = event.getKey().getValue() |
124 keystr = event.getKey().getAsString().lower() | 133 keystr = event.getKey().getAsString().lower() |
125 if keyval == fife.Key.ESCAPE: | 134 if keyval == fife.Key.ESCAPE: |
126 self.detach() | 135 self.detach() |