Advertisement
humpda

Lander

Mar 8th, 2022
1,321
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.91 KB | None | 0 0
  1. from random import *
  2. surface = Actor("surface")
  3. surface.pos = 400, 600
  4. lander = Actor("lander")
  5. lander.pos = ((randint(100,700), 100))
  6. count=1
  7. HEIGHT = 800
  8. WIDTH = 800
  9. TARGET=Rect((randint(100,700),700),(50,50))
  10.  
  11. def draw():
  12.     screen.clear()
  13.     surface.draw()
  14.     screen.draw.rect(TARGET, (255,0,0))
  15.     lander.draw()
  16. def update():
  17.     lander_update()
  18.  
  19. def lander_update():
  20.     if keyboard.right:
  21.         lander.pos = (lander.x + 5, lander.y)
  22.     if keyboard.left:
  23.         lander.pos = (lander.x - 5, lander.y)
  24.     if keyboard.up:
  25.         lander.pos = (lander.x, lander.y-10)
  26.     landed_lander()
  27.     set_lander_normal()
  28.  
  29. def set_lander_normal():
  30.     global count
  31.     lander.y += (count/7)+1
  32.     count +=1
  33.  
  34. def landed_lander():
  35.     global count
  36.     if lander.colliderect(TARGET):
  37.         sounds.eep.play()
  38.     elif lander.y>750:
  39.         lander.pos = ((randint(100,700), 100))
  40.         count = 1
  41.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement