![]() ![]() The playing area is 20 cells wide and 15 cells high, and each cell has a side length of 15 pixels. If the new head position is at the same position as any of the snake's other segments, then the game is over. If the new head position is at the position same as the food's position, then the snake's tail is not removed, and the food is moved to a random position not occupied by the snake. its new head position) in the direction that the snake is going. ![]() its old tail position) is removed, and an item is added to the front (i.e. When the snake moves, then the last item in the sequence (i.e. The food is represented by a single X and Y position. The snake is represented by a sequence of X and Y positions. The game is over when the snake crashes into itself. The snake will wrap around to the other side of the screen when it goes off the edge. When the food is eaten it moves to another random position. Please send any feedback to snake.py RulesĮating food makes the snake grow. A tutorial for Python and Pygame Zero 1.2 ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |