Where to go now

It would be great if you would allow the game to move the snake at higher speed when the player ate a certain amount of fruits. To do this, you can set the frame rate to 30 and use a counter to run the content of onEnterFr function only once every five frames (use modulo operator to do it). This way your snake will move at 30/5=6 frames per second, just like the one you just developed. When the player collects, let's say, 10 fruits, you will make onEnterFr function run its content once every four frames, updating more than six times per second the game field and consequently increasing the snake's speed and game difficulty.

Get Flash Game Development by Example now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.