Snake Multiplayer

Make sure you have a working single player snake (if not two player snake) before starting this project!

Overall, people report that the code for multiplayer snake gets large. You probably want to make a separate folder for your snake game and break it into separate files using require and provide. I recommend each file only do one “part” of the animation. To give you an idea, I made separate files for:

Model

For many multi-player snake, we will want:

where each snake has

(define-struct sn (id head body dir))
(define-struct multi (apples snakes))

Draw Handler

Break the job into pieces, draw each piece on a provided background.

Key Handler

I wrote one function to determine which id number snake certain keys control and another function to determine which way the snake turns given the keys.

I then applied the change in direction to the snake with the appropriate id (going through the whole list of snakes and not changing the rest of them).

Tick Handler

There’s a lot to the tick handler. I’m going to leave planning this up to you. Email with questions! This sketch is short / incomplete.