Esempio n. 1
0
 def handle_events(self):
     pos = (0, 0)
     for event in pygame.event.get():
         if event.type == pygame.QUIT:
             GameEngine.quit()
         if event.type == pygame.MOUSEBUTTONUP:
             pos = pygame.mouse.get_pos()
     if 360 < pos[0] < 440 and 395 < pos[1] < 405:
         GameEngine.change_state(games.asteroids.Asteroids())
     elif 360 < pos[0] < 440 and 435 < pos[1] < 445:
         GameEngine.change_state(games.snake.Snake())
Esempio n. 2
0
 def handle_events(self):
     for event in pygame.event.get():
         if event.type == pygame.QUIT:
             GameEngine.quit()
     keypresses = pygame.key.get_pressed()
     if keypresses[pygame.K_UP] != 0:
         if self.direction != 90:
             self.direction = -90
     if keypresses[pygame.K_LEFT] != 0:
         if self.direction != 0:
             self.direction = 180
     if keypresses[pygame.K_RIGHT] != 0:
         if self.direction != 180:
             self.direction = 0
     if keypresses[pygame.K_DOWN] != 0:
         if self.direction != -90:
             self.direction = 90
Esempio n. 3
0
 def handle_events(self):
     for event in pygame.event.get():
         if event.type == pygame.QUIT:
             GameEngine.quit()
     keypresses = pygame.key.get_pressed()
     if keypresses[pygame.K_LEFT] != 0:
         self.ship.angle = (self.ship.angle + 5) % 360
     if keypresses[pygame.K_RIGHT] != 0:
         self.ship.angle = (self.ship.angle - 5) % 360
     if keypresses[pygame.K_UP] != 0:
         self.ship.acceleration = 6
     if self.ship.firing == 0 and keypresses[pygame.K_SPACE] != 0:
         self.ship.firing = 4
         self.ship.bullets.append(Bullet(self.ship.rect.x + 15, self.ship.rect.y + 17, self.ship.angle))
     if self.ship.warp == 0 and (keypresses[pygame.K_LSHIFT] != 0 or keypresses[pygame.K_RSHIFT] != 0):
         self.ship.warp = 20
         self.ship.rect.x = random.randint(0, GameEngine.display_width)
         self.ship.rect.y = random.randint(0, GameEngine.display_height)
Esempio n. 4
0
 def handle_events(self):
     for event in pygame.event.get():
         if event.type == pygame.QUIT:
             GameEngine.quit()