Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pygame
- from Platform import Platform
- # height and width of the screen
- SCREEN_WIDTH = 1024
- SCREEN_HEIGHT = 800
- # pygame settings
- pygame.init()
- # display, clock and background objects
- display = pygame.display.set_mode([SCREEN_WIDTH, SCREEN_HEIGHT])
- clock = pygame.time.Clock()
- background_image = pygame.image.load('images/background.png')
- # platform object
- platform = Platform()
- # main game loop
- game_on = True
- while game_on:
- for event in pygame.event.get():
- if event.type == pygame.KEYDOWN:
- if event.key == pygame.K_ESCAPE:
- game_on = False
- elif event.type == pygame.QUIT:
- game_on = False
- # platform controls
- pressed_keys = pygame.key.get_pressed()
- if pressed_keys[pygame.K_a]:
- platform.move_platform(-1)
- if pressed_keys[pygame.K_d]:
- platform.move_platform(1)
- # display background
- display.blit(background_image, (0, 0))
- # display platform
- display.blit(platform.image, platform.position)
- pygame.display.flip()
- clock.tick(30)
- pygame.quit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement