Advertisement
ada1711

Untitled

Mar 15th, 2023
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 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.reset_position()
  12.  
  13. # resetting position
  14. def reset_position(self):
  15. self.position = pygame.Rect(
  16. SCREEN_WIDTH/2-70, SCREEN_HEIGHT-100, 140, 30)
  17.  
  18. # moving the platform
  19. def move_platform(self, value):
  20. speed = 10
  21. self.position.move_ip(value*speed, 0)
  22. if self.position.left <= 0:
  23. self.position.x = 0
  24. if self.position.right >= SCREEN_WIDTH:
  25. self.position.x = SCREEN_HEIGHT-140
  26.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement