c语言贪吃蛇游戏主页面
时间: 2023-08-16 13:28:53 浏览: 48
好的,以下是一个简单的 C 语言贪吃蛇游戏主页面的示例代码:
```c
#include <stdio.h>
#include <stdlib.h>
int main() {
printf("Welcome to the Snake Game!\n");
printf("==========================\n");
printf("1. New Game\n");
printf("2. High Scores\n");
printf("3. Exit\n");
int choice;
printf("Enter your choice (1-3): ");
scanf("%d", &choice);
switch (choice) {
case 1:
printf("Starting a new game...\n");
// TODO: Start the game
break;
case 2:
printf("Displaying high scores...\n");
// TODO: Display high scores
break;
case 3:
printf("Exiting the game...\n");
exit(0);
default:
printf("Invalid choice! Please enter a number between 1 and 3.\n");
break;
}
return 0;
}
```
这段代码会输出一个简单的菜单,让用户选择开始新游戏、查看高分榜还是退出游戏。用户输入选择后,程序会进入相应的分支执行相应的操作。在这个示例代码中,只是输出了相应的提示信息,实际的游戏逻辑还需要在相应的分支中实现。