ABIX_Edukacja

zapros-01

Dec 10th, 2020 (edited)
859
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.29 KB | None | 0 0
  1. # gra - pirat musi dostać się na statek
  2. # Licencja: GNU GPL - https://www.gnu.org/licenses/gpl-3.0.html
  3. # obrazki oryginalnie w serwisie Pixabay:
  4. # Statek: https://pixabay.com/pl/vectors/statek-%C5%82%C3%B3d%C5%BA-pirat-korsarz-146312/
  5. # Pirat: https://pixabay.com/pl/vectors/pingwin-pirat-tux-zwierz%C4%85t-chustka-161356/
  6. # Morze: https://pixabay.com/pl/photos/sun-ustawienie-niebo-zach%C3%B3d-s%C5%82o%C5%84ca-3726030/
  7.  
  8. WIDTH = 800
  9. HEIGHT = 532
  10. KROK = 3
  11. ODLEGLOSC = 40
  12.  
  13. from random import randint
  14.  
  15.  
  16. ship = Actor("ship.png")
  17. ship.x = randint(10, 700)
  18. ship.y = randint(10, 432)
  19. pirat = Actor("pingwin.png")
  20. pirat.x = randint(10, 750)
  21. pirat.y = randint(10, 500)
  22.  
  23. def draw():
  24.     screen.blit("sun_800.jpg", (0, 0))
  25.     ship.draw()
  26.     pirat.draw()
  27.     if pirat.distance_to(ship) < ODLEGLOSC:
  28.         screen.draw.text("SUPER !!!", (40, 10), shadow=(2,2), scolor="#202020")
  29.    
  30.  
  31. def update():
  32.     if keyboard.d:
  33.         pirat.x += KROK
  34.         if pirat.x > 780:
  35.             pirat.x = 775
  36.     if keyboard.a:
  37.         pirat.x -= KROK
  38.         if pirat.x < 20:
  39.             pirat.x = 25
  40.     if keyboard.w:
  41.         pirat.y -= KROK
  42.         if pirat.y < 20:
  43.             pirat.y = 25
  44.     if keyboard.s:
  45.         pirat.y += KROK
  46.         if pirat.y > 510:
  47.             pirat.y = 495
  48.    
  49.  
Advertisement
Add Comment
Please, Sign In to add comment