kevin7.net

Snake Game

Posted on by Kevin Foong

This is the biggest sketch (big for a P5.js sketch) I have done in P5.js - 356 lines of code. The classic Snake game. Eat the food (in green) and avoid the poison (in purple).  The green food is worth 2 points. After a while it turns pink and is only worth 1 point. If you eat the poison 3 points is deducted.

It was originally designed for the phone hence the controls is via a 3x3 grid. Clicking the left or right third moves the snake left or right. And likewise clicking the top and bottom thirds moves the snake up and down.

See Snake Game

...

Tags: processing, p5.js, games