Nibbles-game with hit test?

I’m creating a 4-player nibbles-like game (you know: the game with the snakes getting longer and longer, where you have to avoid hitting yourself or the walls.)

In my game the snakes have to grow constantly so it won’t be neccesary to think about the tail following the head.
I’m building the game so that the snakes are made of small segments (movie clips) that duplicates in a certain direction each time the snake moves that way.

-Question:
How do I program the snakes to die when they hit eachother or the walls?
Shall I use hit test, so that each segment of the snakes (the body) test if the snakes’ heads hit them or is there a better way to do it?

  • Hommer

You could have an array-based game:

A 2-dimensionnal array represents the game board, and each possible position of the board is represented by an element of that array. If 2 bits of snakes are in the same position time, there’s collision. Otherwise there isn’t :slight_smile: