Advertisement
CatNamedWill

Untitled

Jun 27th, 2023
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. from tphysics import *
  2. from random import randint
  3.  
  4. game = Game("William's Game", 600, 600, "grey")
  5.  
  6. player = Rectangle(-150, -150, 10, 10)
  7. player.fill_colour = "green"
  8.  
  9. pickup = Rectangle( randint(-200,200), randint(-200,200), 10, 10)
  10. pickup.fill_colour = "turquoise"
  11.  
  12. game.add_shape(player)
  13. game.add_shape(pickup)
  14.  
  15. while True:
  16.  
  17. if game.ispressed("Left"):
  18. player.x -= 0.7
  19. if game.ispressed("Right"):
  20. player.x += 0.7
  21. if game.ispressed("Up"):
  22. player.y += 0.7
  23. if game.ispressed("Down"):
  24. player.y -= 0.7
  25.  
  26. if player.collide(pickup):
  27. player.width += 5
  28. player.height += 5
  29. pickup.x = randint(-200, 200)
  30. pickup.y = randint(-200, 200)
  31.  
  32. game.update()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement