My C++ Ships game

Started by
27 comments, last by GameDev.net 18 years, 8 months ago
Hello, Here is my second C++ game, Ships (my first game was TicTacToe). The game still has some bugs, which will be fixed soon, but the first version is here. Source code is included, but its not commented so you probably won't understand too much. But please, comment the game in general, report bugs and stuff. Download Ships Thank you, RexTroianus
Advertisement
You need to check if the player is placing any ships on already occupied locations, since I placed all 4 ships on (3,6) without problems.

Other than that, good job!

Toolmaker

Yes, I know about that problem.

Also, there is a problem when choosing target location. You can input (100,232) and it will tell you missed.

Thanks for trying it! ;) I expect more comments from other guys...

RexTroianus
i was able to set all ships on one position and fire on a position out of screen... seems strange to me O_o
also check to make sure that the x and y coords that the player inputs, is within the board dimensions. I accidentally put in 55 and it just calculated a miss.

But good job. I like how it shows the board every time with a M in the spot that was fired at and missed.
These tears..leave scars...as they run down my face.
I've just taken a fast look over your code:

This is only in so far c++, as you use std::cout and std::cin...

I for myself what call this C and not C++...

So what you should do:

- get rid of your global variables, they are bet style...
especially loop counters should be declared in as small a scop as possible.
- try to put your functions in and variables in classes
- and even with such a small Program start to put the code in more than one file.

I hope this helps a little, just keep going ;-)
Yeah, I know about that bug, as I said already (in Instructions and in my second post)...

I already fixed the bugs. I will upload the final version soon!

Please post more comments and suggestions!

Thank you,
RexTroianus
Quote:Original post by philipptr
i was able to set all ships on one position and fire on a position out of screen... seems strange to me O_o


Yeah, I know about that bug, as I said already (in Instructions and in my second post)...

I already fixed the bugs. I will upload the final version soon!

Please post more comments and suggestions!

Thank you,
RexTroianus
Quote:Original post by Sparhawk42
I've just taken a fast look over your code:

This is only in so far c++, as you use std::cout and std::cin...

I for myself what call this C and not C++...

So what you should do:

- get rid of your global variables, they are bet style...
especially loop counters should be declared in as small a scop as possible.
- try to put your functions in and variables in classes
- and even with such a small Program start to put the code in more than one file.

I hope this helps a little, just keep going ;-)


Yeah, I was thinking about classes and more than just 1 file for this... Maybe in the next version, or next game... :) Thanks anyway! ;)
Here's a bug I found. I just played 1 quick game and I lost. When I type 3 to exit it kept asking me to fire on the enemies remaining ships.

This topic is closed to new replies.

Advertisement