Hi!
I’m trying to make some sort of a snake game, but I’m having trouble with the movement. I refuse to go the “make the snake move along a grid, placing each part of the snake to the cell the previous part occupied the last update” route as I think it looks stupid, so I started making a smooth moving snake but still with 90 degree turns.
This is working OKish already after the very first try by having each part move independently of each other. Every time the player turns the head, it saves the coordinates and the new direction where the turn happened and each part checks these coordinates of the previous part and does the same change once it hits the said coordinates, again saving the coordinates for the next part to check them etc. Once the part has made the turn, I then fix it’s position relative to the part before it to make it line up perfectly as there are some rounding errors etc.
But there are some problems still plus you can just feel that the snake isn’t connected but it’s rather just several blocks moving next to each other (and when it bugs out the snake snaps in two).
I have two different options here… either I keep going like this and try to perfect the snake movement so that it a) looks good and b) has no chance of crapping out or I take it one step further and make a freeform moving snake with the head rotating in small degree changes and the body flowing freely (yet the way you’d expect it to do) behind it.
The latter is what I’d like to do, but as I’m not too good at maths I’m having trouble figuring out how to calculate the positions of the body parts.
I came across this which seems interesting to try but I couldn’t figure out how to fully translate that into Javanese to see how it works. Again, sucking at maths doesn’t help as I can’t figure out the corresponding Java tools to use (namely the Vector2.Transform and Matrix.CreateRotationZ in that code (can I use affine transform here somehow?). I’m doing this on libgdx if there are some tools in their built in vector classes and whatnot that I should use.
Any input and help would be appreciated to get me going