-
-
The classic setup for the game. Each player starts with 18 tiles.
-
The random setup for the game. Players start with 0-100 tiles.
-
This is what the game might look like in the middle of playing.
-
Here is an example of when the game ends because all blue tiles are captured.
-
In this case, green failed to eat a mouse on their previous turn. They lose.
-
Nobody wins when the game ends and scores are equal. (note: going in spirals is not a good strategy)
-
This is the start screen which prompts the user to press "c" for classic mode or "r" for random mode.
Inspiration
I was inspired by the Snakes and Hackers theme and the old, yet iconic snake game.
What it does
The game creates a 10x10 game board with 4 different tile types.
- Red tiles belong to the red snake (player 1) and green tiles belong to the green snake (player 2).
- Blue tiles belong to no one and mouse tiles act like health because at least one must be picked up every turn (or else you lose).
- The player can select if they want the tiles placed in the normal configuration or if they want the tiles placed randomly.
- Each turn, players get 5 moves to go around the board eating mice and capturing blue or enemy tiles.
- The game ends when a player fails to reach a mouse in their 5 moves or when there are no blue tiles left, in which case a winner is decided based on player score.
How I built it
I built the game from scratch this weekend in Visual Studio 2019 and by using the C++ graphics library SFML. The major steps of the process:
- Creating a 2D array to keep track of the board state
- Setting up user interactions for the snake movement
- Making a whole lot of booleans to determine the stages of the game.
Challenges I ran into
A challenge I ran into was making images format correctly with the board tile objects. I ended up having to edit all of my images in Pixlr to edit transparency and make them the exact same pixel size as my tiles, and I used MS Paint to draw white outlines on them.
Accomplishments that I'm proud of
I'm proud of how much skill is actually involved in winning the game. I thought that I would have to settle for a very basic game that relies heavily on luck (like Snakes and Ladders or Candyland). While Snake 2 has simple rules, there is no luck factor (outside of random mode) and the winner is based solely on strategy. While you can take the aggressive approach and focus on invading the enemy's territory, you put yourself at risk of being out of reach of a mouse. There's lots of things to think about when playing the game and that's what I'm most proud of.
What I learned
I learned a lot about code efficiency in terms of displaying images and shape objects. When loading images, I found that this should only be done once, and all that sprites should be set from one loaded texture. I also learned that you can make a temporary sprite, draw it to the window, and then it doesn't need to be saved. In my for loop for drawing the game board, I used this strategy to speed up the drawing of mice on the tiles.
What's next for Snake 2: Two Snakes
The next step is to find a way to host the game on the web so that people can play it more easily with minimal setup.
Built With
- c++
- sfml
- visual-studio


Log in or sign up for Devpost to join the conversation.