コード例 #1
0
    def __init__(self):
        pygame.init()
        self.screen = pygame.display.set_mode(
            SCREEN_SIZE)  # create a screen with no
        self.clock = pygame.time.Clock()

        self.info = DebugDisplayManager()
        self.event = EventManager()

        self.event.setChords('quit', (K_ESCAPE, ), (K_LCTRL, K_q))
コード例 #2
0
class GameManager():
    def __init__(self):
        pygame.init()
        self.screen = pygame.display.set_mode(
            SCREEN_SIZE)  # create a screen with no
        self.clock = pygame.time.Clock()

        self.info = DebugDisplayManager()
        self.event = EventManager()

        self.event.setChords('quit', (K_ESCAPE, ), (K_LCTRL, K_q))

    def draw(self):
        # create buffer
        dblbuff = pygame.Surface(SCREEN_SIZE)

        # draw background
        dblbuff.fill(BG_COLOR)

        # debug
        if DEBUG:
            dblbuff.blit(self.info.render(), DBG_POS)

        #update display
        self.screen.blit(dblbuff, (0, 0))
        pygame.display.flip()

    def tick(self):
        self.clock.tick(FRAME_RATE)
        self.info['FPS'] = "%f" % self.clock.get_fps()

        self.event.tick()

        self.draw()

    def quit(self):
        sys.exit()

    def run(self):
        while True:
            try:
                self.tick()

            except QuitMessage, e:
                print 'Quit Message recieved: ', e.value
                self.quit()
コード例 #3
0
class GameManager():
	def __init__(self):
		pygame.init()
		self.screen = pygame.display.set_mode(SCREEN_SIZE)  # create a screen with no
		self.clock  = pygame.time.Clock()
		
		self.info  = DebugDisplayManager()
		self.event = EventManager()
	
		self.event.setChords('quit', (K_ESCAPE,), (K_LCTRL, K_q))
	
	def draw(self):
		# create buffer
		dblbuff = pygame.Surface(SCREEN_SIZE)
		
		# draw background
		dblbuff.fill(BG_COLOR)
		
		# debug
		if DEBUG:
			dblbuff.blit(self.info.render(), DBG_POS)
		
		#update display
		self.screen.blit(dblbuff,(0,0))
		pygame.display.flip()
	
	def tick(self):
		self.clock.tick(FRAME_RATE)
		self.info['FPS'] = "%f" % self.clock.get_fps()
		
		self.event.tick()

		self.draw()
		
	def quit(self):
		sys.exit()
	
	def run(self):
		while True:
			try:
				self.tick()

			except QuitMessage, e:
				print 'Quit Message recieved: ',e.value
				self.quit()
コード例 #4
0
	def __init__(self):
		pygame.init()
		self.screen = pygame.display.set_mode(SCREEN_SIZE)  # create a screen with no
		self.clock  = pygame.time.Clock()
		
		self.info  = DebugDisplayManager()
		self.event = EventManager()
	
		self.event.setChords('quit', (K_ESCAPE,), (K_LCTRL, K_q))