Mobile Battleship

Mobile Battleship, a game for the SDL assignment for Gregory Pitts, with small bits of code taken from Professor McCann's nest library.

Goal

In this prototype, I wanted to create a battleship type game where the pieces are mobile. It ended up turning into a game where you selected spots to move your "ships" and the computer fired at you. It is a survival game because you cannot fire back.

Method

First, I had to create a grid. The grid is 20x20. Then, I created the mouse handling. The grid will highlight when you scroll the mouse over the spots. Then, when you click it will highlight the square blue, signifying that you selected it. You can deselect squares. The amount of squares to choose is shown on the side. When you have selected all your squares, hit enter. this causes the computer to attack and if it guesses any of your squares you lose that piece. Game ends when 15 turns have elapsed or you die all your pieces. The grid is just a 2d array of integers that store the color. All the logic is based on the colors at each location.

Novelty

This is different than battleship because you can move your pieces around and across the map. However, you cannot go to spaces that were already attacked or that you already won. You win a space by the computer attacking once and not hitting you. This reduces the number of spots available and makes it more interesting because you can choose where to move your pieces.

Results

The results of this game were not what i expected. I made something completely different than I was planning when I sat down. Now I have an extra idea. I had another idea for a grid based game. But I liked the idea of user input highlighting the grid so I went with that and ended up with this game.
The game is decently challenging. I played several times at the end and both won easily and lost easily. It is subject to randomness so it is difficult to guage. It could improve by only allowing pieces to move to adjacent spaces or to make pieces more than one block in length. But this is OK for a prototype.
The winning conditions are kind of arbitrary and the points don't mean anything, but it is an OK time seeing if you can get to the end without losing any pieces. I have played more fun games.
One more problem. If you try to click really fast it allows you to press more than the amount of squares you are allowed. It will also allow you to click already used spaces. I couldn't figure out why it did this, but I imagine it is something to do with SDL mouse inputs. Hopefully.