ada1711

Untitled

Mar 16th, 2023
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. import pygame
  2.  
  3. SCREEN_WIDTH = 1024
  4. SCREEN_HEIGHT = 800
  5.  
  6.  
  7. class Platform(pygame.sprite.Sprite):
  8. def __init__(self):
  9. super(Platform, self).__init__()
  10. self.image = pygame.image.load("images/pad.png")
  11. self.moving = 0
  12. self.reset_position()
  13.  
  14. # resetting position
  15. def reset_position(self):
  16. self.position = pygame.Rect(
  17. SCREEN_WIDTH/2-70, SCREEN_HEIGHT-100, 140, 30)
  18.  
  19. # moving the platform
  20. def move_platform(self, value):
  21. speed = 10
  22. self.position.move_ip(value*speed, 0)
  23. self.moving = value
  24. if self.position.left <= 0:
  25. self.position.x = 0
  26. if self.position.right >= SCREEN_WIDTH:
  27. self.position.x = SCREEN_HEIGHT-140
  28.  
  29. # update
  30. def update(self):
  31. self.moving = 0
  32.  
Add Comment
Please, Sign In to add comment