View difference between Paste ID: 5VkEbUJ9 and jKbzj023
SHOW: | | - or go back to the newest paste.
1
import pygame
2
3
SCREEN_WIDTH = 1024
4
SCREEN_HEIGHT = 800
5
6
7-
class Platform(pygame.sprite.Sprite):
7+
class Paddle(pygame.sprite.Sprite):
8
    def __init__(self):
9-
        super(Platform, self).__init__()
9+
        super(Paddle, 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(
15+
        self.rect = pygame.Rect(
16
            SCREEN_WIDTH/2-70, SCREEN_HEIGHT-100, 140, 30)
17
18-
    # moving the platform
18+
    # moving the paddle
19-
    def move_platform(self, value):
19+
    def move_paddle(self, value):
20
        speed = 10
21-
        self.position.move_ip(value*speed, 0)
21+
        self.rect.move_ip(value*speed, 0)
22-
        if self.position.left <= 0:
22+
        if self.rect.left <= 0:
23-
            self.position.x = 0
23+
            self.rect.x = 0
24-
        if self.position.right >= SCREEN_WIDTH:
24+
        if self.rect.right >= SCREEN_WIDTH:
25-
            self.position.x = SCREEN_HEIGHT-140
25+
            self.rect.x = SCREEN_HEIGHT-140
26