   Any way to make random movement for demo?
  I have an assignment that has me making my human car character move randomly for the demo mode. The way its controlled now is using the MoveCarRight() or MoveCarLeft() and using GetAsyncKeyState(VK_RIGHT) in the  functions. I tried making them equal to something for random movement, but it doesn't like the GetAsyncKeyState(VK_LEFT)= 1 or something of the sort.the function i use to make them move by human means is void MoveCarRight(){// Move the car based upon left/right key presses    POINT ptVelocity = g_pCarSprite->GetVelocity();//if (GetAsyncKeyState(VK_RIGHT) < 0)//{ // Move right ptVelocity.x = min(ptVelocity.x + 2, 6); g_pCarSprite->SetVelocity(ptVelocity);//}  }and call it by if (GetAsyncKeyState(VK_RIGHT) < 0){MoveCarRight();}Is it possible to make the movement random for a demo mode, without me pressing the buttons?   
  Couldn't you just use a timer each frame and randomly change directions every so often?//global or somethingDWORD timer = GetTickCount();srand(GetTickCount()); //seed random number generator with tick count//each frameif (timer + 1000 < GetTickCount() ) //if more than a second has passed since the last movement{ int direction =  ( rand() % 2 ) //this may not be right but I didn't look it up get a random number between 1 and 0 if (direction==0)  MoveCarRight() else if (direction==1)  MoveCarLeft()} [Edited by - yewbie on May 2, 2009 3:29:41 AM];  Have a demo boolean, and if the game is currently in demo mode, ignore the check for input and move. This would probably rely on some sort randomness to determine which direction the car should move.if (demoMode){// generate number 0-1// 0 = left, 1 = rightstatic int direction = rand() % 2;// hold the direction for anywhere between 0-1000 milliseconds// replace timeGetTime with a timer function of sorts relevant to your usestatic int holdTime = timeGetTime() + (rand() % 1001);// if the key-hold time expired...if (timeGetTime() > holdTime){// generate another directiondirection = rand() % 2;// generate another timeholdTime = timeGetTime() + (rand() % 1001);}if (direction == 0){MoveCarLeft();}else if (direction == 1){MoveCarRight();}}else{// check for human input here};  Make your own func to replace the GetKeyState function.  Inside of it, you can randomly set the "state" of the "key" and a duration.  Everytime you call the function, you can check to see if the duration has expired, then randomly set it again.   ;  I will try the random number generations above, also how can you change the key state of the function? Isnt that a library function or something?   ;  Essentially, yes. However, you can make a function that calls GetAsyncKeyState(...) if key mode isn't emulated, and artificially set key states if it is.   