Advertisement
Guest User

Untitled

a guest
Mar 30th, 2020
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.70 KB | None | 0 0
  1. import pygame,random,sys
  2.  
  3.  
  4. pygame.init()
  5.  
  6.  
  7. ball = "C:\ws\Testing ground\ball.ogg"
  8. bounce = pygame.mixer.Sound(ball)
  9.  
  10. font = pygame.font.SysFont("timesnewroman", 20)
  11.  
  12. white = (255,255,255)
  13. black = (0,0,0)
  14. red = (255,0,0)
  15. blue = (0,0,255)
  16. green = (0,255,0)
  17.  
  18. # ODREĐUJE DIMENZIJE ZASLONA
  19.  
  20. x = 600
  21. y = 700
  22. z = [x,y]
  23.  
  24. win = pygame.display
  25.  
  26. # ODREĐUJE POKRETANJE TIPKI
  27. move_x, move_y = 0,0
  28. change_x, change_y = 0,0
  29.  
  30. # DAJE NASLOV ZASLONA
  31. win.set_caption("IGRA RIJEČI!")
  32.  
  33. # POVRŠINA ZASLONA
  34. surface = win.set_mode(z)
  35.  
  36. python = pygame.image.load("C:\ws\Testing ground\lol.jpg")
  37. window = True
  38. #python_x,python_y = 200,200
  39. clock = pygame.time.Clock()
  40. click = 0
  41. colors = [white,red,blue,green]
  42. fill = white
  43. text_color = black
  44. circle_x, circle_y = x//2,y//2
  45.  
  46. while window:
  47. font = pygame.font.SysFont("timesnewroman", 20)
  48. text = font.render("Start", 0, text_color)
  49. for event in pygame.event.get():
  50. c_x,c_y = pygame.mouse.get_pos()
  51. if event.type == pygame.QUIT:
  52. pygame.quit()
  53. sys.exit()
  54. # window = False
  55. #surface.fill(white)
  56. #surface.blit(python,(python_x,python_y))
  57.  
  58. # Tipke za pokret.
  59. if event.type == pygame.MOUSEBUTTONDOWN:
  60. #python_x,python_y = random.randint(100,500),random.randint(100,600)
  61. if ((300-c_x)**2+(400-c_y)**2) < 2500:
  62. text_color = white
  63. move_x,move_y = random.randint(-20,20),random.randint(-20,20)
  64. #fill = random.choice(colors)
  65. circle_x += move_x
  66. circle_y += move_y
  67.  
  68.  
  69. # if event.type == pygame.KEYDOWN:
  70. # if event.key == pygame.K_LEFT:
  71. # change_x -= 5
  72. # if event.key == pygame.K_RIGHT:
  73. # change_x += 5
  74. # if event.key == pygame.K_UP:
  75. # change_y -= 5
  76. # if event.key == pygame.K_DOWN:
  77. # change_y += 5
  78. # if event.type == pygame.KEYUP:
  79. # if event.key == pygame.K_DOWN or event.key == pygame.K_UP:
  80. # change_y = 0
  81. # if event.key == pygame.K_LEFT or event.key == pygame.K_RIGHT:
  82. # change_x = 0
  83.  
  84. # Izrada za odbijanje od stranice
  85.  
  86. if circle_x < 55 or circle_x > 545:
  87. move_x = -move_x
  88. if circle_y < 55 or circle_y > 645:
  89. move_y = -move_y
  90.  
  91. #move_x += change_x
  92. #move_y += change_y
  93.  
  94. surface.fill(fill)
  95. surface.blit(text,(x//2-19,y//2-12))
  96. pygame.draw.rect(surface,black,(5,5,590,690),3)
  97. pygame.draw.circle(surface,black,(circle_x,circle_y),50,1)
  98. movement = pygame.mouse.get_pos()
  99. #surface.blit(python,(move_x,move_y))
  100. win.update()
  101. clock.tick(10)
  102.  
  103. pygame.quit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement