View difference between Paste ID: GRzDf6EF and NsENLX3a
SHOW: | | - or go back to the newest paste.
1
import pygame
2
3-
from Platform import Platform
3+
from paddle import Paddle
4
5
# height and width of the screen
6
SCREEN_WIDTH = 1024
7
SCREEN_HEIGHT = 800
8
# pygame settings
9
pygame.init()
10
11
# display, clock and background objects
12
display = pygame.display.set_mode([SCREEN_WIDTH, SCREEN_HEIGHT])
13
clock = pygame.time.Clock()
14
background_image = pygame.image.load('images/background.png')
15
16-
# platform object
16+
# paddle object
17-
platform = Platform()
17+
paddle = Paddle()
18
19
# main game loop
20
game_on = True
21
while game_on:
22
    for event in pygame.event.get():
23
        if event.type == pygame.KEYDOWN:
24
            if event.key == pygame.K_ESCAPE:
25
                game_on = False
26
        elif event.type == pygame.QUIT:
27
            game_on = False
28
29-
    # platform controls
29+
    # paddle controls
30
    pressed_keys = pygame.key.get_pressed()
31
    if pressed_keys[pygame.K_a]:
32-
        platform.move_platform(-1)
32+
        paddle.move_paddle(-1)
33
    if pressed_keys[pygame.K_d]:
34-
        platform.move_platform(1)
34+
        paddle.move_paddle(1)
35
36
    # display background
37
    display.blit(background_image, (0, 0))
38
39-
    # display  platform
39+
    # display  paddle
40-
    display.blit(platform.image, platform.position)
40+
    display.blit(paddle.image, paddle.rect)
41
42
    pygame.display.flip()
43
    clock.tick(30)
44
45
pygame.quit()
46-
46+
47