daily pastebin goal
69%
SHARE
TWEET

Untitled

a guest Dec 7th, 2017 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import pygame
  2. pygame.init()
  3.  
  4. Size=(1280,768)
  5. Display=pygame.display.set_mode(Size)
  6.  
  7. yellow = (255,255,0)
  8. red = (255,0,0)
  9.  
  10. pygame.display.set_caption("Visbeer")
  11.  
  12. done = False
  13. clock = pygame.time.Clock()
  14.  
  15. class Player(pygame.sprite.Sprite):
  16.     speedChangeX = 5
  17.     speedChangeY = 5
  18.    
  19.     def __init__(self,color,width,height):
  20.         super().__init__()
  21.         self.image=pygame.Surface([width,height])
  22.         self.image.fill(color)
  23.         self.rect=self.image.get_rect()
  24.         self.rect.center=(1000,200)
  25.        
  26. player=Player(red,32,32)
  27.  
  28. AllSpritesList=pygame.sprite.Group()
  29. AllSpritesList.add(player)
  30.  
  31. while not done:
  32.     for event in pygame.event.get():
  33.         if event.type == pygame.QUIT:
  34.             done = True
  35.  
  36.     pressed = pygame.key.get_pressed()
  37.     if pressed[pygame.K_UP]: player.rect.centery -= player.speedChangeY
  38.     if pressed[pygame.K_DOWN]: player.rect.centery += player.speedChangeY
  39.     if pressed[pygame.K_RIGHT]: player.rect.centerx += player.speedChangeX
  40.     if pressed[pygame.K_LEFT]: player.rect.centerx -= player.speedChangeX
  41.  
  42.     AllSpritesList.update()
  43.  
  44.     Display.fill(yellow)
  45.     AllSpritesList.draw(Display)
  46.     pygame.display.flip()
  47.     clock.tick(60)
  48.  
  49.  
  50. pygame.quit()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top