0

I want to make a game in the turtle module similar to "Lunar Lander" by Atari but I'm not sure if I'll be able to make a collision system if I draw the terrain using a turtle. Any help would be appreciated.

Pat
  • 21
  • 3
  • `turtle` uses `tkinter` `Canvas` which has some method to check if two objects `overlap` - so it could be used to check collisions but access to canvas is hidden and it can make problems. I agree with @kimilao that `turtle` is nice for [drawing figures](https://blog.furas.pl/drawing-with-turtle-triangle.html) (especialy with recursion) and [PyGame](https://www.pygame.org/docs/) or similar (like [PyGameZero](https://pygame-zero.readthedocs.io/en/stable/), [Arcade](https://arcade.academy/) can be better. – furas Dec 24 '20 at 07:42

1 Answers1

2

I don't think python turtle have the collision system, but you can make the limit for the ground. Such as if the ground surface is on -40y, then you can create a variable and prevent the object from going through the ground.

groundLimit = -40  #create the limit for the object
while True:
    if turtle.ycor() < 40:  #check if the object hit the ground
        turtle.sety(40)   #make the object on the ground again
#but this method might make the object a bit weird

But if you are making a game, I would suggest using the "pygame" module. It's great for making games and better than turtle. Turtle is just for drawing, but pygame is for making games. You can find tutorials online to help you.

Good Luck!

kimilao
  • 41
  • 5
  • yeah its for a school project in which turtle has to be used. I'm going to find a workaround somehow. I was thinking maybe a list of x and y coordinates where the x and y of the lander are checked in the list each time my loop runs through. It'll be painstaking but I cant think of another way right now. I could make the list by adding each x,y coordinate as the drawing turtle makes the terrain. – Pat Dec 25 '20 at 03:25