This application presents a grid of 100 squares to the user. The user has thirty five attempts to find to find the computers fleet. The computer randomly positions five ships of varying sizes around the board.
The board is made up of 100 buttons each uniquely numbered. They start sea-green indicating not selected. When selected the application checks if the area is occupied and turns red if unoccupied turns blue. The application also emits an explosion for a hit and a splash for a miss. It also recognizes a complete sinking by ringing the ships bell. On complete sinking of a ship it's corresponding ship indicator turns yellow.
After 35 attempts the application will show all missed squares by turning the squares yellow.
It uses the following......
wav files for all the sounds
Buttons for the squares
Random method to place the ships
Use manager to organise the squares
I have included the code and wav files in the following zip file (See attached file: BattleBoat.zip)
You will notice three classes - Battleship, GridManager and MainForm.
The Mainfrom is the entry point for the application. It initializes the application and controls play.
GridManager manages the grid. It adds the ships. Controls the current condition of the buttons.
Battleship - holds information about each ship. It tells the condition of the ship e.g. if it has sunk or wrecked etc, it holds the type, name and length of the ship
You might note I have used the random method twice before I assign the ship. This was the only way to ensure complete randomization. If I used it once then it seems to position the ships very close together.
Join the conversation! Your thoughts help the community grow.
Sign in to leave a comment
It is the same account you read, post and publish with — and you will come straight back to this page.
Ash PPosted Jul 9, 2015, 7:21 AM
Hi I need to make battleship game for single player using c#.net, please help me
gentush goliPosted Dec 10, 2010, 10:55 AM
hi i have to create a battleship game in c# but i have no idea how to do it. Could you help me, please?
gentush goliPosted Dec 10, 2010, 10:53 AM
hi i have to do a battleship game in c#, but i have no idea how to do it :( could you help me please?
Chris StannardPosted May 29, 2009, 8:27 PM
Just what I've been trying to code myself. Got as far as creating the logic but I'm looking at the System.Drawing usage. Pretty cool code.
nuwan WaidyaPosted Feb 4, 2008, 9:08 PM
thanks for the post
carlos orekPosted Jan 1, 2008, 3:18 PM
please can you help me lam a postgrad student in uk and l have an assignment to develop a single player battleship game the problem is l have no programming experience and this is a bit out of my depth please can you help me out i dont know what to do l only have two weeks from now and l dont mind paying if l have to please
mutasim yaqoobPosted Feb 18, 2007, 7:25 AM
i am after battleship game using VB.net and CsGL code do you know how to develop or who knows? please let me know if you know many thanks