basically I need to implement a pause feature in my game (which is a simplified version of frogger) which stops the logs scrolling, and ignores any other input until the character p is pressed again). The way I've started to implement this in a while loop is to end it once another p Is pressed.
if(serial_input == 'p' || serial_input == 'P') {
while(1){
//need to pause the game
if(serial_input == 'p' || serial_input == 'P')
break;
}
This is how my logs are currently scrolling: /* The following statements change the scrolling speeds of the individual logs */
current_time = get_clock_ticks();
if(is_frog_alive() && current_time >= last_move_time1 + 1000) {
scroll_lane(0, 1);
last_move_time1 = current_time;
} else if(is_frog_alive() && current_time >= last_move_time2 + 600) {
scroll_lane(1, -1);
last_move_time2 = current_time;
} else if(is_frog_alive() && current_time >= last_move_time3 + 800) {
scroll_lane(2, 1);
last_move_time3 = current_time;
} else if(is_frog_alive() && current_time >= last_move_time4 + 900) {
scroll_log_channel(0, -1);
last_move_time4 = current_time;
} else if(is_frog_alive() && current_time >= last_move_time5 + 1200) {
scroll_log_channel(1, 1);
last_move_time5 = current_time;
And this is implemented by a timer as described:
* We update a global clock tick variable - whose value
* can be retrieved using the get_clock_ticks() function.
*/
Any suggestions would be greatly appreciated