battleship

This is a discussion on battleship within the Game Programming forums, part of the General Programming Boards category; I was just wondering how many of you have dont battleship, and how many lines of code should it take? ...

  1. #1
    Unregistered Leeman_s's Avatar
    Join Date
    Oct 2001
    Posts
    753

    battleship

    I was just wondering how many of you have dont battleship, and how many lines of code should it take? Just an estimate.

    See, thats what I'm working on right now. I have the player ship placement very near completion, its just a matter of typing now. After that the rest should be real easy. Do you think this is a good game to do after tic tac toe?

  2. #2
    Intranasal Heroin User Xterria's Avatar
    Join Date
    Sep 2001
    Location
    Buffalo, NY
    Posts
    1,035
    its simple, ive done it before
    172 lines for me

  3. #3
    Registered User Dual-Catfish's Avatar
    Join Date
    Sep 2001
    Posts
    802
    Yep, I've done it... an OOP approach though, it was around 500-600 lines.

    As for the estimate of how many it will take you.. I can't give you one, nor can anyone else. It all depends on your style. For example, some people comment on new lines, others don't (I do). Some declare more than one variable on one line (I don't). Others make use of brackets on tiny if statements (like me).

    if (something)
    {
    doSomething();
    }

    vs.

    if (something)
    doSomething();

    These things add up very quickly
    Last edited by Dual-Catfish; 04-16-2002 at 08:51 PM.

  4. #4
    Unregistered Leeman_s's Avatar
    Join Date
    Oct 2001
    Posts
    753
    download my battleship zip, only player ship placement is done. the zip has the source and an executable. oh and comment on it please.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    Feb 2002
    Posts
    57
    And so it seems i do everything that takes up more lines! It makes it more organized for me. Always use brackets on if's, declare variables on different lines, etc..
    Language: C++
    Compiler: Visual C++ 6.0
    Currently Working On: Simple OpenGL aspects

  6. #6
    Registered User Dual-Catfish's Avatar
    Join Date
    Sep 2001
    Posts
    802
    Exactly. Less lines by no means is better.

  7. #7
    Registered User heat511's Avatar
    Join Date
    Dec 2001
    Posts
    169

    800 i think

    my battleship is 800 or so, but its totally dummy proof (other than when you press letters instead of numbers) but maybe its overly complicated...

  8. #8
    I'm Back
    Join Date
    Dec 2001
    Posts
    556
    It also depends on how many features you put in the program, sound,color,positon check,display format etc etc.

    Mine is 900 odd line and still unfinished.

    >>172 lines for me
    Xterria, is that really true? you must be joking.

  9. #9
    Registered User heat511's Avatar
    Join Date
    Dec 2001
    Posts
    169

    i agree

    i've never heard of anything under 400

    at least not if its dummy proof (what happens if they put -1 as left coord for battleship, etc.)

    we did it as a project in class and the shortest code was 400 something

  10. #10
    Registered User
    Join Date
    Feb 2002
    Posts
    2

    battleship

    I am new to C:

    Any chance anyone could send me or post your battleship source code? We just got the project and the function I have to write is a Generate_Board function that will take as an array a parameter of 108 integers and will place the following ships:
    1 ship a length of 2
    2 ships a length of 3
    2 ships a length of 4
    1 ship a length of 5 these must be randomly generated by the computer as opposed to being placed by the player. I was hoping your code might give me some insight.
    Thanks to anyone willing

    kidglove14@aol.com

  11. #11
    Registered User seditee's Avatar
    Join Date
    Apr 2002
    Posts
    82
    or...you can write things like this:


    for(c=10;c>1;c--)delay(c);


    rather than...



    for(c=10;c>1;c--)

    {

    delay(c);

    }



    saves lines.
    lebios

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. c++ battleship game
    By JTtheCPPgod in forum Game Programming
    Replies: 4
    Last Post: 01-05-2002, 11:12 AM
  5. Battleship
    By Unregistered in forum Game Programming
    Replies: 11
    Last Post: 11-29-2001, 04:35 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21