@@ -165,14 +165,12 @@ def _normalizeRect(self, x, y, width, height):
165165 height = self .height - y
166166 assert isinstance (width , int ), 'width must be an integer or None, got %s' % repr (width )
167167 assert isinstance (height , int ), 'height must be an integer or None, got %s' % repr (height )
168- if width < 0 : # if width or height are backwards then flip them
169- x += width
170- width = abs (width )
171- if height < 0 :
172- y += height
173- height = abs (height )
168+
169+ assert width >= 0 and height >= 0 , 'width and height cannot be negative'
170+ # later idea, negative numbers work like Python list indexing
171+
174172 assert x >= 0 and y >= 0 and x + width <= self .width and y + height <= self .height , \
175- 'Rect is out of bounds at (x=%i y=%i width=%i height=%i), Console bounds are (width=%i, height=%i)' % old + self .getSize ()
173+ 'Rect is out of bounds at (x=%i y=%i width=%i height=%i), Console bounds are (width=%i, height=%i)' % ( old + self .getSize () )
176174 return x , y , width , height
177175
178176 def _rectInBounds (self , x , y , width , height ):
@@ -235,9 +233,6 @@ def blit(self, source, x=0, y=0, width=None, height=None, srcx=0, srcy=0):
235233 if height == None :
236234 height = min (self .height - y , source .height - srcy )
237235
238- # _normalizeRect will break negative values in this case, so enforce
239- # an assert on positive numbers in this one case
240- assert width >= 0 and height >= 0 , 'width and height cannot be negative'
241236 x , y , width , height = self ._normalizeRect (x , y , width , height )
242237 srcx , srcy , width , height = source ._normalizeRect (srcx , srcy , width , height )
243238
@@ -433,11 +428,12 @@ def drawRect(self, x, y, width, height, string=None, fgcolor=(255, 255, 255), bg
433428 height. If width or height are None then it will extend to the edge
434429 of the console. The rest are the same as drawChar.
435430 """
436- assert self ._drawable (x , y )
437- if not self ._rectInBounds (x , y , width , height ):
438- raise TDLError ('Rectange is out of bounds at (x=%i, y=%i, width=%s, height=%s), bounds are (%i, %i)' %
439- ((x , y , width , height ) + self .getSize ()))
440- x , y , width , height = self ._clampRect (x , y , width , height ) # fill in width height
431+ #assert self._drawable(x, y)
432+ #if not self._rectInBounds(x, y, width, height):
433+ # raise TDLError('Rectange is out of bounds at (x=%i, y=%i, width=%s, height=%s), bounds are (%i, %i)' %
434+ # ((x, y, width, height) + self.getSize()))
435+ #x, y, width, height = self._clampRect(x, y, width, height) # fill in width height
436+ x , y , width , height = self ._normalizeRect (x , y , width , height )
441437 assert _verify_colors (fgcolor , bgcolor )
442438 fgcolor , bgcolor = _formatColor (fgcolor ), _formatColor (bgcolor )
443439 char = _formatChar (string )
@@ -450,11 +446,12 @@ def drawFrame(self, x, y, width, height, string=None, fgcolor=(255, 255, 255), b
450446 # hardcode alpha settings for now
451447 #bgblend=1
452448
453- if not self ._rectInBounds (x , y , width , height ):
454- raise TDLError ('Frame is out of bounds at (x=%i, y=%i, width=%i, height=%i), bounds are (width=%i, height=%i)' %
455- ((x , y , width , height ) + self .getSize ()))
449+ # if not self._rectInBounds(x, y, width, height):
450+ # raise TDLError('Frame is out of bounds at (x=%i, y=%i, width=%i, height=%i), bounds are (width=%i, height=%i)' %
451+ # ((x, y, width, height) + self.getSize()))
456452
457- x , y , width , height = self ._clampRect (x , y , width , height ) # fill in width height
453+ #x, y, width, height = self._clampRect(x, y, width, height) # fill in width height
454+ x , y , width , height = self ._normalizeRect (x , y , width , height )
458455 assert _verify_colors (fgcolor , bgcolor )
459456 fgcolor , bgcolor = _formatColor (fgcolor ), _formatColor (bgcolor )
460457 char = _formatChar (string )
@@ -572,8 +569,7 @@ def init(width, height, title='TDL', fullscreen=False, renderer='SDL'):
572569 RENDERERS = {'GLSL' : 0 , 'OPENGL' : 1 , 'SDL' : 2 }
573570 global _rootinitialized , _rootconsole
574571 if not _fontinitialized : # set the default font to the one that comes with tdl
575- setFont (_unpackfile ('terminal.png' ),
576- width = 16 , height = 16 , colomn = True )
572+ setFont (_unpackfile ('terminal.png' ), 16 , 16 , colomn = True )
577573
578574 if renderer .upper () not in RENDERERS :
579575 raise TDLError ('No such render type "%s", expected one of "%s"' % (renderer , '", "' .join (RENDERERS )))
@@ -615,13 +611,13 @@ def flush():
615611 #event._eventsflushed = False
616612 _lib .TCOD_console_flush ()
617613
618- def setFont (path , width , height , colomn = False , greyscale = False , altLayout = False ):
614+ def setFont (path , tileWidth , tileHeight , colomn = False , greyscale = False , altLayout = False ):
619615 """Changes the font to be used for this session
620616 This should be called before tdl.init
621617
622618 path - must be a string for where a bitmap file is found.
623619
624- width, height - is the size of an individual tile.
620+ tileWidth, tileHeight - is the size of an individual tile.
625621
626622 colomn - defines if the characer order goes along the rows or colomns. It
627623 should be True if the codes are 0-15 in the first column. And should be
@@ -654,7 +650,7 @@ def setFont(path, width, height, colomn=False, greyscale=False, altLayout=False)
654650 # path = path.name # if given a file just grab the path from the obj
655651 if not os .path .exists (path ):
656652 raise TDLError ('no file exists at: "%s"' % path )
657- _lib .TCOD_console_set_custom_font (_format_string (path ), flags , width , height )
653+ _lib .TCOD_console_set_custom_font (_format_string (path ), flags , tileWidth , tileHeight )
658654
659655def getFullscreen ():
660656 """Returns if the window is fullscreen
@@ -708,15 +704,15 @@ def screenshot(file=None):
708704 else :
709705 raise TypeError ('fileobj is an invalid type: %s' % type (fileobj ))
710706
711- def setFPS (fps ):
712- """Set the frames per second .
707+ def setFPS (frameRate ):
708+ """Set the frame rate .
713709
714710 You can set this to have no limit by using 0.
715711 """
716- if fps is None :
717- fps = 0
718- assert isinstance (fps , int ), 'fps must be an integer or None, got: %s' % repr (fps )
719- _lib .TCOD_sys_set_fps (fps )
712+ if frameRate is None :
713+ frameRate = 0
714+ assert isinstance (frameRate , int ), 'frameRate must be an integer or None, got: %s' % repr (frameRate )
715+ _lib .TCOD_sys_set_fps (frameRate )
720716
721717def getFPS ():
722718 """Return the current frames per second of the running program.
0 commit comments