Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pygame
- from pygame.locals import (
- K_UP,
- K_DOWN,
- K_LEFT,
- K_RIGHT,
- K_ESCAPE,
- KEYDOWN,
- QUIT,
- )
- #initialize game
- pygame.init()
- SCREEN_WIDTH = 800
- SCREEN_HEIGHT = 600
- screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
- screen.fill((255,255,255))
- fighter = pygame.Surface((50,50))
- fighter.fill((0,0,0))
- rect = fighter.get_rect()
- screen.blit(fighter, (SCREEN_WIDTH/2,SCREEN_HEIGHT/2))
- pygame.display.flip()
- running = True
- #Main Loop
- while running:
- for event in pygame.event.get():
- if event.type == KEYDOWN:
- if event.key == K_ESCAPE:
- running = False
- elif event.type == QUIT:
- running = False
- pygame.quit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement