Skip to content

Commit a8bc191

Browse files
author
4b796c65
committed
Various small changes, including Python 3.3 support
1 parent 6527844 commit a8bc191

File tree

5 files changed

+29
-7
lines changed

5 files changed

+29
-7
lines changed

CHANGELOG.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
* added a method to iterate over all coordinates of a Console
1+
* a for loop can iterate over all coordinates of a Console
22
* drawStr can be configured to scroll or raise an error
33
* You can now configure or disable key repeating with tdl.event.setKeyRepeat
44

dev/stressTest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class TestApp(tdl.event.App):
4343
def __init__(self, console):
4444
self.console = console
4545
self.writer = self.console
46-
self.console.setScrollMode('scroll')
46+
self.console.setMode('scroll')
4747
self.width, self.height = self.console.getSize()
4848
self.total = self.width * self.height
4949
self.cells = list(itertools.product(range(self.width), range(self.height)))

tdl/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@ def getSize(self):
633633
"""
634634
return self.width, self.height
635635

636-
def map(self):
636+
def __iter__(self):
637637
"""Return an iterator with every possible (x, y) value for this console.
638638
639639
It goes without saying that working on the console this way is a

tdl/__tcod.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,30 @@ def __iter__(self):
321321
KEY_PRESSED = 1
322322
KEY_RELEASED = 2
323323

324+
325+
#class char_t(Structure):
326+
# _fields_ = [('c', c_int), # character ascii code
327+
# ('cf', c_int), # character number in font
328+
# ('fore', _Color), ('back', _Color),
329+
# ('dirty', c_uint8)]
330+
331+
332+
#class TCOD_console_t(Structure):
333+
# _fields_ = [('buf', POINTER(char_t)), # current console
334+
# ('oldbuf', POINTER(char_t)), # console for last frame
335+
# ('w', c_int), ('h', c_int), # console width and height (in characters,not pixels)
336+
# ]
337+
338+
# /* default background operator for print & print_rect functions */
339+
# TCOD_bkgnd_flag_t bkgnd_flag;
340+
# /* default alignment for print & print_rect functions */
341+
# TCOD_alignment_t alignment;
342+
# /* foreground (text), background and key colors */
343+
# TCOD_color_t fore,back,key;
344+
# uint8 fade;
345+
# bool haskey; /* a key color has been defined */
346+
#} TCOD_console_data_t;
347+
324348
TCOD_console_t = c_void_p
325349

326350
_lib.TCOD_console_init_root.restype = None

tdl/event.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,6 @@ class App(object):
225225
L{tdl.flush}.
226226
"""
227227
__slots__ = ('__running', '__prevTime')
228-
__running = False
229-
__prevTime = None
230228

231229
def ev_QUIT(self, event):
232230
"""Unless overridden this method raises a SystemExit exception closing
@@ -281,7 +279,7 @@ def run(self):
281279
this function is called. And then the App can be run again.
282280
But a single App instance can not be run multiple times simultaneously.
283281
"""
284-
if self.__running:
282+
if getattr(self, '_App__running', False):
285283
raise _tdl.TDLError('An App can not be run multiple times simultaneously')
286284
self.__running = True
287285
while self.__running:
@@ -296,7 +294,7 @@ def runOnce(self):
296294
Having multiple L{App} instances and selectively calling runOnce on
297295
them is a decent way to create a state machine.
298296
"""
299-
if self.__prevTime is None:
297+
if not hasattr(self, '_App__prevTime'):
300298
self.__prevTime = time.clock() # initiate __prevTime
301299
for event in get():
302300
if event.type: # exclude custom events with a blank type variable

0 commit comments

Comments
 (0)