Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- import pygame
- from pygame.locals import*
- #create player
- player = pygame.image.load('player.png')
- player_x = 0
- player_y = 0
- player_r = 0
- #set screen size and background color
- bg = (255, 64, 64)
- w = 640
- h = 480
- screen = pygame.display.set_mode((w, h))
- screen.fill((bg))
- #main loop
- while True:
- screen.fill((bg))
- #check for key press
- for event in pygame.event.get():
- if event.type == pygame.KEYDOWN:
- #print event.key
- if (event.key == pygame.K_ESCAPE) or (event.key == pygame.K_q):
- pygame.quit();
- #Check for continuous key pressess
- keys = pygame.key.get_pressed()
- if keys[pygame.K_RIGHT]:
- player_x+=1
- if keys[pygame.K_LEFT]:
- player_x-=1
- if keys[pygame.K_UP]:
- player_y-=1
- if keys[pygame.K_DOWN]:
- player_y+=1
- if keys[pygame.K_r]:
- # player_r+=.01
- # player_rect = player.get_rect(center=image_rect.center)
- #screen.blit(image, image_rect)
- print "nope"
- #player = pygame.transform.rotate(player, player_r)
- #draw player to screen
- screen.blit(player,(player_x,player_y))
- #update display
- pygame.display.flip()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement