OtsoSilver

Untitled

Oct 18th, 2021
809
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #pgzero
  2. import random
  3.  
  4. WIDTH = 1000 # Ширина окна
  5. HEIGHT = 600 # Высота окна
  6.  
  7. TITLE = "Название игры" # Заголовок окна игры
  8. FPS = 30 # Количество кадров в секунду
  9. x_ball = 0
  10. y_ball = 1
  11.  
  12. enemies = []
  13. for j in range(5):
  14.     for i in range(5):
  15.         enemy = Actor('plate',topleft = (i * 200, j * 40))
  16.         enemies.append(enemy)
  17. player = Actor('hero', (500, 500))
  18. ball = Actor('ball', (500, 480))
  19. fon = Actor('fon')
  20. def draw():
  21.     fon.draw()
  22.     for enem in enemies:
  23.         enem.draw()
  24.     player.draw()
  25.     ball.draw()
  26.    
  27.    
  28.    
  29. def ball_move():
  30.     global x_ball, y_ball
  31.     ball.top -= 5 * y_ball
  32.     ball.left -= 5 * x_ball
  33.     enemy_index = ball.collidelist(enemies)
  34.     if enemy_index != -1:
  35.         y_ball = -1
  36.         enemy = enemies[enemy_index]
  37.         enemy_x_collide = (enemy.left + 75) - ball.left
  38.         x_ball = (enemy_x_collide / 75)
  39.         enemies.remove(enemy)
  40.     if ball.colliderect(player):
  41.         player_collide = (player.left + 75) - ball.left
  42.         y_ball = 1
  43.         x_ball = (player_collide / 75)
  44.  
  45. def update(dt):
  46.     ball_move()
  47.  
  48.  
  49. def on_mouse_move(pos):
  50.     player.pos = (pos[0], 500)
  51.    
RAW Paste Data