Thread: help with some game logics

  1. #1
    Registered User
    Join Date
    Jun 2003
    Posts
    31

    help with some game logics

    Hi, I have done this function draw_random_tank() in OpenGL, this function generate random numbers and place the objects on my landscape based on the random numbers generated. My question is this, because I have some keyboard function which will call glutPostRedisplay(), every time I press the key, it invokes the glutPostRedisplay(), therefore my draw_random_tank gets called, and their position changes every time a key event is pressed. How can I fix this? thanks(sorry, this is quite a long post).
    'The bigger they are, the harder they fall' ~Yang

  2. #2
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    Placing the tank on the terrain at random sounds like it should only be done in the initialization stage of your game...not in the rendering loop and/or main game loop.

    Put this code outside of the game loop to 'setup' the game and you won't experience this problem.

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. game engine advice?
    By stien in forum Game Programming
    Replies: 0
    Last Post: 01-23-2007, 03:46 PM
  3. 2D RPG Online Game Project. 30% Complete. To be released and marketed.
    By drallstars in forum Projects and Job Recruitment
    Replies: 2
    Last Post: 10-28-2006, 12:48 AM
  4. C++ Game of Life Program
    By rayrayj52 in forum C++ Programming
    Replies: 16
    Last Post: 09-26-2004, 03:58 PM
  5. My Maze Game --- A Few Questions
    By TechWins in forum Game Programming
    Replies: 18
    Last Post: 04-24-2002, 11:00 PM