Thread: Battleship

  1. #1
    Unregistered
    Guest

    Battleship

    Hi I was hoping anyone here had a simple source code for the game battleship its a project in class we have to do and I'm a little lost on how I should set it up and would like to see how some other rpogrammers did.

  2. #2
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    First, try to write the code yourself. You won't learn much from someone else's source. You will find that it is twice as hard or even three times as hard to read someone else's source (even when it has good format and comments) than to just try the code on your own.

    Try and fail. Come back here and post the part that failed and about a gazillion people will help you solve your problem. But you gotta try first.

    If you don't know where to start, play the game in real life. Break the game into it's component parts and try to code those to the best of your ability. For starters: look at the game board. Isn't it strange how it looks like a 2 dimensional array?

  3. #3
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145

    Question

    Just wondering... have someone ever made a 3D-Battleship, which includes airplanes with different height?
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  4. #4
    "The Oldest Member Here" Xterria's Avatar
    Join Date
    Sep 2001
    Location
    Buffalo, NY
    Posts
    1,039
    Why don't you go talk to someone like John Carmack or romero?

  5. #5
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    Don't know, but it would not be that hard to do. To explain it in this thread would probably confuse the issue at hand.

  6. #6
    Linguistic Engineer... doubleanti's Avatar
    Join Date
    Aug 2001
    Location
    CA
    Posts
    2,459
    understand the functionality of the real world application...
    understand the syntax for implementing that same functionality in a source code file...

    debug debug debug... wash rinse repeat...

    then ask...
    hasafraggin shizigishin oppashigger...

  7. #7
    DockyD
    Guest

    Battleships - class or not to class!

    Hi,
    I am new to C and C++ and reading up on it.
    I studied the tic tac toe game and would like to attempt a battleships game.
    What I would like to ask is, as I am a beginner should I write this in C or C++?. I would like to go straight for C++ with classes and polymorphism's etc but will I come into problems?


    Your advice would be helpful.
    Thanks

  8. #8
    Linguistic Engineer... doubleanti's Avatar
    Join Date
    Aug 2001
    Location
    CA
    Posts
    2,459
    try either... use only what you have to, and if you end up only using C then go with that... lay it out, figure how to get it to code, wash rinse repeat... theoretically, since guru programmers do exist... [like salem... ] you should have no problems doing anything... but practically, you do... ask and ye shall find, be not vague, but rather as specific and local as you can... the more concise you are, the more concise we'll be...
    hasafraggin shizigishin oppashigger...

  9. #9
    Registered User
    Join Date
    Oct 2001
    Posts
    375
    I would like to go straight for C++
    Then that is your answer. I agree, you just got to go with what you are interested in. Both C and C++ are more than capable to accomplish just about any task.
    Allegro precompiled Installer for Dev-C++, MSVC, and Borland: http://galileo.spaceports.com/~springs/

  10. #10
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    ...but will I come into problems?

    You are programming, right? Yes, you will have problems since that is the name of the game. Will you have problems because you choose C++ over C? No. Both approaches have their bad points and good points. Since this is for a simple project, I would use C instead of C++. If you have more time to study the hierarchy of the objects in the game and how they relate to each other then use C++. The choice is yours. If you are not strong in C++, then code the project for class in C (to get the grade), and then code it in C++ on your own to learn more.

    I'm not a "everything must be C++ or it's worthless" kind of programmer. Both C and C++ when used correctly are very powerful.

  11. #11
    Linguistic Engineer... doubleanti's Avatar
    Join Date
    Aug 2001
    Location
    CA
    Posts
    2,459
    > Yes, you will have problems since that is the name of the game.

    if debugging is the practice of removing bugs... then programming must be the practice of putting them in...
    that's very true... practice makes perfect... [lim as practice -> infinity dpractice/dtime == perfect...]

    >kind of programmer

    i agree... use what you need... get it done... especially if someone is grading you... and in general if you further explore it... i find this is always good practice... it's the mentality...
    hasafraggin shizigishin oppashigger...

  12. #12
    DockyD
    Guest
    Hi,
    Thanks all for the comments.
    I will post the Battleships Program when I have it done. (or have a major problem stopping me completing it!!).

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Battleship Game (Win32 EXP Needed)
    By ElWhapo in forum Projects and Job Recruitment
    Replies: 2
    Last Post: 01-15-2005, 10:10 PM
  2. Battleship
    By mandingo in forum C++ Programming
    Replies: 7
    Last Post: 12-12-2004, 05:28 PM
  3. Battleship
    By luckygold6 in forum C++ Programming
    Replies: 25
    Last Post: 03-06-2003, 03:14 PM
  4. battleship
    By Leeman_s in forum Game Programming
    Replies: 10
    Last Post: 04-26-2002, 07:01 PM
  5. c++ battleship game
    By JTtheCPPgod in forum Game Programming
    Replies: 4
    Last Post: 01-05-2002, 11:12 AM