Пример #1
0
	def __init__(self, screeen):
		#initialize game engine, pygame surfaces etc
		self.screen = screeen
		self.background = pygame.Surface([SCREEN_W,SCREEN_H])
		self.background = self.background.convert()
		self.background_tools = pygame.Surface([SCREEN_W,120])
		self.background_tools = self.background_tools.convert()
		bgimg = pygame.image.load(data.filepath("edtitleish_sm.jpg"))
		self.screen.blit(bgimg, (0,0))
		pygame.display.flip()
		self.clock = pygame.time.Clock()
		pygame.display.set_caption(GAME_TITLE)
		pygame.mouse.set_visible(1)
		GAME_STATE = "title"
		self.controller = edtitleController.titleController(self.screen)
Пример #2
0
	def run(self):
		#do game loop
		GAME_STATE = "title"
		GAME_SELECTION = "none"
		while(GAME_STATE != "quit"):
			self.clock.tick(60)
			#get input
			for event in pygame.event.get():
				if event.type == QUIT:
					GAME_STATE = "quit"
				elif event.type == KEYDOWN and event.key == K_ESCAPE and GAME_STATE != "title":
					GAME_STATE = "title"
				elif event.type == KEYDOWN and event.key == K_ESCAPE:
					GAME_STATE = "quit"
				elif event.type == KEYDOWN :
					tmpres = self.controller.parseKeyDown(event.key, GAME_STATE, GAME_SELECTION)
					GAME_SELECTION = tmpres[1]
					GAME_STATE = tmpres[0]
				elif event.type == KEYUP:
					GAME_STATE = self.controller.parseKeyUp(event.key, GAME_STATE)
				elif event.type == MOUSEBUTTONDOWN and GAME_STATE == "game":
					self.controller.parseMouseDown(event.pos)
			#change controller if needed
			if GAME_STATE == "game" and self.controller.function() != "game":
				self.controller = editorController.editorController(self.screen, GAME_SELECTION)
			if GAME_STATE == "title" and self.controller.function() != "title":
				self.controller = edtitleController.titleController(self.screen)
				
			#update the current controller
			self.controller.update()

			#render the current controller
			self.background.fill((0,0,0))
			self.background_tools.fill((15,15,15))
			self.screen.blit(self.background, (0,0))
			self.screen.blit(self.background_tools, (0,SCREEN_H))
			self.controller.render(self.screen)
			#flip display
			pygame.display.flip()