Python and PyGame are cross-platform, although we had some issues running it on OSX (which we fixed–kinda).
One of my additions was to randomize the block sizes. Here is a bit of code that did that:
class block(scroller): def __init__(self, y): scroller.__init__(self) self.side1 = random.randint(20,100) self.side2 = 20 self.dimensions = random.choice([(self.side1,self.side2),(self.side2,self.side1)]) self.image = pygame.Surface(self.dimensions) self.rect = self.image.get_rect() self.y = y pygame.draw.rect(self.image, (28,55,183), self.rect) self.rect.right = pygame.display.get_surface().get_width() self.rect.centery = y ...
You can see one of Python’s cool built-in methods at work: random.choice(…). This method randomly returns one of the options passed in to it. Here, I’m using it to determine if a block will be wide or tall.
Pygame is also used in the code snippet above. pygame.surface(…) prepares an image object, which pygame.draw.rect(…) then draws on the page.
See all our changes here: http://github.com/dhatch/PyRunner/pull/4