class GameState(Application.State): def __init__(self, app, player, world, network): self.world = world self.network = network self.player = player self.controller = PlayerController(player) Application.State.__init__(self, app) def setup(self): self.coins = CoinGroup() for coin in self.world.coins: self.coins.add_sprite(coin) self.players = PlayerGroup() for player in self.world.players: self.players.add_sprite(player) def handle_event(self, event): self.controller.handle_event(event) def update(self, dt): self.world.update(dt) self.players.update() self.coins.update() def draw(self, screen): screen.fill((80,80,80)) self.coins.draw(screen) self.players.draw(screen)
def __init__(self, app, player, world, network): self.world = world self.network = network self.player = player self.player.local = True self.controller = PlayerController(player) Application.State.__init__(self, app)
def __init__(self, app, player, world, network): self.world = world self.network = network self.player = player self.controller = PlayerController(player) Application.State.__init__(self, app)
class GameState(Application.State): def __init__(self, app, player, world, network): self.world = world self.network = network self.player = player self.player.local = True self.controller = PlayerController(player) Application.State.__init__(self, app) def setup(self): self.coins = CoinGroup() for coin in self.world.coins: self.coins.add_sprite(coin) self.players = PlayerGroup() for player in self.world.players: self.players.add_sprite(player) def handle_event(self, event): if event.type == KEYDOWN and event.key == K_ESCAPE: self.app.quit() else: self.controller.handle_event(event) def update(self, dt): self.world.update(dt) self.players.update() self.coins.update() def draw(self, screen): screen.fill((80, 80, 80)) self.coins.draw(screen) self.players.draw(screen)
def gotInitialPlayer(self, player): #Hook up a PlayerView and a PlayerController for the given Player. self.window.submitTo(PlayerController(player))
enemies.draw(screen) # Set up the game screen = pygame.display.set_mode(RESOLUTION, DOUBLEBUF | NOFRAME) screen_rect = screen.get_rect() screen_rect = np.array([screen_rect.w, screen_rect.h]) clock = pygame.time.Clock() keys = defaultdict(bool) if not SIMULATION: bufhelp.connect() score = n_shots = n_deaths = n_hits = 0 rect = screen.get_rect() ship = ShipSprite() ship_group = pygame.sprite.RenderPlain(ship) controller = ProbablisticConroller(alpha=0.5*PREDICTION_TIME) if SIMULATION else PlayerController() enemy_group = pygame.sprite.RenderPlain() bullet_group = pygame.sprite.RenderPlain() last_enemy_spawned = -ENEMY_SPAWN_TIME ship_start_pos = 0 last_pred_time = 0 left = True pygame.init() font = pygame.font.Font(pygame.font.get_default_font(), 16) lasttime = last_bullet_spawned = game_start_time = time.time() if not SIMULATION: bufhelp.sendEvent('experiment.im', 'start') while True: clock.tick(60) # 60 FPS curtime = time.time() deltatime = curtime - lasttime lasttime = curtime