CPE 471 Final Project: Pirate Ship Battle

Nicholas Plewtong

Introduction

For my final project, I was looking to create the basis of a game with movement, textures, collision detection and particle effects. What I have created is an interactive pirate ship battle which contains the following concepts incorporated in the program. The player is able to control a ship, shoot cannonballs, and see whether or not they have successfully hit the enemy ship.

Movement

The player starts to game in control of his or her own ship. The player can speed up the ship by tapping the 'W' key up to a certain maximum speed. The player can slow down the ship by tapping the 'S' key until the ship comes to a complete stop. Along with this, the player can hold the 'A' or the 'D' keys in order to turn the ship slowly to the left or right respectively. These combination of keys allow the player to have full control of where they would like the ship to go on the ocean. The player can shoot a cannonball from the left side of the ship where the cannons are located by hitting the 'Q' key but are limited to one cannonball at a time. The player also has a full range of perspective by using the mouse to control where the player is looking.

Texture Mapping

For the ocean, I used an ocean texture with a turquoise base color in order to achieve the lighting effect of the ocean that I desired.

For the pirate ship, there were multiple parts of the ship that needed to be textured from the .obj that I obtained. I textured the majority of the ship parts with a wood texture in order to obtain what looked to be a realistic ship. There were several other parts of the ship that I had to distinguish with different textures. Out of the 197 shapes in the obj file, I found those shapes that corresponded to the sails to which I textured with a cloth/fabric texture. Along with this, I found which shapes corresponded to the cannons of the ship and textured that with a metal texture. This texture is also used for the cannonballs.

Collision Detection

I used a box collision detection system in order to determine if the cannonball has hit the enemy ship. This box is built as close as possible around the dimensions of the enemy ship so that if the cannonball enter within a certain dimensional range that represents the enemy ship, then the program will register that as a hit. I had to fiddle with the range of the hit detection in order to achieve a box that has decent accuracy visually to when it hits the model of the ship.

Particle Effects

When the cannonball successfully collides with the enemy ship, a particle effect simulating an explosion from the impact of the cannonball on the ship occurs. This particle effect is red in nature and expands outward with the particles for a short period of time in order to best simulate the explosion. This is used in order to provide feedback to the player that they have successfully hit the enemy ship.

Above shows the player ship firing a cannonball

Above shows explosion from the cannonball hitting the enemy ship.

Conclusion

I had a lot of fun creating this base pirate ship interaction for which I will probably continue expanding upon. I was able to combine all the labs we learned throughout the quarter in order to create an awesome demo of a pirate ship battle. Future work could include adding more sophisticated AI to the computers, improve collision detection, and incorporate scenary like rocks to create a more varied landscape.

References