Advertisement
Guest User

Untitled

a guest
Feb 25th, 2020
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. import pygame
  2. import random
  3. import sys
  4.  
  5. #### GLOBALNE VARIJABLE
  6. WIDTH = 800
  7. HEIGHT = 600
  8.  
  9. RED = (255, 0, 0)
  10. GREEN = (0, 255, 0)
  11. BLUE = (0, 0, 255)
  12. WHITE = (255, 255, 255)
  13. BLACK = (0, 0, 0)
  14. size = (WIDTH, HEIGHT)
  15.  
  16.  
  17. # inicijalizacija pygame sustava
  18. pygame.init()
  19.  
  20. pygame.font.init()
  21. #definiranje novog ekrana za igru
  22. screen = pygame.display.set_mode(size)
  23. #definiranje naziva prozora
  24. pygame.display.set_caption("Nasa kul igra")
  25.  
  26. slika = pygame.image.load("slika.jpg")
  27. slika = pygame.transform.scale(slika,(100,100))
  28. clock = pygame.time.Clock()
  29. bg = RED
  30. x = WIDTH/2-50
  31. y = HEIGHT/2-50
  32. done = False
  33. while not done:
  34. #event petlja
  35. for event in pygame.event.get():
  36. if event.type == pygame.QUIT:
  37. done = True
  38. if event.type == pygame.KEYDOWN:
  39. if event.key == pygame.K_ESCAPE:
  40. done = True
  41. if event.key == pygame.K_SPACE:
  42. if bg == RED:
  43. bg = BLUE
  44. elif bg == BLUE:
  45. bg = RED
  46. screen.fill(bg)
  47. screen.blit(slika,(x, y))
  48.  
  49. pygame.display.flip()
  50. dt = clock.tick(60)
  51.  
  52. pygame.quit()
  53. sys.exit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement