New Posts  All Forums:Forum Nav:

Battleship Game - C++

post #1 of 15
Thread Starter 
Hello guys,

This is my first post, I wanted to post my final class project. We had to make a game, i made a Battleship game. It is a 1 player game, so there is AI in it along with some colours. I didn't have time to get graphics working (graphics.h library) yet, but will soon.

I attached the .exe file, please do check it and let me know of any errors. Let me know if anyone wants a fully documented source code.

Click Here to download

-Thanks
post #2 of 15
Its cool, but hard to use.

Allow me to be your first REP+
post #3 of 15
question: why does it take so long to choose a 'random' spot to place my ships?? I have a quad core at 3.6GHz for cryin out loud. :C

also i would like to recommend you make either the rows or the columns letters. That way you can specify a hit like 'A2'
Blitz II
(14 items)
 
  
CPUMotherboardGraphicsRAM
i5 750 MSI P55-GD65 GTX 660Ti 4GB Corsair Dominator 1600MHz 
Hard DriveOSMonitorKeyboard
600GB (2x300GB Velociraptors RAID0) Windows 10 24" ASUS VW246H Logitech Illuminated 
PowerCaseMouseMouse Pad
Corsair 750HX Lian Li Lancool PC-K62 G5/DeathAdder Desk 
Audio
Yamaha H80M + HS10W 
  hide details  
Reply
Blitz II
(14 items)
 
  
CPUMotherboardGraphicsRAM
i5 750 MSI P55-GD65 GTX 660Ti 4GB Corsair Dominator 1600MHz 
Hard DriveOSMonitorKeyboard
600GB (2x300GB Velociraptors RAID0) Windows 10 24" ASUS VW246H Logitech Illuminated 
PowerCaseMouseMouse Pad
Corsair 750HX Lian Li Lancool PC-K62 G5/DeathAdder Desk 
Audio
Yamaha H80M + HS10W 
  hide details  
Reply
post #4 of 15
Quote:
Originally Posted by Microsis View Post
question: why does it take so long to choose a 'random' spot to place my ships?? I have a quad core at 3.6GHz for cryin out loud. :C
lol, i thought that too...
post #5 of 15
Thread Starter 
Quote:
Originally Posted by Microsis View Post
question: why does it take so long to choose a 'random' spot to place my ships?? I have a quad core at 3.6GHz for cryin out loud. :C
NO no, it is not the computer. I'll try to be as clear as possible, sorry if confusing.

You see, when your done placing ships, assuming you are adding it manually, then it's computer's turn. The computer randomly picks the coloumn and row number, and a random direction for all ships. It is doing many checks as this process continues. If the ship overlaps, it erases all ship cells and starts over again. If the ship gets out of the given box (from 0-9), it erases all ship cells and starts over again. So there are lots of checks, if any of them are false then the ships cells have to be erased in the array and the process is restarted. Since the number for the computer is picked randomly, it may happen a couple of times per ship. I did put restriction on random function but as more ships appear on the board, error percentage increases.

I guess i haven't listed in the game that '*' means its a hit and 'm' means its a miss shot.

As for letters, i'll have to change everything and go back to strings. It is possible though.

-Thanks, good question though.
post #6 of 15
ah gotcha. still, even with all those checks you'd think it would still be almost instantaneous... I dunno though, i am just starting to learn C++.

another suggestion in addition to the one i posted above: you should color code the ships (if you can) as well as the hit and miss icons. (eg make the * red or something)

that should get u a better grade
Blitz II
(14 items)
 
  
CPUMotherboardGraphicsRAM
i5 750 MSI P55-GD65 GTX 660Ti 4GB Corsair Dominator 1600MHz 
Hard DriveOSMonitorKeyboard
600GB (2x300GB Velociraptors RAID0) Windows 10 24" ASUS VW246H Logitech Illuminated 
PowerCaseMouseMouse Pad
Corsair 750HX Lian Li Lancool PC-K62 G5/DeathAdder Desk 
Audio
Yamaha H80M + HS10W 
  hide details  
Reply
Blitz II
(14 items)
 
  
CPUMotherboardGraphicsRAM
i5 750 MSI P55-GD65 GTX 660Ti 4GB Corsair Dominator 1600MHz 
Hard DriveOSMonitorKeyboard
600GB (2x300GB Velociraptors RAID0) Windows 10 24" ASUS VW246H Logitech Illuminated 
PowerCaseMouseMouse Pad
Corsair 750HX Lian Li Lancool PC-K62 G5/DeathAdder Desk 
Audio
Yamaha H80M + HS10W 
  hide details  
Reply
post #7 of 15
AOA! Please send me the cpp file of ur game. I'm required to make the same game for my semester project. I hav been trying to figure out how to make it and so far i have just made the board. I want to see how did u make the random ship placement and the checks. Many thanks. Kindly send it on rasputin_returns89@yahoo.com
post #8 of 15
Quote:
Originally Posted by khan View Post
AOA! Please send me the cpp file of ur game. I'm required to make the same game for my semester project. I hav been trying to figure out how to make it and so far i have just made the board. I want to see how did u make the random ship placement and the checks. Many thanks. Kindly send it on rasputin_returns89@yahoo.com
Yeah ...and once you pass your course then you can go get a job with these guys.
post #9 of 15
Am I the only one that finds it a little shady that this kid joined just to post this program he made? Could be my internet-sense kicking in.
My System
(13 items)
 
  
CPUMotherboardGraphicsRAM
QX9650 @ 3.66 EVGA Nvidia 780i 2x EVGA 9600GT 512mb OCZ Reaper 4GB DDR2 1066 
Hard DriveOSPowerCase
2x 500gb Seagate Barracuda 7200.11 Vista Ultimate 64 bit OCZ GameXStream 700W Antec Nine Hundred Black Steel 
  hide details  
Reply
My System
(13 items)
 
  
CPUMotherboardGraphicsRAM
QX9650 @ 3.66 EVGA Nvidia 780i 2x EVGA 9600GT 512mb OCZ Reaper 4GB DDR2 1066 
Hard DriveOSPowerCase
2x 500gb Seagate Barracuda 7200.11 Vista Ultimate 64 bit OCZ GameXStream 700W Antec Nine Hundred Black Steel 
  hide details  
Reply
post #10 of 15
Thread Starter 
I don't get your point, make it clear please.
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Application Programming