Chunky by FelipeFS
Chunky by FelipeFS
GPWiki.org
It is currently Thu Aug 28, 2014 5:06 am

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Pygame OOP Framework
PostPosted: Thu Oct 03, 2013 4:11 pm 
Rookie

Joined: Thu Oct 03, 2013 12:18 pm
Posts: 1
http://content.gpwiki.org/index.php/Python:Pygame_OOP_Framework has a nice tutorial!
But I'm having an issue with mouseable that raise an error in states.py line 136.

Code Listing: Expand
...
try:
w,h = mouseable.loc[2:4]
except IndexError:
w,h = self.screen.get_width(),self.screen.get_height()
...


Looking at the line with mouseable.loc[2:4] (line 136 in states.py), loc is a tuple with 2 elements, so calling loc[2:4] it's not possible
Is this correct? Or mouseable.loc[2:4] should be replaced with mouseable.bounds[2:4]? But this would imply a modification in the Mouseable class in gui.py


Top
 Profile  
 
 Post subject: Re: Pygame OOP Framework
PostPosted: Fri Oct 04, 2013 7:38 pm 
BANNED

Joined: Sun Jun 24, 2012 12:49 am
Posts: 504
Code:
...
try:
    w,h = mouseable.loc[2:4]
except IndexError:
    w,h = self.screen.get_width(),self.screen.get_height()
...


Does

w,h = mouseable.loc[2] help anything? That's my best guess since I don't have much experience with Python :P


Top
 Profile  
 
 Post subject: Re: Pygame OOP Framework
PostPosted: Sat Oct 05, 2013 9:26 am 
Grand Optimizer

Joined: Sun Oct 16, 2011 3:09 pm
Posts: 364
Location: Here (where else?)
Given that it catches IndexError (which is what happens when you try to access non-existing fields), my guess is that an earlier version of pygame may have had more parameters, and this code fixes removal of that part, or loc can have multiple locations, eg a joy-stick or track-ball or so (and the IndexError then catches lack of having such a device).

_________________
My project: Messing about in FreeRCT, dev blog, and IRC #freerct at oftc.net


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: AHrefs Bot [Crawler] and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

Powered by phpBB® Forum Software © phpBB Group