Status: | Merged | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Approved by: | Alistair Broomhead | ||||||||||||||||||||
Approved revision: | no longer in the source branch. | ||||||||||||||||||||
Merged at revision: | 1 | ||||||||||||||||||||
Proposed branch: | lp:pyqtrpg | ||||||||||||||||||||
Merge into: | lp:pyqtrpg/debug | ||||||||||||||||||||
Diff against target: |
998 lines (+731/-38) 20 files modified
Display.py (+4/-0) GameObjects/_Character.py (+46/-0) GameObjects/_Containable.py (+2/-1) GameObjects/_GameObject.py (+44/-15) GameObjects/_Level.py (+5/-0) GameObjects/__init__.py (+5/-3) GameObjects/_fifo.py (+47/-0) GameObjects/commandList.py (+21/-0) Levels/Level00.py (+27/-0) Levels/World00.py (+3/-0) Levels/__init__.py (+2/-0) Levels/objects.py (+92/-0) _Display/_DebugOutput.py (+29/-0) _Display/_DisplayObject.py (+52/-0) _Display/_DisplayWindow.py (+79/-0) _Display/_Interface.py (+114/-0) _Display/__init__.py (+4/-0) _Display/_clickableIcon.py (+29/-0) _Display/_interfaceButton.py (+51/-0) pyrpg.py (+75/-19) |
||||||||||||||||||||
To merge this branch: | bzr merge lp:pyqtrpg | ||||||||||||||||||||
Related bugs: |
|
||||||||||||||||||||
Related blueprints: |
Moving around
(Essential)
Attacking things
(Essential)
Opening doors
(Essential)
Dying
(Essential)
Picking up items and adding them to inventory
(Essential)
Some objects to test other features
(Essential)
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Alistair Broomhead | Approve | ||
Review via email: mp+46299@code.launchpad.net |
Commit message
Looks good...
Description of the change
All features for 0.2 complete.
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === added file 'Display.py' |
2 | --- Display.py 1970-01-01 00:00:00 +0000 |
3 | +++ Display.py 2011-01-14 17:58:52 +0000 |
4 | @@ -0,0 +1,4 @@ |
5 | +from _Display import (DisplayObject, |
6 | + DisplayWindow, |
7 | + Interface, |
8 | + DebugOutput) |
9 | \ No newline at end of file |
10 | |
11 | === added file 'GameObjects/_Character.py' |
12 | --- GameObjects/_Character.py 1970-01-01 00:00:00 +0000 |
13 | +++ GameObjects/_Character.py 2011-01-14 17:58:52 +0000 |
14 | @@ -0,0 +1,46 @@ |
15 | +from PyQt4.Qt import pyqtSignal |
16 | +from _Containable import Containable |
17 | +class Character(Containable): |
18 | + broadcast = pyqtSignal(str) |
19 | + def tick(self): |
20 | + def getcmd(c): |
21 | + x = c.getfirst() |
22 | + return x[0], x[1:] |
23 | + c = self.commands |
24 | + if c.len: |
25 | + obj,cmd = getcmd(c) |
26 | + while obj != self: |
27 | + obj.commands.add(c.pop()) |
28 | + obj,cmd = getcmd(c) |
29 | + x,y = self.position |
30 | + self.broadcast.emit("%s@%s:\t%s"%(self.name, self.position,`cmd`)) |
31 | + if cmd[0] == 'up': |
32 | + self.position = (x,y-1) |
33 | + c.pop() |
34 | + elif cmd[0] == 'down': |
35 | + self.position = (x,y+1) |
36 | + c.pop() |
37 | + elif cmd[0] == 'left': |
38 | + self.position = (x-1,y) |
39 | + c.pop() |
40 | + elif cmd[0] == 'right': |
41 | + self.position = (x+1,y) |
42 | + c.pop() |
43 | + elif cmd[0] in ['move', 'attack']: |
44 | + X,Y = cmd[1] |
45 | + if X-x > 0: |
46 | + self.position = (x+1,y) |
47 | + elif X-x < 0: |
48 | + self.position = (x-1,y) |
49 | + elif Y-y > 0: |
50 | + self.position = (x,y+1) |
51 | + elif Y-y < 0: |
52 | + self.position = (x,y-1) |
53 | + if (X-x)**2 + (Y-y)**2 == 1: |
54 | + c.pop() |
55 | + self._allObjects[0].Changed.emit() |
56 | + |
57 | + def __init__(self, **kwargs): |
58 | + if not 'name' in kwargs: |
59 | + kwargs['name'] = 'Unknown Character' |
60 | + Containable.__init__(self, **kwargs) |
61 | \ No newline at end of file |
62 | |
63 | === modified file 'GameObjects/_Containable.py' |
64 | --- GameObjects/_Containable.py 2010-11-22 06:47:41 +0000 |
65 | +++ GameObjects/_Containable.py 2011-01-14 17:58:52 +0000 |
66 | @@ -9,5 +9,6 @@ |
67 | assert isinstance(info[1], info[0]) |
68 | self.container = container |
69 | container.addContent(self) |
70 | - except Exception, e: |
71 | + container.contents.sort() |
72 | + except Exception, e: |
73 | e.args = self._custAssert(info, e.args), |
74 | \ No newline at end of file |
75 | |
76 | === modified file 'GameObjects/_GameObject.py' |
77 | --- GameObjects/_GameObject.py 2010-11-22 06:47:41 +0000 |
78 | +++ GameObjects/_GameObject.py 2011-01-14 17:58:52 +0000 |
79 | @@ -1,4 +1,9 @@ |
80 | -class GameObject(object): |
81 | +from commandList import commandQueue |
82 | +from PyQt4.QtCore import QObject, pyqtSignal |
83 | +class _contentList(list): |
84 | + def sort(self): |
85 | + list.sort(self,key=lambda tile:tile.flag) |
86 | +class GameObject(QObject): |
87 | """ |
88 | This is the class which all objects in the game must subclass. This |
89 | enables us to keep a list of all game objects. |
90 | @@ -7,6 +12,8 @@ |
91 | detection - this should also be useful for debugging, and probably for |
92 | purposes I have not yet thought of. |
93 | """ |
94 | + ItemAdded = pyqtSignal(str) |
95 | + Changed = pyqtSignal() |
96 | _allObjects = [] |
97 | def __getitem__(self,i): |
98 | return self.contents[i] |
99 | @@ -17,7 +24,7 @@ |
100 | """Returns all GameObjects decended from the same type as self""" |
101 | return [x for x in self._allObjects |
102 | if isinstance(x, type(self))] |
103 | - |
104 | + |
105 | def _custAssert(self,(expected, got, input), e_args): |
106 | return ' '.join(("You tried to input a", `input`, ':', |
107 | `type(got)`, ',', `got`, 'into ', |
108 | @@ -28,7 +35,7 @@ |
109 | info = (GameObject, content, "Item to be added to "+self.name) |
110 | assert isinstance(info[1], info[0]) |
111 | self.contents.append(content) |
112 | - except Exception, e: |
113 | + except Exception, e: |
114 | e.args = self._custAssert(info, e.args), |
115 | raise |
116 | def __init__(self, position=(0,0), |
117 | @@ -36,10 +43,23 @@ |
118 | size=(-1,-1), |
119 | stats={}, |
120 | contents=[], |
121 | - name="Unknown Object"): |
122 | + name="Unknown Object", |
123 | + image='', |
124 | + flag=0): |
125 | + QObject.__init__(self) |
126 | + |
127 | + self.commands = commandQueue() |
128 | try: |
129 | + # On some platforms there is no support for python beyond 2.5.4 |
130 | + # ABC's were only implemented in python 2.6 so we'll fall back to |
131 | + # integers if we can't use Number - the base class for int and float etc |
132 | from numbers import Number |
133 | - # Check position is a tuple |
134 | + except: |
135 | + Number = int |
136 | + try: |
137 | + self.flag = flag |
138 | + |
139 | + # Check position is a tuple |
140 | info = (tuple, position, "position") |
141 | assert isinstance(info[1], info[0]) |
142 | info = (Number, position[0], "position_x") |
143 | @@ -47,8 +67,8 @@ |
144 | info = (Number, position[1], "position_y") |
145 | assert isinstance(info[1], info[0]) |
146 | self.position = position |
147 | - |
148 | - # Check size is a tuple |
149 | + |
150 | + # Check heading is a tuple |
151 | info = (tuple, heading, "heading") |
152 | assert isinstance(info[1], info[0]) |
153 | info = (Number, heading[0], "heading_speed") |
154 | @@ -56,30 +76,39 @@ |
155 | info = (Number, heading[1], "heading_XY_angle") |
156 | assert isinstance(info[1], info[0]) |
157 | self.heading = heading |
158 | - |
159 | + |
160 | # Check size is a tuple |
161 | info = (tuple, size, "size") |
162 | assert isinstance(info[1], info[0]) |
163 | self.size = size |
164 | - |
165 | - # Check size is a tuple |
166 | + |
167 | + # Check name is a string |
168 | info = (str, name, "name") |
169 | assert isinstance(info[1], info[0]) |
170 | self.name = name |
171 | - |
172 | + |
173 | # Check stats is a dictionary |
174 | info = (dict, stats, "stats") |
175 | assert isinstance(info[1], info[0]) |
176 | self.stats = stats.copy() |
177 | - |
178 | + |
179 | # Check contents is a list |
180 | info = (list, contents, "contents") |
181 | assert isinstance(info[1], info[0]) |
182 | for obj in contents: |
183 | info = (GameObject, obj, "object in contents") |
184 | assert isinstance(info[1], info[0]) |
185 | - self.contents = contents[:] |
186 | + def _sort(): |
187 | + pass |
188 | + self.contents = _contentList(contents[:]) |
189 | + #self.contents.sort = _sort |
190 | self._allObjects.append(self) |
191 | - except Exception, e: |
192 | + self._allObjects[0].ItemAdded.emit(self.name) |
193 | + |
194 | + # Check image is a string |
195 | + info = (str, image, "image") |
196 | + assert isinstance(info[1], info[0]) |
197 | + self.image = image |
198 | + except Exception, e: |
199 | e.args = self._custAssert(info, e.args), |
200 | - raise |
201 | \ No newline at end of file |
202 | + raise |
203 | |
204 | === added file 'GameObjects/_Level.py' |
205 | --- GameObjects/_Level.py 1970-01-01 00:00:00 +0000 |
206 | +++ GameObjects/_Level.py 2011-01-14 17:58:52 +0000 |
207 | @@ -0,0 +1,5 @@ |
208 | +from _World import World |
209 | +class Level(World): |
210 | + def __init__(self, container, **kwargs): |
211 | + kwargs.setdefault('name', 'Unknown Level') |
212 | + parent = World.__init__(self, container, **kwargs) |
213 | \ No newline at end of file |
214 | |
215 | === modified file 'GameObjects/__init__.py' |
216 | --- GameObjects/__init__.py 2010-11-22 06:47:41 +0000 |
217 | +++ GameObjects/__init__.py 2011-01-14 17:58:52 +0000 |
218 | @@ -1,10 +1,12 @@ |
219 | from _GameObject import GameObject |
220 | from _Containable import Containable |
221 | from _World import World |
222 | +from _Level import Level |
223 | from _Weapon import Weapon |
224 | + |
225 | +# Further object types being defined |
226 | +from _Character import Character as Character |
227 | # Further object types to be implemented |
228 | #from _Potion import Potion |
229 | -#from _Resource import Resource |
230 | -#from _Character import Character |
231 | -#from _NCP import NCP |
232 | +#from _Resource import Resource |
233 | #from _NCP import NCP |
234 | #from _Quests import Quests |
235 | |
236 | === added file 'GameObjects/_fifo.py' |
237 | --- GameObjects/_fifo.py 1970-01-01 00:00:00 +0000 |
238 | +++ GameObjects/_fifo.py 2011-01-14 17:58:52 +0000 |
239 | @@ -0,0 +1,47 @@ |
240 | +class _first(object): |
241 | + def __get__(self): |
242 | + new_ = (x for x in self._parent._list[0]) |
243 | + return self._parent._list[0] |
244 | + def __set__(self, new_): |
245 | + #new_ = (x for x in new_) |
246 | + self._parent._parent.takenFrom.emit(self._parent._list[0]) |
247 | + self._parent._parent.addedTo.emit(new_) |
248 | + self._parent._list[0] = (new_) |
249 | + def __del__(self): |
250 | + self._parent._parent.takenFrom.emit(self._parent._list.pop(0)) |
251 | + if not self._parent._list: |
252 | + self._parent._parent.isEmpty.emit() |
253 | + def __init__(self,parent): |
254 | + self._parent = parent |
255 | + |
256 | +class _fifo(object): |
257 | + def __get__(self): |
258 | + new_ = [x for x in self._list] |
259 | + return new_ |
260 | + def __set__(self, new_): |
261 | + #new_ = (x for x in new_) |
262 | + if not self._list: |
263 | + self._parent.isNotEmpty.emit() |
264 | + self._list.extend(new_) |
265 | + for item in new_: |
266 | + self._parent.addedTo.emit(item) |
267 | + def __getitem__(self, k): |
268 | + new_ = (x for x in self._list[k]) |
269 | + return self._list[k] |
270 | + def getfirst(self): |
271 | + new_ = (x for x in self._list[0]) |
272 | + return self._list[0] |
273 | + def pop(self): |
274 | + item = self.getfirst() |
275 | + self.first.__del__() |
276 | + return item |
277 | + def append(self, item): |
278 | + self.__set__([item,]) |
279 | + def __init__(self, parent, other=None): |
280 | + self._list = [] |
281 | + self._parent = parent |
282 | + self.first = _first(self) |
283 | + if other: |
284 | + for X in other: |
285 | + #X = (x for x in X) |
286 | + self._list.append(X) |
287 | \ No newline at end of file |
288 | |
289 | === added file 'GameObjects/commandList.py' |
290 | --- GameObjects/commandList.py 1970-01-01 00:00:00 +0000 |
291 | +++ GameObjects/commandList.py 2011-01-14 17:58:52 +0000 |
292 | @@ -0,0 +1,21 @@ |
293 | +from PyQt4.Qt import (QObject, |
294 | + pyqtSignal, |
295 | + QString) |
296 | +from _fifo import _fifo |
297 | +class commandQueue(QObject): |
298 | + addedTo = pyqtSignal(tuple) |
299 | + takenFrom = pyqtSignal(tuple) |
300 | + isNotEmpty = pyqtSignal() |
301 | + isEmpty = pyqtSignal() |
302 | + def add(self, *item): |
303 | + self._fifo.append(tuple(item)) |
304 | + def __init__(self): |
305 | + QObject.__init__(self) |
306 | + self._fifo = _fifo(self) |
307 | + self.first = self._fifo.first |
308 | + self.getfirst = self._fifo.getfirst |
309 | + self.pop = self._fifo.pop |
310 | + self.isEmpty.emit() |
311 | + @property |
312 | + def len(self): |
313 | + return len(self._fifo._list) |
314 | \ No newline at end of file |
315 | |
316 | === added directory 'Levels' |
317 | === added file 'Levels/Level00.py' |
318 | --- Levels/Level00.py 1970-01-01 00:00:00 +0000 |
319 | +++ Levels/Level00.py 2011-01-14 17:58:52 +0000 |
320 | @@ -0,0 +1,27 @@ |
321 | +# Levels are defined as tuple grids - each square of the tuple grid |
322 | +# is a square of a game map. |
323 | +from objects import * |
324 | +level = ( |
325 | +( Wall, Wall, Wall, Wall, Wall, Wall, Wall, Wall, Wall, Wall, Wall, Wall), |
326 | + |
327 | +( Wall, Floor, Floor, Floor, Wall, Out, Out, Wall, Floor, Floor, Floor, Wall), |
328 | + |
329 | +( Wall, Floor, (Floor, |
330 | + Player),Floor, Wall, Out, Out, Wall, Floor, Floor, Floor, Wall), |
331 | + |
332 | +( Wall, Floor, Floor, Floor, Wall, Wall, Wall, Floor, Floor, Floor, Floor, Wall), |
333 | + |
334 | +( Wall, Floor, (Floor, |
335 | + Sword), Floor, Floor, Floor, Floor, Floor, Wall, Wall, Floor, (Floor, |
336 | + Door)), |
337 | + |
338 | +( Wall, Floor, Floor, Floor, Floor, Floor, Floor, Wall, Out, Wall, Floor, Wall), |
339 | + |
340 | +( Wall, Floor, Floor, Floor, Floor, Floor, Floor, Wall, Out, Wall, Floor, Wall), |
341 | + |
342 | +( Wall, Floor, Floor, Floor, Floor, Floor, Floor, Wall, Out, Wall, Floor, Wall), |
343 | + |
344 | +( Wall, Floor, Floor, Floor, Floor, Floor, Floor, Wall, Out, Wall, Floor, Wall), |
345 | + |
346 | +( Wall, Wall, Wall, Wall, Wall, Wall, Wall, Wall, Wall, Wall, Wall, Wall), |
347 | +) |
348 | \ No newline at end of file |
349 | |
350 | === added file 'Levels/Level01.py' |
351 | === added file 'Levels/World00.py' |
352 | --- Levels/World00.py 1970-01-01 00:00:00 +0000 |
353 | +++ Levels/World00.py 2011-01-14 17:58:52 +0000 |
354 | @@ -0,0 +1,3 @@ |
355 | +world = [] |
356 | +import Level00; world.append(Level00.level) |
357 | +#import Level01; world.append(Level01.level) |
358 | \ No newline at end of file |
359 | |
360 | === added file 'Levels/__init__.py' |
361 | --- Levels/__init__.py 1970-01-01 00:00:00 +0000 |
362 | +++ Levels/__init__.py 2011-01-14 17:58:52 +0000 |
363 | @@ -0,0 +1,2 @@ |
364 | +worlds = [] |
365 | +import World00; worlds.append(World00.world) |
366 | \ No newline at end of file |
367 | |
368 | === added file 'Levels/objects.py' |
369 | --- Levels/objects.py 1970-01-01 00:00:00 +0000 |
370 | +++ Levels/objects.py 2011-01-14 17:58:52 +0000 |
371 | @@ -0,0 +1,92 @@ |
372 | +# This gives a set of objects that can be used to build levels |
373 | + |
374 | +class _statsobject(object): |
375 | + def __get__(self): |
376 | + return self.__dict__.__get__() |
377 | + def __str__(self): |
378 | + return self.__dict__.__str__() |
379 | + def __repr__(self): |
380 | + return self.__dict__.__repr__() |
381 | + def copy(self): |
382 | + return self.__init__(self) |
383 | + def __getattr__(self,k): |
384 | + return None |
385 | + def __init__(self,old=None): |
386 | + if old: |
387 | + self.__dict__ = old.__dict__.copy() |
388 | + else: self.__dict__ = {} |
389 | +class _flagobject(object): |
390 | + def __call__(self, flag): |
391 | + if type(flag) == type(int) and flag&self._value: |
392 | + return True |
393 | + if type(flag) == type(self) and flag._value&self._value: |
394 | + return True |
395 | + return False |
396 | + def __get__(self): |
397 | + return self._value.__get__() |
398 | + def __str__(self): |
399 | + return hex(self._value) |
400 | + def __repr__(self): |
401 | + return repr(hex(self._value)) |
402 | + def __init__(self,flag): |
403 | + if flag == 0: |
404 | + self._value = 0 |
405 | + else: |
406 | + self._value = 2**(flag-1) |
407 | +class _objectMarker(object): |
408 | + @property |
409 | + def stats(self): |
410 | + return self._stats |
411 | + @property |
412 | + def flag(self): |
413 | + return self._flag |
414 | + @property |
415 | + def image(self): |
416 | + return self._image |
417 | + def __get__(self): |
418 | + return self._flag.__get__() |
419 | + def __str__(self): |
420 | + return self._flag.__str__() |
421 | + def __repr__(self): |
422 | + return self._flag.__repr__() |
423 | + def __nonzero__(self): |
424 | + return self._flag.__nonzero__() |
425 | + def __cmp__(self, other): |
426 | + return self._flag.__cmp__(other) |
427 | + def __init__(self,flag,image='',**kwargs): |
428 | + self.__dict__['_flag'] = _flagobject(flag) |
429 | + self.__dict__['_stats'] = _statsobject() |
430 | + self.__dict__['_stats'].__dict__ = kwargs |
431 | + self.__dict__['_image'] = image |
432 | + def __setattr__(self,k,v): |
433 | + try: |
434 | + assert k in self.__dict__ |
435 | + self.__dict__[k] = v |
436 | + except AssertionError: |
437 | + raise AttributeError, "'%s' is not an attribute of class '%s'"%(k,self.__class__.__name__) |
438 | + |
439 | + |
440 | +Out = _objectMarker(0) |
441 | + |
442 | +Floor = _objectMarker(1, 'GenericCarpet') |
443 | +Wall = _objectMarker(2, 'GenericWall') |
444 | +Door = _objectMarker(3) |
445 | + |
446 | +Player = _objectMarker(4, 'GenericCharacter') |
447 | +#Friend = _objectMarker(5) |
448 | +#Neutral = _objectMarker(6) |
449 | +#Enemy = _objectMarker(7) |
450 | + |
451 | +#Book = _objectMarker(8) |
452 | +#Scroll = _objectMarker(9) |
453 | +#HPotion = _objectMarker(10) |
454 | +#MPotion = _objectMarker(11) |
455 | + |
456 | +#Box = _objectMarker(12) |
457 | +#Resource = _objectMarker(13) |
458 | + |
459 | +#Dagger = _objectMarker(14) |
460 | +#Bow = _objectMarker(15) |
461 | +#Axe = _objectMarker(16) |
462 | +Shield = _objectMarker(17) |
463 | +Sword = _objectMarker(18, 'GenericWeapon') |
464 | |
465 | === added directory '_Display' |
466 | === added directory '_Display/Buttons' |
467 | === added file '_Display/Buttons/attack.png' |
468 | Binary files _Display/Buttons/attack.png 1970-01-01 00:00:00 +0000 and _Display/Buttons/attack.png 2011-01-14 17:58:52 +0000 differ |
469 | === added file '_Display/Buttons/close.png' |
470 | Binary files _Display/Buttons/close.png 1970-01-01 00:00:00 +0000 and _Display/Buttons/close.png 2011-01-14 17:58:52 +0000 differ |
471 | === added file '_Display/Buttons/down.png' |
472 | Binary files _Display/Buttons/down.png 1970-01-01 00:00:00 +0000 and _Display/Buttons/down.png 2011-01-14 17:58:52 +0000 differ |
473 | === added file '_Display/Buttons/fullscr.png' |
474 | Binary files _Display/Buttons/fullscr.png 1970-01-01 00:00:00 +0000 and _Display/Buttons/fullscr.png 2011-01-14 17:58:52 +0000 differ |
475 | === added file '_Display/Buttons/left.png' |
476 | Binary files _Display/Buttons/left.png 1970-01-01 00:00:00 +0000 and _Display/Buttons/left.png 2011-01-14 17:58:52 +0000 differ |
477 | === added file '_Display/Buttons/move.png' |
478 | Binary files _Display/Buttons/move.png 1970-01-01 00:00:00 +0000 and _Display/Buttons/move.png 2011-01-14 17:58:52 +0000 differ |
479 | === added file '_Display/Buttons/right.png' |
480 | Binary files _Display/Buttons/right.png 1970-01-01 00:00:00 +0000 and _Display/Buttons/right.png 2011-01-14 17:58:52 +0000 differ |
481 | === added file '_Display/Buttons/up.png' |
482 | Binary files _Display/Buttons/up.png 1970-01-01 00:00:00 +0000 and _Display/Buttons/up.png 2011-01-14 17:58:52 +0000 differ |
483 | === added directory '_Display/Sprites' |
484 | === added file '_Display/Sprites/Generic.png' |
485 | Binary files _Display/Sprites/Generic.png 1970-01-01 00:00:00 +0000 and _Display/Sprites/Generic.png 2011-01-14 17:58:52 +0000 differ |
486 | === added file '_Display/Sprites/GenericCarpet.png' |
487 | Binary files _Display/Sprites/GenericCarpet.png 1970-01-01 00:00:00 +0000 and _Display/Sprites/GenericCarpet.png 2011-01-14 17:58:52 +0000 differ |
488 | === added file '_Display/Sprites/GenericCharacter.png' |
489 | Binary files _Display/Sprites/GenericCharacter.png 1970-01-01 00:00:00 +0000 and _Display/Sprites/GenericCharacter.png 2011-01-14 17:58:52 +0000 differ |
490 | === added file '_Display/Sprites/GenericPotion.png' |
491 | Binary files _Display/Sprites/GenericPotion.png 1970-01-01 00:00:00 +0000 and _Display/Sprites/GenericPotion.png 2011-01-14 17:58:52 +0000 differ |
492 | === added file '_Display/Sprites/GenericWall.png' |
493 | Binary files _Display/Sprites/GenericWall.png 1970-01-01 00:00:00 +0000 and _Display/Sprites/GenericWall.png 2011-01-14 17:58:52 +0000 differ |
494 | === added file '_Display/Sprites/GenericWeapon.png' |
495 | Binary files _Display/Sprites/GenericWeapon.png 1970-01-01 00:00:00 +0000 and _Display/Sprites/GenericWeapon.png 2011-01-14 17:58:52 +0000 differ |
496 | === added file '_Display/Sprites/Thumbs.db' |
497 | Binary files _Display/Sprites/Thumbs.db 1970-01-01 00:00:00 +0000 and _Display/Sprites/Thumbs.db 2011-01-14 17:58:52 +0000 differ |
498 | === added file '_Display/_DebugOutput.py' |
499 | --- _Display/_DebugOutput.py 1970-01-01 00:00:00 +0000 |
500 | +++ _Display/_DebugOutput.py 2011-01-14 17:58:52 +0000 |
501 | @@ -0,0 +1,29 @@ |
502 | +from PyQt4.Qt import QTextEdit, QString |
503 | +class DebugOutput(QTextEdit): |
504 | + def __init__(self, player, parent, *args, **kwargs): |
505 | + QTextEdit.__init__(self, *args, **kwargs) |
506 | + QTextEdit.setFontPointSize(self, 10) |
507 | + self.setFixedWidth(320) |
508 | + self.setReadOnly(True) |
509 | + self.property("kineticScroller").toPyObject().setEnabled(True) |
510 | + self.text = '' |
511 | + self.parent = parent |
512 | + self.player = player |
513 | + player.commands.addedTo.connect(self._append) |
514 | + player.broadcast.connect(self._append) |
515 | + def _append(self,line): |
516 | + self.append(str(line)) |
517 | + #anchor = QString(line) |
518 | + #self.text += '\n'+line |
519 | + #QTextEdit.setText(self,self.text) |
520 | + #self.scrollContentsBy(0,-self.rect().height()) |
521 | + |
522 | + def resizeEvent(self, event): |
523 | + rect = self.rect() |
524 | + # self.append( 'Debug output:\t' + |
525 | + # `rect.width()` + |
526 | + # "x" + |
527 | + # `rect.height()`) |
528 | + QTextEdit.resizeEvent(self, event) |
529 | + def paintEvent(self, event): |
530 | + QTextEdit.paintEvent(self, event) |
531 | \ No newline at end of file |
532 | |
533 | === added file '_Display/_DisplayObject.py' |
534 | --- _Display/_DisplayObject.py 1970-01-01 00:00:00 +0000 |
535 | +++ _Display/_DisplayObject.py 2011-01-14 17:58:52 +0000 |
536 | @@ -0,0 +1,52 @@ |
537 | +from PyQt4.Qt import QMainWindow, QTimer |
538 | +class DisplayObject(QMainWindow): |
539 | + def doTicks(s): |
540 | + for char in s.Game.Player.getAllSameClass(): |
541 | + char.tick() |
542 | + def exec_(s): |
543 | + s._a.exec_() |
544 | + def __init__(s, Game): |
545 | + from _DebugOutput import DebugOutput |
546 | + from _DisplayWindow import DisplayWindow |
547 | + from _Interface import Interface |
548 | + from PyQt4.Qt import QApplication, QWidget, QGridLayout, QIcon |
549 | + from sys import argv |
550 | + import os.path |
551 | + win = (800, 480) |
552 | + s.Game = Game |
553 | + a = QApplication(argv) # We'll need a QApplication. |
554 | + QMainWindow.__init__(s) # And it'll be a subclass of QMainWindow, |
555 | + s.resize(*win) # so initialise it and give it a size. |
556 | + central = QWidget() |
557 | + s.setCentralWidget(central) # Central widget to contain layout, |
558 | + s.grid = QGridLayout(central) # like so... |
559 | + s.setWindowTitle("pyRPG") # Let's give it a nice title. |
560 | + s._a = a |
561 | + s.commands = Game.commands |
562 | + iconpath = ("Display/pyrpg.png") |
563 | + s.icon_ = QIcon() |
564 | + s.icon_.addFile(iconpath) |
565 | + s.setWindowIcon(s.icon_) |
566 | + |
567 | + s.DebugOutput = DebugOutput(player=Game.Player,parent=s) |
568 | + s.MainGraphicView = DisplayWindow(player=Game.Player,textstream=s.DebugOutput) |
569 | + s.Options = Interface(player=Game.Player,parent=s,textstream=s.DebugOutput) |
570 | + |
571 | + s.grid.addWidget(s.MainGraphicView, 0, 0) |
572 | + s.grid.addWidget(s.Options, 1, 0, 1, 0) |
573 | + s.grid.addWidget(s.DebugOutput, 0, 1) |
574 | + |
575 | + s.grid.setMargin(0) |
576 | + s.grid.setSpacing(0) |
577 | + s.grid.setRowStretch (0, 400) |
578 | + s.grid.setRowStretch (1, 80) |
579 | + s.grid.setColumnStretch (0, 480) |
580 | + s.grid.setColumnStretch (1, 320) |
581 | + |
582 | + s.Timer = QTimer() |
583 | + s.Timer.start(200) |
584 | + s.Timer.timeout.connect(s.doTicks) |
585 | + s.Game.Changed.connect(s.MainGraphicView.update) |
586 | + |
587 | + s.showFullScreen() # There's no point doing all of this if we |
588 | + # don't show it(FullScreen?) |
589 | |
590 | === added file '_Display/_DisplayWindow.py' |
591 | --- _Display/_DisplayWindow.py 1970-01-01 00:00:00 +0000 |
592 | +++ _Display/_DisplayWindow.py 2011-01-14 17:58:52 +0000 |
593 | @@ -0,0 +1,79 @@ |
594 | +from PyQt4.Qt import (QWidget, |
595 | + QColor, |
596 | + QPainter, |
597 | + QBrush, |
598 | + pyqtSignal, |
599 | + QRect) |
600 | + |
601 | +from PyQt4.QtCore import Qt |
602 | + |
603 | +class DisplayWindow(QWidget): |
604 | + pressed = pyqtSignal(tuple) |
605 | + released = pyqtSignal(tuple) |
606 | + clicked = pyqtSignal(tuple) |
607 | + dragged = pyqtSignal(tuple) |
608 | + def giveTile(self,x,y): |
609 | + x += self.x_offset |
610 | + y += self.y_offset |
611 | + tsx,tsy = self.tilesize |
612 | + X = x/tsx - 1 + ((x % tsx) != 0) |
613 | + Y = y/tsy - 1 + ((y % tsy) != 0) |
614 | + return X,Y |
615 | + def mousePressEvent(self, event): |
616 | + if event.button() == Qt.LeftButton: |
617 | + pos = self.giveTile(event.x(),event.y()) |
618 | + self.pressed.emit(pos) |
619 | + self._TouchStarted = pos |
620 | + def mouseReleaseEvent(self, event): |
621 | + if event.button() == Qt.LeftButton: |
622 | + x,y = self.giveTile(event.x(),event.y()) |
623 | + self.released.emit((x,y)) |
624 | + X,Y = self._TouchStarted |
625 | + if (x,y) == (X,Y): |
626 | + self.clicked.emit((x,y)) |
627 | + else: |
628 | + self.dragged.emit((X-x,Y-y)) |
629 | + self._TouchStarted = None |
630 | + def __init__(self, player, textstream, **kwargs): |
631 | + QWidget.__init__(self) |
632 | + self.qp = QPainter() |
633 | + self.textstream = textstream |
634 | + self._TouchStarted = None |
635 | + self.displayQueue = [] |
636 | + self.x_offset = 0 |
637 | + self.y_offset = 0 |
638 | + self.tilesize = (40,40) |
639 | + self.player = player |
640 | + def resizeEvent(self, event): |
641 | + rect = self.rect() |
642 | + self.textstream.append( 'Display window:\t' + `rect.width()` + "x" + `rect.height()`) |
643 | + def _showtile(self, tile, event): |
644 | + from _clickableIcon import clickableIcon |
645 | + for subtile in tile.contents: |
646 | + self._showTile(subtile, event) |
647 | + if tile.image: |
648 | + image = clickableIcon(self, tile.image) |
649 | + x,y = tile.position |
650 | + X,Y = self.tilesize |
651 | + image.setRect(x*X, y*Y, X, Y) |
652 | + image.paintEvent(event) |
653 | + def paintEvent(self, event): |
654 | + self.qp = QPainter() |
655 | + c = (QColor("#121"), |
656 | + QColor("#101")) |
657 | + brush = QBrush(Qt.SolidPattern) |
658 | + rect = self.rect() |
659 | + self.qp.begin(self) |
660 | + self.qp.setBrush(brush) |
661 | + currlevel = self.player.container |
662 | + currworld = currlevel.container |
663 | + otherlevels = ( level |
664 | + for level |
665 | + in currworld.contents |
666 | + if type(level) == type(currlevel) |
667 | + and level != currlevel) |
668 | + for tile in currlevel.contents: |
669 | + self._showtile(tile, event) |
670 | + self.qp.end() |
671 | + QWidget.paintEvent(self, event) |
672 | + self.textstream.append("Drawing") |
673 | \ No newline at end of file |
674 | |
675 | === added file '_Display/_Interface.py' |
676 | --- _Display/_Interface.py 1970-01-01 00:00:00 +0000 |
677 | +++ _Display/_Interface.py 2011-01-14 17:58:52 +0000 |
678 | @@ -0,0 +1,114 @@ |
679 | +from PyQt4.QtGui import (QGridLayout, |
680 | + QWidget, |
681 | + QColor, |
682 | + QPainter, |
683 | + QBrush) |
684 | + |
685 | +from PyQt4.QtCore import Qt |
686 | +import os.path |
687 | +class Interface(QWidget): |
688 | + def toggleFullscreen(self): |
689 | + p = self.parent |
690 | + if p.isFullScreen(): |
691 | + p.setWindowState(Qt.WindowNoState) |
692 | + else: |
693 | + p.setWindowState(Qt.WindowFullScreen) |
694 | + def move_up(self): |
695 | + self.player.commands.add(self.player,'up') |
696 | + def move_down(self): |
697 | + self.player.commands.add(self.player,'down') |
698 | + def move_left(self): |
699 | + self.player.commands.add(self.player,'left') |
700 | + def move_right(self): |
701 | + self.player.commands.add(self.player,'right') |
702 | + def set_attack(self,bool_in): |
703 | + self.attackmode = bool_in |
704 | + def set_move(self,bool_in): |
705 | + self.movemode = bool_in |
706 | + def handleDisplayDragged(self, pos): |
707 | + self.textstream.append('screen dragged by: '+`pos`) |
708 | + def handleDisplayClicked(self, pos): |
709 | + if self.attackmode: |
710 | + self.player.commands.add(self.player,'attack',pos) |
711 | + self.B_ATTK.toggle() |
712 | + elif self.movemode: |
713 | + self.player.commands.add(self.player,'move',pos) |
714 | + self.B_MOVE.toggle() |
715 | + else: |
716 | + self.textstream.append('screen clicked at: '+`pos`) |
717 | + |
718 | + def __init__(self, player, parent, textstream, **kwargs): |
719 | + QWidget.__init__(self) |
720 | + |
721 | + def mkbutton(y,x,h=1,w=1,image=None,act=None,toggle=False): |
722 | + from _interfaceButton import interfaceButton |
723 | + if image: |
724 | + b = interfaceButton(self, "_Display/Buttons/"+image+".png") |
725 | + else: |
726 | + b = interfaceButton(self) |
727 | + self.OptionsGrid.addWidget(b,y,x,h,w) |
728 | + if act: |
729 | + if toggle: |
730 | + b.setCheckable(True) |
731 | + b.toggled.connect(act) |
732 | + else: |
733 | + b.clicked.connect(act) |
734 | + return b |
735 | + |
736 | + self.qp = QPainter() |
737 | + self.OptionsGrid = QGridLayout(self) |
738 | + self.parent = parent |
739 | + self.player = player |
740 | + self.textstream = textstream |
741 | + self.height = 32 |
742 | + self.margin = 4 |
743 | + self.spacing = 8 |
744 | + self.attackmode = False |
745 | + self.movemode = False |
746 | + |
747 | + self.OptionsGrid.setMargin(self.margin) |
748 | + self.OptionsGrid.setSpacing(self.spacing) |
749 | + |
750 | + self.parent.MainGraphicView.clicked.connect(self.handleDisplayClicked) |
751 | + self.parent.MainGraphicView.dragged.connect(self.handleDisplayDragged) |
752 | + |
753 | + if True: #Spawn buttons |
754 | + self.B_ATTK = mkbutton(0,0,1,1,"Attack", self.set_attack,True) |
755 | + self.B_MVUP = mkbutton(0,1,1,1,"up", self.move_up) |
756 | + self.B_MOVE = mkbutton(0,2,1,1,"Move", self.set_move,True) |
757 | + self.B_0__3 = mkbutton(0,3) |
758 | + self.B_0__4 = mkbutton(0,4) |
759 | + self.B_0__5 = mkbutton(0,5) |
760 | + self.B_0__6 = mkbutton(0,6) |
761 | + self.B_0__7 = mkbutton(0,7) |
762 | + self.B_MVLT = mkbutton(1,0,1,1,"left", self.move_left) |
763 | + self.B_MVDN = mkbutton(1,1,1,1,"down", self.move_down) |
764 | + self.B_MVRT = mkbutton(1,2,1,1,"right", self.move_right) |
765 | + self.B_1__3 = mkbutton(1,3) |
766 | + self.B_1__4 = mkbutton(1,4) |
767 | + self.B_1__5 = mkbutton(1,5) |
768 | + self.B_1__6 = mkbutton(1,6) |
769 | + self.B_1__7 = mkbutton(1,7) |
770 | + self.B_QUIT = mkbutton(0,12,2,2,"close", self.parent.close) |
771 | + self.B_FULL = mkbutton(0,14,2,2,"fullscr",self.toggleFullscreen) |
772 | + self.rowcount = self.OptionsGrid.rowCount() |
773 | + self.setFixedHeight(self.height*self.rowcount + |
774 | + self.margin*2 + |
775 | + self.spacing*(self.rowcount-1)) |
776 | + def resizeEvent(self, event): |
777 | + rect = self.rect() |
778 | + self.textstream.append( 'Interface:\t\t' + |
779 | + `rect.width()` + |
780 | + "x" + |
781 | + `rect.height()`) |
782 | + def paintEvent(self, event): |
783 | + #print "Painting options" |
784 | + charcoal = QColor("#101010") |
785 | + black = QColor("#000000") |
786 | + brush = QBrush(Qt.SolidPattern) |
787 | + rect = self.rect() |
788 | + self.qp.begin(self) |
789 | + self.qp.setBrush(brush) |
790 | + self.qp.fillRect(rect, charcoal) |
791 | + self.qp.end() |
792 | + |
793 | |
794 | === added file '_Display/__init__.py' |
795 | --- _Display/__init__.py 1970-01-01 00:00:00 +0000 |
796 | +++ _Display/__init__.py 2011-01-14 17:58:52 +0000 |
797 | @@ -0,0 +1,4 @@ |
798 | +from _DisplayObject import DisplayObject |
799 | +from _DisplayWindow import DisplayWindow |
800 | +from _Interface import Interface |
801 | +from _DebugOutput import DebugOutput |
802 | \ No newline at end of file |
803 | |
804 | === added file '_Display/_clickableIcon.py' |
805 | --- _Display/_clickableIcon.py 1970-01-01 00:00:00 +0000 |
806 | +++ _Display/_clickableIcon.py 2011-01-14 17:58:52 +0000 |
807 | @@ -0,0 +1,29 @@ |
808 | +from PyQt4.QtGui import QPushButton, QBrush, QIcon |
809 | +from PyQt4.QtCore import Qt, QRect |
810 | + |
811 | +class clickableIcon(QPushButton): |
812 | + def paintEvent(self, event): |
813 | + r = QRect(self.x, self.y, self.w, self.h) |
814 | + self.image.paint(self.qp, r) |
815 | + def setRect(self,x,y,w,h): |
816 | + r = self.rect() |
817 | + self.x = x |
818 | + self.y = y |
819 | + self.w = w |
820 | + self.h = h |
821 | + r.setRect(x,y,w,h) |
822 | + self.setGeometry(r) |
823 | + def centre(self): |
824 | + r = self.rect() |
825 | + return (r.x()+r.width()/2, r.y()+r.height()/2) |
826 | + def __init__(self,parent,image): |
827 | + QPushButton.__init__(self) |
828 | + self.image = QIcon() |
829 | + self.qp = parent.qp |
830 | + self.x = 0 |
831 | + self.y = 0 |
832 | + self.w = 0 |
833 | + self.h = 0 |
834 | + self.imagename = "_Display/Sprites/"+image+".png" |
835 | + self.image.addFile(self.imagename) |
836 | + #self.move(x,y) translates the sprite's rectangle |
837 | \ No newline at end of file |
838 | |
839 | === added file '_Display/_interfaceButton.py' |
840 | --- _Display/_interfaceButton.py 1970-01-01 00:00:00 +0000 |
841 | +++ _Display/_interfaceButton.py 2011-01-14 17:58:52 +0000 |
842 | @@ -0,0 +1,51 @@ |
843 | +from PyQt4.QtGui import (QColor, |
844 | + QPainter, |
845 | + QIcon, |
846 | + QImage, |
847 | + QBrush, |
848 | + QPushButton, |
849 | + QLabel, |
850 | + QSizePolicy, |
851 | + QKeySequence) |
852 | +from PyQt4.QtCore import (QString, |
853 | + QSize, |
854 | + Qt) |
855 | +import os.path |
856 | +class interfaceButton(QPushButton): |
857 | + def paintEvent_(self, event): |
858 | + black = QColor("#000000") |
859 | + charcoal = QColor("#101010") |
860 | + orange = QColor("#F08038") |
861 | + if self.isDown() or (self.isChecked() and self.isCheckable()): |
862 | + background = orange |
863 | + else: |
864 | + background = black |
865 | + brush = QBrush(Qt.SolidPattern) |
866 | + self.qp.begin(self) |
867 | + self.qp.setBrush(brush) |
868 | + self.qp.fillRect(self.rect(), background) |
869 | + self.image.paint(self.qp, self.rect(), state=QIcon.On) |
870 | + self.qp.end() |
871 | + def paintEvent__(self, event): |
872 | + QPushButton.paintEvent(self, event) |
873 | + pass |
874 | + def __init__(self, parent, display='', shortcut=None): |
875 | + QPushButton.__init__(self) |
876 | + self.parent = parent |
877 | + self.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding) |
878 | + try: |
879 | + assert os.path.isfile(display) |
880 | + self.imagename = display |
881 | + self.image = QIcon() |
882 | + self.image.addFile(display) |
883 | + self.image.sizeHint = self.sizeHint |
884 | + self.qp = parent.qp |
885 | + self.paintEvent = self.paintEvent_ |
886 | + self.setFlat(True) |
887 | + except: |
888 | + self.setText(display) |
889 | + if display=='': |
890 | + self.setFlat(True) |
891 | + self.paintEvent = self.paintEvent__ |
892 | + if shortcut: |
893 | + self.setShortcut(QKeySequence(shortcut)) |
894 | \ No newline at end of file |
895 | |
896 | === added file '_Display/pyrpg.png' |
897 | Binary files _Display/pyrpg.png 1970-01-01 00:00:00 +0000 and _Display/pyrpg.png 2011-01-14 17:58:52 +0000 differ |
898 | === added file 'layered.ico' |
899 | Binary files layered.ico 1970-01-01 00:00:00 +0000 and layered.ico 2011-01-14 17:58:52 +0000 differ |
900 | === modified file 'pyrpg.py' |
901 | --- pyrpg.py 2010-11-22 06:47:41 +0000 |
902 | +++ pyrpg.py 2011-01-14 17:58:52 +0000 |
903 | @@ -1,20 +1,76 @@ |
904 | -from GameObjects import GameObject, Containable, World, Weapon |
905 | +#!/usr/bin/python |
906 | +# |
907 | +from GameObjects import GameObject, World, Level, Weapon, Character, Containable |
908 | +from Display import DisplayObject |
909 | +from Levels import worlds |
910 | +from Levels import objects |
911 | +def setupTile(x, y, tile, thisLevel, Game): |
912 | + cont = thisLevel |
913 | + if tile.flag != objects.Out.flag: |
914 | + if tile.flag(objects.Floor.flag):# This needs to not be collision-tested |
915 | + Containable(flag=tile.flag, container=cont, position=(x,y), name="Floor@%s"%(`(x,y)`), image=tile.image) |
916 | + if tile.flag(objects.Wall.flag): # This needs to be indestructable |
917 | + Containable(flag=tile.flag, container=cont, position=(x,y), name="Wall@%s"%(`(x,y)`), image=tile.image) |
918 | + if tile.flag(objects.Door.flag): # This needs to link levels |
919 | + Containable(flag=tile.flag, container=cont, position=(x,y), name="Door@%s"%(`(x,y)`), image=tile.image) |
920 | + if tile.flag(objects.Player.flag): |
921 | + Game.Player = Character(flag=tile.flag, container=cont, position=(x,y), name="Player 1", image=tile.image) |
922 | + # if tile.flag(objects.Box.flag): # Not implemented yet |
923 | + # print "Adding a box","at %s"%(`(x,y)`) |
924 | + # if tile.flag(objects.Resource.flag):# Not implemented yet |
925 | + # print "Adding a resource stash","at %s"%(`(x,y)`) |
926 | + # if tile.flag(objects.Friend.flag): # Not implemented yet |
927 | + # print "Adding a friend","at %s"%(`(x,y)`) |
928 | + # if tile.flag(objects.Enemy.flag): # Not implemented yet |
929 | + # print "Adding an enemy","at %s"%(`(x,y)`) |
930 | + # if tile.flag(objects.Neutral.flag): # Not implemented yet |
931 | + # print "Adding a neutral party","at %s"%(`(x,y)`) |
932 | + # if tile.flag(objects.Book.flag): # Not implemented yet |
933 | + # print "Adding a book","at %s"%(`(x,y)`) |
934 | + # if tile.flag(objects.Scroll.flag): # Not implemented yet |
935 | + # print "Adding a scroll","at %s"%(`(x,y)`) |
936 | + # if tile.flag(objects.HPotion.flag): # Not implemented yet |
937 | + # print "Adding a health potion","at %s"%(`(x,y)`) |
938 | + # if tile.flag(objects.MPotion.flag): # Not implemented yet |
939 | + # print "Adding a mana potion","at %s"%(`(x,y)`) |
940 | + # if tile.flag(objects.Dagger.flag): # Not implemented yet |
941 | + # print "Adding a dagger","at %s"%(`(x,y)`) |
942 | + # if tile.flag(objects.Bow.flag): # Not implemented yet |
943 | + # print "Adding a bow","at %s"%(`(x,y)`) |
944 | + # if tile.flag(objects.Axe.flag): # Not implemented yet |
945 | + # print "Adding an axe","at %s"%(`(x,y)`) |
946 | + if tile.flag(objects.Shield.flag): |
947 | + Weapon(flag=tile.flag, container=cont, position=(x,y), name="Sheild@%s"%(`(x,y)`), image=tile.image) |
948 | + if tile.flag(objects.Sword.flag): |
949 | + Weapon(flag=tile.flag, container=cont, position=(x,y), name="Sword@%s"%(`(x,y)`), image=tile.image) |
950 | + return cont |
951 | + |
952 | + |
953 | +def setupGame(): |
954 | + Game = GameObject(flag=objects.Out.flag, name="Game") |
955 | + DisplayList = [] |
956 | + |
957 | + wn = 0 |
958 | + for world in worlds: |
959 | + thisWorld = World(flag=objects.Out.flag, container=Game, name="World_%s"%(`wn`)) |
960 | + ln = 0 |
961 | + for level in world: |
962 | + thisLevel = Level(flag=objects.Out.flag, container=thisWorld, name="Level_%s.%s"%(`wn`,`ln`)) |
963 | + x,y = 0,0 |
964 | + for line in level: |
965 | + for tile in line: |
966 | + if type(tile) == type(tuple()): |
967 | + cont = thisLevel |
968 | + for item in tile: |
969 | + cont = setupTile(x, y, item, cont, Game) |
970 | + else: |
971 | + setupTile(x, y, tile, thisLevel, Game) |
972 | + x += 1 |
973 | + x = 0 |
974 | + y += 1 |
975 | + wn += 1 |
976 | + return Game |
977 | if __name__ == "__main__": |
978 | - print '\n'*100 |
979 | - Game = GameObject(name="Game") |
980 | - w1 = World(container=Game, name="World1") |
981 | - w2 = World(container=Game, name="World2") |
982 | - W1 = Weapon(container=w1, name="Weapon1") |
983 | - print "W2" |
984 | - W2 = Weapon(container=w2, name="Weapon2") |
985 | - print '\n'*100 |
986 | - Objects = Game.getAllSameClass() |
987 | - for Object in Objects: |
988 | - if len(Object.contents): |
989 | - print `Object.name`, "contains:\n\t", ', '.join([`x.name` for x in Object]) |
990 | - else: |
991 | - print `Object.name`, "is empty." |
992 | - if hasattr(Object, 'container'): |
993 | - print `Object.name`, "contained by", `Object.container.name`+'.' |
994 | - else: |
995 | - print `Object.name`, "has no container." |
996 | \ No newline at end of file |
997 | + Game = setupGame() |
998 | + d = DisplayObject(Game) |
999 | + d.exec_() |
Looks like there's a bit of feature-creep towards 0.4, but everything looks to be present. It's hard to really test this thoroughly without more features...