def __init__(self): #Pygame init pygame.init() #Posicion de la ventana os.environ['SDL_VIDEO_WINDOW_POS'] = str(500) + "," + str(200) self.screen = pygame.display.set_mode((800, 600)) self.currentScene = GameScene(self.screen)
def __init__(self): #Pygame init pygame.init() #Posicion de la ventana os.environ['SDL_VIDEO_WINDOW_POS'] = str(500) + "," + str(200) self.screen = pygame.display.set_mode((800,600)) self.currentScene=GameScene(self.screen)
def __init__(self): self.width = WINDOW_SIZE[0] self.height = WINDOW_SIZE[1] self.win = pygame.display.set_mode((self.width, self.height)) pygame.display.set_caption("Maze") self.running = True self.scenes = { "main_menu": MainMenuScene(self), "exit_scene": ExitScene(self), "in_game_exit_scene": InGameExitMenu(self), "select_level": SelectLevelScene(self), "game_scene": GameScene(self), "win_scene": WinScene(self), "instruction_scene": InstructionScene(self), } self.current_scene_name = "main_menu" self.current_scene = self.scenes["main_menu"] self.current_map = None self.next_level_filename = "" self.clock = pygame.time.Clock()
def play(self, level): # Display intro screen start_scene = StartScene(self.renderer) result = start_scene.run() if result not in ('quit'): # Display the main game screen game_scene = GameScene(self.renderer) result = game_scene.run(level - 1) if result in ('infected', 'died'): gameover_scene = GameOverScene(self.renderer, result) return gameover_scene.run() elif result in ('victory'): victory_scene = VictoryScene(self.renderer) return victory_scene.run() else: return result
def __init__(self): D = Director() GS = GameScene(D) MS = MenuScene(D) SGS = StandardGameScene(D) MGS = MultiplayerGameScene(D) D.add_scene(MS,'menu') D.add_scene(GS,'game') D.add_scene(SGS,'standardGame') D.add_scene(MGS,'multiplayerGame') D.change_scene('menu') D.run()
class PyGame: def __init__(self): #Pygame init pygame.init() #Posicion de la ventana os.environ['SDL_VIDEO_WINDOW_POS'] = str(500) + "," + str(200) self.screen = pygame.display.set_mode((800,600)) self.currentScene=GameScene(self.screen) #Main loop. Delegates everything on running scene def MainLoop(self): #Main loop clock=pygame.time.Clock() loop=True FPS=30 second=float(1000) while loop: delta=clock.tick(FPS)/second for event in pygame.event.get(): self.currentScene.processInput(event) if event.type == pygame.QUIT: sys.exit() if event.type == pygame.KEYDOWN and event.key==pygame.K_ESCAPE: sys.exit() self.currentScene.update(delta) self.currentScene.draw(self.screen)
class MainGame: def __init__(self): pygame.init() self.screen = pygame.display.set_mode((956, 560), FLAGS, 32) self.current_scene = GameScene((956, 560)) def run(self): clock = pygame.time.Clock() while True: self.handle_events() self.update() self.draw() time_passed = clock.tick(30) def draw(self): self.current_scene.draw() pygame.display.update() def handle_events(self): for event in pygame.event.get(): if event.type == pygame.QUIT: exit(0) keys = pygame.key.get_pressed() if keys[K_ESCAPE]: exit(0) self.current_scene.handle_events() def update(self): self.current_scene.update()
class PyGame: def __init__(self): #Pygame init pygame.init() #Posicion de la ventana os.environ['SDL_VIDEO_WINDOW_POS'] = str(500) + "," + str(200) self.screen = pygame.display.set_mode((800, 600)) self.currentScene = GameScene(self.screen) #Main loop. Delegates everything on running scene def MainLoop(self): #Main loop clock = pygame.time.Clock() loop = True FPS = 30 second = float(1000) while loop: delta = clock.tick(FPS) / second for event in pygame.event.get(): self.currentScene.processInput(event) if event.type == pygame.QUIT: sys.exit() if event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE: sys.exit() self.currentScene.update(delta) self.currentScene.draw(self.screen)
def on_game_start(): director.replace(GameScene())
import cocos import scenes.GameScene as GameScene if __name__ == "__main__": cocos.director.director.init(caption="Planetor") scene = cocos.scene.Scene(GameScene.GameLayer()) cocos.director.director.run(scene)
neighbors = get_neighbors(old_life) new_life = create_life(old_life, neighbors) for coordinate in new_life: life.append(Cell(coordinate)) return life gamestate = Game() from life import Cell, create_life, get_neighbors from scenes import GameScene, TitleScene title = TitleScene((50, 50, 200)) game = GameScene((150, 150, 150)) pause = GameScene((150, 150, 150)) exit = GameScene((150, 150, 150)) states = {} states['title'] = title states['game'] = game states['pause'] = pause states['exit'] = exit def event_handler(state): for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit() sys.exit()
def __init__(self): pygame.init() self.screen = pygame.display.set_mode((956, 560), FLAGS, 32) self.current_scene = GameScene((956, 560))