View difference between Paste ID: zWt0hnaj and LAuUsk76
SHOW: | | - or go back to the newest paste.
1
# adding pygame module
2
import pygame
3
4
# creating constants
5
WINDOW_WIDTH = 800
6
WIDNOW_HEIGHT = 600
7
# loading images to variables
8
background_image = pygame.image.load('images/background.png')
9
character_base_image = pygame.image.load('images/base.png')
10
11
# pygame initialisation
12
pygame.init()
13
# creating display object and the game clock (FPS)
14
display = pygame.display.set_mode([WINDOW_WIDTH, WIDNOW_HEIGHT])
15
clock = pygame.time.Clock()
16
17
# main game loop
18
game_on = True
19
while game_on:
20
    # event handling
21
    for event in pygame.event.get():
22
        # key presses
23
        if event.type == pygame.KEYDOWN:
24
            if event.key == pygame.K_ESCAPE:
25
                game_on = False
26
        # pressing X to close window
27
        elif event.type == pygame.QUIT:
28
            game_on = False
29
30
    # drawing the background
31
    display.blit(background_image, (0, 0))
32
    # drawing the base of the character
33
    display.blit(character_base_image, (270, 130))
34
35
    # wiping the frame
36
    pygame.display.flip()
37
    # setting the fps to 30
38
    clock.tick(30)
39
40
# end of the main game loop
41
42
# program close
43
pygame.quit()
44