wrap snake position vertically on edge of screen slow game loop to 15 fps instead of 60 (60/15 = 4) get random whole numbers in a specific range keep track of all grids the snake body occupies moves one grid length every frame in either the x or y direction When you become a Patron, you get access to behind the scenes development logs, the ability to vote on which games I work on next, and early access to the next Basic HTML Game. Other Basic Gamesīasic HTML Games are made possible by users like you. Apart from that, were content to let them speak for themselves. Giving attribution is not required, but appreciated. What to say about Flower and Snake (aka Hana to hebi) that hasnt been said already If youre not familiar with the 1974 or 2004 films, we can recommend the Wikipedia pages at the links for much intriguing background concerning these classic (and some would say completely over-the-top) Japanese productions. There's no need to ask permission before using these. The player is represented as snake, which grows if it eats an apple.
The game is an arcade game and it has very simple logic, which is why it is an ideal example to demonstrate how to build games with Pygame. (CC0 1.0 Universal) You're free to use this game and code in any project, personal or commercial. Python hosting: Host, run, and code Python in the cloud In this tutorial you will learn how to build the game snake. This series is meant to give a basic outline of the game but nothing more. Important note: I will answer questions about the code but will not add more features or answer questions about adding more features.
Improve it so it only spawns in empty grid locations