First Game

This is a discussion on First Game within the Game Programming forums, part of the General Programming Boards category; I know you probably all think I'm a dumb n00b, but oh well. I made my first game(it doesn't really ...

  1. #1
    The Pantless Man CheesyMoo's Avatar
    Join Date
    Jan 2003
    Posts
    262

    First Game

    I know you probably all think I'm a dumb n00b, but oh well.
    I made my first game(it doesn't really count) it was a mad lib game, it was really easy but, I want to make a game like tic-tac-toe or something... I'm lost I really have no idea on how to start, I've read tutorials and all they say is stuff like you can't start out making quake 3 start small... that really doesn't help, does any body example code for a tic-tac-toe game or other VERY simple game... thanks.

  2. #2
    Registered User
    Join Date
    Sep 2002
    Posts
    1,640
    What's mad lib?
    Well Tic-Tac-Toe is about the easiest thing i can think of,
    imagin an array

    Code:
    int spot[10]; // 10 instead of 9 because 10 doesnt count
    you ask the input from a player and proces it

    Code:
    if(key_pressed=="1")
         spot[1]==current_player; // current player is an int holding the....
    and you print it

    Code:
     cout << spot[1] << spot[2] << spot[3] << endl;
     cout << spot[4] << spot[5] << spot[6] << endl;
     cout << spot[7] << spot[8] << spot[9] << endl;
    That just about covers the basics.

  3. #3
    I lurk
    Join Date
    Aug 2002
    Posts
    1,361
    No, you'd still use spot[9]...
    0-8 = 9 elements, while 9th holds the NULL terminator.

  4. #4
    The Pantless Man CheesyMoo's Avatar
    Join Date
    Jan 2003
    Posts
    262
    Is goto statement for C++ like in BASIC? I'm trying to think of a way to have it ask for the input again and go back to the switch statement without writing it over and over alot.

  5. #5
    Registered User Vber's Avatar
    Join Date
    Nov 2002
    Posts
    807

    hmm...

    TicTacToe - you can have a 2d array
    Code:
    char board[3][3];
    And then make a function to print the board,
    another function to get data and put in the array, another to check if we have a winner and so on...

    Not too hard.
    Hmm A nice game is: "The Game of the life".
    If you wan't some info about him, tell.

  6. #6
    The Pantless Man CheesyMoo's Avatar
    Join Date
    Jan 2003
    Posts
    262
    Nevermind, I fixed it.

  7. #7
    The Pantless Man CheesyMoo's Avatar
    Join Date
    Jan 2003
    Posts
    262
    I've been workin' for a while and I got it to run and the only problem is, it asks for only player ones input, but I think I can figure it out, I just need a rest thanks for the help! I think in a couple of days I'll have my first working game!

  8. #8
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    Originally posted by Eibro
    No, you'd still use spot[9]...
    0-8 = 9 elements, while 9th holds the NULL terminator.
    Only strings have a Null terminator, not 'normal' arrays.
    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.

  9. #9
    Registered User
    Join Date
    Sep 2002
    Posts
    1,640
    Originally posted by CheesyMoo
    Is goto statement for C++ like in BASIC?
    ....there is....BUT YOU MUST NOT USE IT!!!! NEVER!!!
    Use while,do or for loops instead

  10. #10
    The Pantless Man CheesyMoo's Avatar
    Join Date
    Jan 2003
    Posts
    262
    I finished it, got out most of the bugs and here it is, I think I can upload it... I don't really know how but give me your thoughts on it and any bugs you find thanks.
    Attached Files Attached Files

  11. #11
    Registered User
    Join Date
    Sep 2002
    Posts
    1,640
    I stumbled among some problems:

    You're using the old <iostream.h>, The new one is <iostream>

    You don't have 'using namespace std' but you don't specify them
    with std functions either.

    You're using the Boreland clscr(); command, i replacement is '
    system("cls");'.

    The variable 'uno' doesn't seem to be initilized.

  12. #12
    The Pantless Man CheesyMoo's Avatar
    Join Date
    Jan 2003
    Posts
    262
    My compiler won't recognize namespace std... everytme I type it in it says, bad initilazation or something like that...

  13. #13
    Registered User
    Join Date
    Sep 2002
    Posts
    1,640
    Originally posted by CheesyMoo
    My compiler won't recognize namespace std... everytme I type it in it says, bad initilazation or something like that...
    You changed <iostream.h> to <iostream>?
    You must use 'using namespace std'.

  14. #14
    The Pantless Man CheesyMoo's Avatar
    Join Date
    Jan 2003
    Posts
    262
    I type in #include <iostream>
    using namespace std;

    It says, can't find IOSTREAM
    Bad syntax,declaration error(for using namespace)

  15. #15
    Registered User
    Join Date
    Sep 2002
    Posts
    1,640
    Hm, specify your compiler.

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how do the game engine and the api interact?
    By Shadow12345 in forum Game Programming
    Replies: 9
    Last Post: 12-08-2010, 12:08 AM
  2. Open Source / Semi Open source game idea. Help needed
    By CaptainPatent in forum Projects and Job Recruitment
    Replies: 10
    Last Post: 05-16-2007, 11:44 AM
  3. game engine advice?
    By stien in forum Game Programming
    Replies: 0
    Last Post: 01-23-2007, 03:46 PM
  4. My Maze Game --- A Few Questions
    By TechWins in forum Game Programming
    Replies: 18
    Last Post: 04-25-2002, 12:00 AM

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