Quick Question...

This is a discussion on Quick Question... within the Game Programming forums, part of the General Programming Boards category; Satisfy my curiosity on this one: I have more or less just started out learning C++. I am going through ...

  1. #1
    Registered User
    Join Date
    Apr 2004
    Posts
    20

    Question Quick Question...

    Satisfy my curiosity on this one:

    I have more or less just started out learning C++. I am going through the tutorials on this site and I'm pretty much halfway through.
    I continue learning and programming simple console applications every night I can, which averages out to about 2 hours a day.

    About how long until I am able to program a Tetris clone from scratch? All I'm looking for is an estimation. Base it on your own experiance if you want.

    Please note that I realize the amount of experiance I have is negligible. I am not expecting to hear that the answer in weeks. Nor am I feeling impatient. I am just curious.

  2. #2
    mov.w #$1337,D0 Jeremy G's Avatar
    Join Date
    Nov 2001
    Posts
    704
    Really the answer depends entirely on you. Because unless you are working towards makeing a tetris clone you will never do it. Search the forum for tetris, and you'll find sources and topics from people that have done it. Use their code to learn whats going on and try tomake your own. If you are dead set on making the clone, you could make one in 3 days easily.
    c++->visualc++->directx->opengl->c++;
    (it should be realized my posts are all in a light hearted manner. And should not be taken offense to.)

  3. #3
    Registered User
    Join Date
    Apr 2004
    Posts
    20
    Thanks

    I wanted to know after reading this article:
    http://www.gamedev.net/reference/des...ames/page2.asp

    I don't mean to be pushy, but a second answer would be appreciated. Take a look, and you may get an idea of what I mean. I'm sure I could rig together a tetris clone in a few days, but I think that for it to actually be a milestone in understanding, I need to be at a certain point in learning before undertaking the project.
    So about how long until that point, or is it truly impossible to tell and I just have to be satisfied with that?

  4. #4
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596
    If you understand arrays you can program tetris.


    Here is a simple way to draw the board - 10x10 tiles. I'm not sure the exact dimensions of a tetris board but we will go with 20 across by 50 down or 200x500 pixels.

    Code:
    //This code assumes Board is a 2D array
    //It could be a 1D accessed in 2D, but I didn't do it for clarity's 
    //sake
    void DrawBoard(int startx,int starty)
    {
      int x=startx;
      int y=starty;
    
      int cellvalue=0;
      int boxcolor=0;
    
      for (int i=0;i<20;i++)
      {
         for (int j=0;j<50;j++)
        {
           boxcolor=Board[i][j];
           DrawFilledBox(x,y,x+9,y+9,boxcolor);
           x+=10;
        }
        x=startx;
        y+=10;
      }
    }
    Last edited by VirtualAce; 04-12-2004 at 11:58 PM.

  5. #5
    Registered User heat511's Avatar
    Join Date
    Dec 2001
    Posts
    169
    personally, i'd try doing this one on your own w/o looking at other people's work. ill give you a few hints tho. use a 3x3 character array to hold the X's and the 0's. then you can draw the rest of the board w/ little |'s. you can have the person enter the coordinates of where they want to place an X or O.
    "uh uh uh, you didn't say the magic word"
    -Jurassic Park

  6. #6
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596
    TicTacToe.h
    Code:
    #ifndef _TICTACTOE_
    #define _TICTACTOE_
    
    #define ROWCOLTOMEM (row,col) ((row)*(3)+(col))
    
    #define FAILURE 1
    #define SUCCESS 0
    #define EMPTY 0
    #define FULL 1
    #define XPIECE 1
    #define YPIECE 2
    
    class TicTacToe
    {
       protected:
         unsigned char *Board;
         int numslotsfree;
      public:
         TicTacToe(void);
         ~TicTacToe(void);
         int Init(void);
         unsigned char GetBoardValue(int row,int col);
         int SetBoardValue(int row,int col);
         
         //You figure these out
         int CheckForWin(void)=0;
         void SaveToDisk(void)=0;
         void LoadFromDisk(void)=0;
    };
    #endif
    TicTacToe.cpp
    Code:
    #include "TicTacToe.h"
    
    TicTacToe::TicTacToe(void)
    {
      Board=0;
      numslotsfree=0;
    }
    
    TicTacToe::~TicTacToe(void)
    {
      if (Board) delete [] Board;
    }
    
    int TicTacToe::Init(void)
    {
      numslotsfree=9;
      Board=new unsigned char[9];
      if (!Board) return FAILURE
      else return SUCCESS;
    }
    
    unsigned char TicTacToe::GetBoardValue(int row,int col)
    {
      return Board[ROWCOLTOMEM(row,col)];
    }
    
    int TicTacToe::SetBoardValue(int row,int col,int value)
    {
       Board[ROWCOLTOMEM(row,col)]=value;
    }
    Player.h
    Code:
    #ifndef _PLAYER_
    #define _PLAYER_
    
    #include "TicTacToe.h"
    
    class Player
    {
        protected:
          unsigned char *name;
          int piecevalue;
        public:
          Player(void);
          ~Player(void) {};
          void Init(unsigned char *_name,int _piecevalue);
          int Move(TicTacToe *_gameptr,int row,int col);
    };
    #endif
    Player.cpp
    Code:
    #include "Player.h"
    
    Player::Player(void) 
    {
      name=0;
      piecevalue=0;
    }
    
    void Player::Init(unsigned char * _name,int _piecevalue)
    {
      name=_name;
      piecevalue=_piecevalue;
    }
    
    int Player::Move(TicTacToe *_gameptr,int row,int col)
    {
       int testvalue=gameptr->GetBoardValue(row,col);
       if (testvalue==EMPTY)
       {
           gameptr->SetBoardValue(row,col,piecevalue);
           return(SUCCESS);
       } else return(FULL);
    }
    That is a very good start for you.
    Last edited by VirtualAce; 04-13-2004 at 11:58 PM.

  7. #7
    Registered User
    Join Date
    Mar 2004
    Posts
    50
    I thought he said Tetris.

    anyway, here is my advice.

    I am a newbie, like you. I found a great Tetris tutorial of step by step of how to make the game. It is the best that I have ever seen. I found it last night and I am basically moving along just like you.

    here is the address:

    http://triplebuffer.devmaster.net/ar...is_in_an_hour/


    I haven't completely dug into it yet but I will soon.

    For me, it would be nice to do it from scratch but I don't want to spend the rest of the month learning Tetris when by the end of the month I could be doing pong or another game and learning AI or soemthing.

  8. #8
    Registered User
    Join Date
    Apr 2004
    Posts
    20
    It's not that I really desire to program tetris. All I want is to have an estimation as to how long it will be until I can actually understand how it works. For instance, that tutorial is all greek to me. All I have done so far is simple console applications.

  9. #9
    mov.w #$1337,D0 Jeremy G's Avatar
    Join Date
    Nov 2001
    Posts
    704
    I've been toying around with an equation that I think will answer your question.

    Code:
    let c be equal to your competency level //(1[best] being john carmack, and any number higher less then bill gates by that many times. ie: 100 would be 100 times less competent)
    let wastedTime = (((days spent asking how long it will take) / 24 ) /60) / 60)
    let learnMins = (hours spent learning <insert language>)/60
    let difficultyRatio = (difficulty rating / (1/c)) //1 would be guess numbers text game, 10000 would be unreal tourny 2004 or halflife 2, or quake 4
    
    time(seconds)  = (15*difficultyRatio) - ((86400/learnMins)*60)+ wastedTime;
    
    This is a serious equation. Assuming john carmack has 10 years experience with c/c++, 0 time wasted, a level 300 game (tetris), it would take him 15 minutes to make the game.
    time(seconds) = (15*300) - (((86400/86400)*60)*60) + 0
    Last edited by dbgt goten; 04-14-2004 at 02:15 PM.
    c++->visualc++->directx->opengl->c++;
    (it should be realized my posts are all in a light hearted manner. And should not be taken offense to.)

  10. #10
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    >let wastedTime = (((days spent asking how long it will take) / 24 ) /60) / 60)
    >let learnMins = (hours spent learning <insert language>)/60
    Bzzt. Wrong. You need to multiply, not divide. Geez. Basic math stuff here.

    Also, your formula is completely b0rked.
    >time(seconds) = (15*difficultyRatio) - ((86400/learnMins)*60)+ wastedTime;
    So, if I spent 1 minute learning the language, making a difficulty 300 program, with no wasted time, it'd take me -5179500 seconds to write. Wow.
    Last edited by XSquared; 04-14-2004 at 02:38 PM.
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  11. #11
    Registered User
    Join Date
    Apr 2004
    Posts
    20
    ...Interesting.

    In a note of defense, I am still learning while asking my question. The wastedTime part seems flawed.

  12. #12
    mov.w #$1337,D0 Jeremy G's Avatar
    Join Date
    Nov 2001
    Posts
    704
    Quote Originally Posted by XSquared
    >Bzzt. Wrong. You need to multiply, not divide. Geez. Basic math stuff here.

    So, if I spent 1 minute learning the language, making a difficulty 300 program, with no wasted time, it'd take me -5179500 seconds to write. Wow.

    Seriously it was a joke. The idea was to say spend less time asking how long it will take, and more time actually doing it.

    Heh, yeah the math was all fuxored. I wrote it in 30 seconds, more of a typo then anything dividing instead of multiplying. But either way its not important. The important thing is - get to work already.
    c++->visualc++->directx->opengl->c++;
    (it should be realized my posts are all in a light hearted manner. And should not be taken offense to.)

  13. #13
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596
    Okay I saw X's and O's and just assumed we changed to Tic Tac Toe. Guess not.

    Anyways you've got a great start for tic tac toe.



Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Very quick math question
    By jverkoey in forum A Brief History of Cprogramming.com
    Replies: 8
    Last Post: 10-26-2005, 11:05 PM
  2. very quick question.
    By Unregistered in forum C++ Programming
    Replies: 7
    Last Post: 07-24-2002, 03:48 AM
  3. quick question
    By Unregistered in forum C++ Programming
    Replies: 5
    Last Post: 07-22-2002, 04:44 AM
  4. Quick Question Regarding Pointers
    By charash in forum C++ Programming
    Replies: 4
    Last Post: 05-04-2002, 11:04 AM
  5. Quick question: exit();
    By Cheeze-It in forum C Programming
    Replies: 6
    Last Post: 08-15-2001, 05:46 PM

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