What is "dot" (a hint is a name that says nothing) and what does it do in the Snale class?
Shifting each part of a snake can be useful if each part of it can be something unique (roughly - each part of a different color). In your version, at this stage, you can use optimized movement - if we meet dot, then we do not change the coordinates of the snake's body, simply add dot to the snake. If dot is not found, simply transfer the end of the snake to the beginning.
"get_score" I, too, would have taken out of the bounds of the snake - what does the bill have to do with a snake?
I do not know a panda, with a python is also poorly familiar, but the question is - in panda, aren’t all calculations / rendering done in one method? And if the calculations will be significant?
In addition, as in this case, handle the following situation:
- there are two snakes
- the speed of one is twice the speed of the other, i.e. one snake at the same time must pass two times more than the other
Will you use your self.period for each snake? And if a bunch of snakes? Migrate self.period to snakes? Or will you just move the same snakes at different distances? Then read on:
- One of the snakes (one that must move at a time at a distance more than twice, for example, two cages) is located at the point [X, Y]
- Dot is at [X-1, Y]
- The snake moves to the point [X-2, Y]
- Logically, because the snake should not "jump", then during the passage of [X-1, Y] the next dot may appear in [X-2, Y], so the snake will have to eat it too - and all this in one move (we only have one period)
And how will you handle it? Will you still move the snake in jerks? And generate dot already after all the movements of the snake? And what kind of twitching will it be?
Why draw and delete objects if you can simply change the coordinates of existing ones?
obj.setPos( Point3( pos.getX( ), depth, pos.getY( ) ) )
Those. pass through the body of the snake, the bark has similar crust, if the body is finished and there are still briks - then remove them already, or if on the contrary - there is a body, but there are no briks - add them.
It is also not quite optimal, you can come up with a better idea, but don’t waste your money on extra load / delete.