Ejemplo n.º 1
0
    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)
Ejemplo n.º 2
0
 def gotInitialPlayer(self, player):
     #Hook up a PlayerView and a PlayerController for the given Player.
     self.window.submitTo(PlayerController(player))
Ejemplo n.º 3
0
    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