CPE 471 Final Project

Doug Foiles




Introduction


I chose to create a 3D remake of the classic Battleship board game. I wanted to make some sort of interactive graphics application so I thought that replicating a board game would be fun. Being up and close to your ships and experiencing them getting blown up is a cool concept and adds to the experience of the game.


How I Implemented the Game

I split the game into two modes, setup and actual gameplay.

During the setup the user is placed above the battleship board and gets to place his/her pieces. The user and the computer both get two ships that are three units long and one ship that is two units long. The computers ships are randomly generated each game. The user can control the placement of the ships using the keys W, A, S, and D (up,left,down,right). Once the user is happy with the position of the ship they can press the ENTER key to confirm its placement and move onto the next piece.

Once all the pieces are placed the user is moved to the front of the board so every part of the board is in sight. The user can now guess where the computers ships are. To guess, the user will enter coordinates with the keyboard. The rows are A-E and the columns are 1-5. For example, the top left box is A1 and the bottom right is E5. When the user guesses a spot where a computer ship is located, a red dot pops up at that spot on the board. If the user misses a ship, a white dot pops up. After each guess the computer will make a random guess. Once the computer guesses it will know not to guess in the same spot. If the computer guesses a spot where one of the users ships is, an explosion animation is played.

What I learned

I got a lot of practice with linking graphics to user interaction and gameplay. I began by programming the gampeplay logic first and then connected the graphics after. There was a little bit of collision detection when the user is setting up the board. I used arrays to map everything. I originally wanted to use particles to create the explosion but I ended up making an animation with timers and scaling shapes. I spent a lot of time with matrix transformations so I ended up having a really good understanding of how to move objects in an environment.

Images

Setup

Gameplay

Explosion