def SetMessage(self, msg="Game"): self.msgSurfaceObj = self.fontObj.render(msg, False, Colors.blue()) self.msgRectobj = self.msgSurfaceObj.get_rect() self.msgRectobj.topleft = (self.width + 4, 0) # Clear previous msg self.surface.fill(Colors.white(), self.msgRectobj) self.surface.blit(self.msgSurfaceObj, self.msgRectobj)
def update(self): delta = self.clock.tick(60) self.delta = delta / 1000 self.mouse_pos = pygame.mouse.get_pos() for event in pygame.event.get(): if event.type == MOUSEBUTTONUP and event.button == 1 and self.left_mouse_pressed: self.left_mouse_pressed = False self.particle_manager.generate_particles( self.mouse_string.startpos, self.mouse_pos) self.mouse_string = None if event.type == MOUSEBUTTONDOWN and event.button == 1: self.mouse_string = MouseString(self.mouse_pos, Colors.white()) self.left_mouse_pressed = True if event.type == QUIT: self.exitflag = True elif event.type == KEYDOWN: if event.key == K_ESCAPE: self.exitflag = True self.particle_manager.update(xmax, ymax, self.delta)
from colors import Colors import gflags import pygame import Queue import sys import threading from pygame.locals import * from memoized import * import world_rules FLAGS = gflags.FLAGS BACKGROUND = Colors.white() class Error(Exception): """General error.""" class NoNeighbor(Error): """Raised if square has no neighbor in the indicated direction.""" class OutsideWorld(Error): """Raised if neighbor would be outside the known world.""" class World(object):