SnakeGame how to make the tail follow the head?

后端 未结 2 509
借酒劲吻你
借酒劲吻你 2020-12-12 05:41

I am making a snake game, and I am stuck at where making the tails follow the head. And I heard using an add and remove on the head and tails could make that happen, but I h

2条回答
  •  忘掉有多难
    2020-12-12 06:23

    For snake style movement, you can, from the tail to the head, move each BodyPart position to the position of the BodyPart ahead of it. For the head there is no part ahead so you have to write decision code whether to simply move the same direction as the part before it or a new direction based on input. Then update the screen.

提交回复
热议问题