Untitled
unknown
plain_text
2 years ago
1.2 kB
4
Indexable
#include <stdio.h> // Declare a function to handle the running animation void runAnimation() { printf("Player is running!\n"); } int main() { int isRunning = 0; // Declare a boolean variable to store the running state int input; // Declare an integer variable to store user input while (1) { // Keep looping indefinitely printf("Press '1' to start running, '2' to stop running, or '3' to quit: "); scanf("%d", &input); // Read user input if (input == 1 && !isRunning) { // If the user entered '1' and the player is not already running isRunning = 1; // Set the running state to true runAnimation(); // Call the run animation function } else if (input == 2 && isRunning) { // If the user entered '2' and the player is currently running isRunning = 0; // Set the running state to false printf("Player stopped running.\n"); } else if (input == 3) { // If the user entered '3' break; // Exit the loop and quit the program } else { // If the user entered an invalid input printf("Invalid input. Try again.\n"); } } return 0; }
Editor is loading...