View difference between Paste ID: BsWspBaU and yrUkzhen
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.moving = 0
12
        self.reset_position()
13
14
    # resetting position
15
    def reset_position(self):
16-
        self.position = pygame.Rect(
16+
        self.rect = pygame.Rect(
17
            SCREEN_WIDTH/2-70, SCREEN_HEIGHT-100, 140, 30)
18
19
    # moving the platform
20-
    def move_platform(self, value):
20+
    def move_paddle(self, value):
21
        speed = 10
22-
        self.position.move_ip(value*speed, 0)
22+
        self.rect.move_ip(value*speed, 0)
23
        self.moving = value
24-
        if self.position.left <= 0:
24+
        if self.rect.left <= 0:
25-
            self.position.x = 0
25+
            self.rect.x = 0
26-
        if self.position.right >= SCREEN_WIDTH:
26+
        if self.rect.right >= SCREEN_WIDTH:
27-
            self.position.x = SCREEN_HEIGHT-140
27+
            self.rect.x = SCREEN_HEIGHT-140
28
29
    # update
30
    def update(self):
31
        self.moving = 0
32