Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # adding pygame module
- import pygame
- # creating constants
- WINDOW_WIDTH = 800
- WIDNOW_HEIGHT = 600
- # loading images to variables
- background_image = pygame.image.load('images/background.png')
- character_base_image = pygame.image.load('images/base.png')
- # pygame initialisation
- pygame.init()
- # creating display object and the game clock (FPS)
- display = pygame.display.set_mode([WINDOW_WIDTH, WIDNOW_HEIGHT])
- clock = pygame.time.Clock()
- # main game loop
- game_on = True
- while game_on:
- # event handling
- for event in pygame.event.get():
- # key presses
- if event.type == pygame.KEYDOWN:
- if event.key == pygame.K_ESCAPE:
- game_on = False
- # pressing X to close window
- elif event.type == pygame.QUIT:
- game_on = False
- # drawing the background
- display.blit(background_image, (0, 0))
- # drawing the base of the character
- display.blit(character_base_image, (270, 130))
- # wiping the frame
- pygame.display.flip()
- # setting the fps to 30
- clock.tick(30)
- # end of the main game loop
- # program close
- pygame.quit()
Add Comment
Please, Sign In to add comment