Overclock.net - Overclocking.net
     
 
Home Gallery Reviews Blogs Register Today's Posts Mark Forums Read Members List


Go Back   Overclock.net - Overclocking.net > Software, Programming and Coding > Coding and Programming > Application Programming

Reply
 
LinkBack Thread Tools
Old 06-13-08   #1 (permalink)
New to Overclock.net
 
Join Date: Jun 2008
Posts: 4

Rep: 2 AAZZ Unknown
Unique Rep: 2
Trader Rating: 0
Default Battleship Game - C++

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
AAZZ is offline   Reply With Quote
Old 06-13-08   #2 (permalink)
Case Modder
 
Cerberus's Avatar
 
amd nvidia

Join Date: Dec 2007
Posts: 718

Rep: 50 Cerberus is acknowledged by some
Unique Rep: 47
Trader Rating: 1
Default

Its cool, but hard to use.

Allow me to be your first REP+
__________________
[||||||||||||||||||]
Car fund(5% Increments)
__________________________________________________ __________________________________________________
"Student by day, Gamer by night"
╩╪Unofficial Lego Lovers Club╩╪

System: Nighthawk
CPU
AMD 3800+X2 Windsor@ 2.8
Motherboard
Biostar TForce 550
Memory
Samsung 2x1Gb
Graphics Card
Sapphire X1900gt 256mb
Hard Drive
WD 120GB
Sound Card
Creative Sound Blaster Audigy SE
Power Supply
Ultra Xfinity 600w Titanium
Case
Cooler Master Centurion 5
CPU cooling
Stock(for now)
GPU cooling
VF-700
OS
Microsoft Windows XP Professional
Monitor
BenQ FP202W 20.1in WS
Cerberus is offline   Reply With Quote
Old 06-13-08   #3 (permalink)
Intel Overclocker
 
Microsis's Avatar
 
intel nvidia

Join Date: Apr 2008
Posts: 956

Rep: 114 Microsis is acknowledged by manyMicrosis is acknowledged by many
Unique Rep: 88
Trader Rating: 0
Default

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'

System: For The Win
CPU
Q6600 @ stock (for summer)
Motherboard
EVGA 750i FTW
Memory
2x2GB Crucial Ballistix @ stock (for summer)
Graphics Card
XFX 8800GT (700/1000)
Hard Drive
300GB VelociRaptor, 36GB Raptor, 250GB Caviar SE16
Sound Card
X-Fi XtremeMusic
Power Supply
580W Hiper Type-R
Case
Cooler Master CM690
CPU cooling
Tuniq Tower
GPU cooling
Thermaltake Duorb
OS
Windows Ultimate x64
Monitor
22" Samsung 226BW
Microsis is offline   Reply With Quote
Old 06-13-08   #4 (permalink)
Case Modder
 
Cerberus's Avatar
 
amd nvidia

Join Date: Dec 2007
Posts: 718

Rep: 50 Cerberus is acknowledged by some
Unique Rep: 47
Trader Rating: 1
Default

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...
__________________
[||||||||||||||||||]
Car fund(5% Increments)
__________________________________________________ __________________________________________________
"Student by day, Gamer by night"
╩╪Unofficial Lego Lovers Club╩╪

System: Nighthawk
CPU
AMD 3800+X2 Windsor@ 2.8
Motherboard
Biostar TForce 550
Memory
Samsung 2x1Gb
Graphics Card
Sapphire X1900gt 256mb
Hard Drive
WD 120GB
Sound Card
Creative Sound Blaster Audigy SE
Power Supply
Ultra Xfinity 600w Titanium
Case
Cooler Master Centurion 5
CPU cooling
Stock(for now)
GPU cooling
VF-700
OS
Microsoft Windows XP Professional
Monitor
BenQ FP202W 20.1in WS
Cerberus is offline   Reply With Quote
Old 06-13-08   #5 (permalink)
New to Overclock.net
 
Join Date: Jun 2008
Posts: 4

Rep: 2 AAZZ Unknown
Unique Rep: 2
Trader Rating: 0
Default

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.
AAZZ is offline   Reply With Quote
Old 06-13-08   #6 (permalink)
Intel Overclocker
 
Microsis's Avatar
 
intel nvidia

Join Date: Apr 2008
Posts: 956

Rep: 114 Microsis is acknowledged by manyMicrosis is acknowledged by many
Unique Rep: 88
Trader Rating: 0
Default

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 :P

System: For The Win
CPU
Q6600 @ stock (for summer)
Motherboard
EVGA 750i FTW
Memory
2x2GB Crucial Ballistix @ stock (for summer)
Graphics Card
XFX 8800GT (700/1000)
Hard Drive
300GB VelociRaptor, 36GB Raptor, 250GB Caviar SE16
Sound Card
X-Fi XtremeMusic
Power Supply
580W Hiper Type-R
Case
Cooler Master CM690
CPU cooling
Tuniq Tower
GPU cooling
Thermaltake Duorb
OS
Windows Ultimate x64
Monitor
22" Samsung 226BW
Microsis is offline   Reply With Quote
Old 06-18-08   #7 (permalink)
New to Overclock.net
 
Join Date: Jun 2008
Posts: 1

Rep: 0 khan Unknown
Unique Rep: 0
Trader Rating: 0
Default Please send the file to me!

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
khan is offline   Reply With Quote
Old 06-19-08   #8 (permalink)
New to Overclock.net
 
Join Date: May 2008
Location: Nottingham, UK
Posts: 24

Rep: 7 Stormwolf Unknown
Unique Rep: 5
Trader Rating: 0
Default

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.
Stormwolf is offline   Reply With Quote
Old 06-19-08   #9 (permalink)
Networking Nut
 
intel nvidia

Join Date: May 2008
Location: Mesa, Arizona
Posts: 171

Rep: 25 smm298 is acknowledged by some
Unique Rep: 24
Trader Rating: 0
Default

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.
__________________
System: My System
CPU
QX9650 @ 3.66
Motherboard
EVGA Nvidia 780i
Memory
OCZ Reaper 4GB DDR2 1066
Graphics Card
2x EVGA 9600GT 512mb
Hard Drive
2x 500gb Seagate Barracuda 7200.11
Power Supply
OCZ GameXStream 700W
Case
Antec Nine Hundred Black Steel
CPU cooling
ZALMAN 9500A
OS
Vista Ultimate 64 bit
smm298 is offline   Reply With Quote
Old 06-19-08   #10 (permalink)
New to Overclock.net
 
Join Date: Jun 2008
Posts: 4

Rep: 2 AAZZ Unknown
Unique Rep: 2
Trader Rating: 0
Default

I don't get your point, make it clear please.
AAZZ is offline   Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools



All times are GMT -4. The time now is 06:36 AM.


Overclock.net is a Carbon Neutral Site Creative Commons License Internet Security By ControlScan

Terms of Service / Forum Rules | Privacy Policy | Advertising | Become an Official Vendor
Copyright © 2008 Shogun Interactive Development. Most rights reserved.
Page generated in 0.20392 seconds with 9 queries