Hello, i'm using VC++ 6.0 and i have a problem with pressed keys in my program. When i press some key i make my program do something. For example i have a falling circle in a timer and if i press 'Z' when the circle gets coordinate Y = 500 it makes my score increased by 100. But if i do not press 'Z' when the circle gets 500
it must make my scores = 0; I made it to increase my points, but i don't know how to make it null the scores if 'Z' is NOT pressed.
I hope someone can help me. Thanks in advance.

You can do something like this :

bool isPressedInsideCircle = false;
while( game.stillRunning() ){
   if( Z_KEY_PRESSED ){ 
      if( fallingCircleIsWithinScoreBounds() ){  
           isPressedInsideCircle = true;
           player.increaseScore();
      }
   }

  if( circleIsOutOfScreen ){
       if( isPressedInsideCircle  == false ){
                player.setScore( 0 ); 
          }
      circle.setLocation( TOP_OF_SCREEN );
   }
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.