Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pygame
- SCREEN_WIDTH = 1024
- SCREEN_HEIGHT = 800
- class Paddle(pygame.sprite.Sprite):
- def __init__(self):
- super(Paddle, self).__init__()
- self.image = pygame.image.load("images/pad.png")
- self.moving = 0
- self.reset_position()
- # resetting position
- def reset_position(self):
- self.rect = pygame.Rect(
- SCREEN_WIDTH/2-70, SCREEN_HEIGHT-100, 140, 30)
- # moving the platform
- def move_paddle(self, value):
- speed = 10
- self.rect.move_ip(value*speed, 0)
- self.moving = value
- if self.rect.left <= 0:
- self.rect.x = 0
- if self.rect.right >= SCREEN_WIDTH:
- self.rect.x = SCREEN_HEIGHT-140
- # update
- def update(self):
- self.moving = 0
Add Comment
Please, Sign In to add comment