OpenGL tic tac toe

This is a discussion on OpenGL tic tac toe within the Game Programming forums, part of the General Programming Boards category; i am making a OpenGL tic tac toe game and i would like to make a menu screen where you ...

  1. #1
    Registered User asbo60's Avatar
    Join Date
    Jan 2006
    Posts
    38

    OpenGL tic tac toe

    i am making a OpenGL tic tac toe game and i would like to make a menu screen where you could us the arrow keys to move a start(*) beside the option.

    eg.

    * Play a Single Player Game

    --Play a Multi-Player Game

    --Quit

    and the star(*) would move down when you pressed the down arrow key or up when you press the up arrow key.

    any suggestions would be nice thank you

    EDIT:
    the dashes are there just to stop it from going back
    Come give my Website a visit and try my new program, all you gamers will love it!
    www.AzA-Productions.com
    Click on applications and download Key Control!

    Also I have tons of extra space available so, if you have a project or application you want the world to see just give me an email at admin@aza-productions.com and ill see what i can do for you.

    Asbo60

  2. #2
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,074
    Quote Originally Posted by asbo60
    i am making a OpenGL tic tac toe game and i would like to make a menu screen where you could us the arrow keys to move a start(*) beside the option.

    eg.

    * Play a Single Player Game

    --Play a Multi-Player Game

    --Quit

    and the star(*) would move down when you pressed the down arrow key or up when you press the up arrow key.

    any suggestions would be nice thank you

    EDIT:
    the dashes are there just to stop it from going back
    Well, if you know how to draw text to the screen, then it's simple. Have the up/down arrow keys decrease/increase the y displacement of the '*' on the screen on the screen to meet up with each of the options, then based on those displacement coordinates, you can figure out what option is being chosen. If I recall correctly, the function is glRasterPos2f(), but personally, I think it would look much neater of you highlighted the color of the selected option instead.
    Last edited by SlyMaelstrom; 05-26-2006 at 05:32 AM.
    Sent from my iPadŽ

  3. #3
    Registered User asbo60's Avatar
    Join Date
    Jan 2006
    Posts
    38
    lol i didnt think of highlighting, i guess that would look better. but how would i go in doing that?
    Come give my Website a visit and try my new program, all you gamers will love it!
    www.AzA-Productions.com
    Click on applications and download Key Control!

    Also I have tons of extra space available so, if you have a project or application you want the world to see just give me an email at admin@aza-productions.com and ill see what i can do for you.

    Asbo60

  4. #4
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,074
    Depends on your implementation, but you may have something along these lines in your code:
    Code:
    bool  isSelected[3] = { TRUE, FALSE, FALSE };
    short int selection = 0;
    Code:
    int DrawGLScene(GLvoid)
    {
    	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    	glLoadIdentity();
    	glTranslatef(0.0f,0.0f,-1.0f);
    	
    	glColor3f(0.0f, 0.0f, isSelected[0] ? 1.0f : 0.5f);
    	glRasterPos2f(-0.1f, 0.1f);
     	glPrint("New Game");
     	
     	glColor3f(0.0f, 0.0f, isSelected[1] ? 1.0f : 0.5f);
    	glRasterPos2f(-0.1f, 0.0f);
     	glPrint("Load Game");
     	
     	glColor3f(0.0f, 0.0f, isSelected[2] ? 1.0f : 0.5f);
    	glRasterPos2f(-0.1f, -0.1f);
     	glPrint("Exit Game");
    	return TRUE;
    }
    ...and psudocode for you keypresses may be
    Code:
    if (UP is pressed) {
      isSelected[selection] = !isSelected[selection];
      if (selection > 0)
        selection = selection - 1;
      else 
        selection = 2;
      isSelected[selection] = !isSelected[selection];
    }
    if (DOWN is pressed) {
      isSelected[selection] = !isSelected[selection];
      if (selection < 2)
        selection = selection + 1;
      else 
        selection = 0;
      isSelected[selection] = !isSelected[selection];
    }
    if (ENTER is pressed) {
       switch (selection) {
          case 0:
             NewGame();
          case 1:
             LoadGame();
          case 2:
             return 0;
       }
    }
    Just to give you an idea of what would be going on.
    Last edited by SlyMaelstrom; 05-27-2006 at 02:42 PM.
    Sent from my iPadŽ

  5. #5
    Registered User asbo60's Avatar
    Join Date
    Jan 2006
    Posts
    38
    that worked perfectly with a little Sleep Function in each if statements

    thanks for the help
    Come give my Website a visit and try my new program, all you gamers will love it!
    www.AzA-Productions.com
    Click on applications and download Key Control!

    Also I have tons of extra space available so, if you have a project or application you want the world to see just give me an email at admin@aza-productions.com and ill see what i can do for you.

    Asbo60

  6. #6
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,074
    Avoid using sleep functions to slow it down. Try thinking of a logical way of making holding a key no different than tapping it.
    Sent from my iPadŽ

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help me with my simple Tic tac toe prog
    By maybnxtseasn in forum C Programming
    Replies: 2
    Last Post: 04-04-2009, 06:25 PM
  2. tic tac toe crashes :(
    By stien in forum Game Programming
    Replies: 4
    Last Post: 05-13-2007, 06:25 PM
  3. Help with Tic Tac Toe game
    By snef73 in forum C++ Programming
    Replies: 1
    Last Post: 04-25-2003, 08:33 AM
  4. my tic tac toe game, please try it
    By Leeman_s in forum C++ Programming
    Replies: 2
    Last Post: 04-14-2002, 05:16 PM
  5. Tic Tac Toe Help
    By aresashura in forum C++ Programming
    Replies: 1
    Last Post: 11-21-2001, 11:52 AM

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