答疑解惑必采纳 2021-07-13 07:50 采纳率: 91.3%
浏览 26
已采纳

c语言编一个游戏,代码部分已给出,求指导

img

img

#include <stdio.h>
#include <stdlib.h>

// Possible square states.
#define VISIBLE_SAFE 0
#define HIDDEN_SAFE 1
#define HIDDEN_MINE 2

// The size of the starting grid.
#define SIZE 8

// The possible command codes.
#define DETECT_ROW 1
#define DETECT_SQUARE 2
#define REVEAL_CROSS 3
#define GAME_MODE 4
#define FLAG_MINE 5
#define DEFUSE 6

// Add any extra #defines here.

void initialise_field(int minefield[SIZE][SIZE]);
void print_debug_minefield(int minefield[SIZE][SIZE]);

// Place your function prototyes here.

int main(void) {
int minefield[SIZE][SIZE];

initialise_field(minefield);
printf("Welcome to minesweeper!\n");
printf("How many mines? ");

// TODO: Scan in the number of pairs of mines.

printf("Enter pairs:\n");

// TODO: Scan in the pairs of mines and place them on the grid.


printf("Game Started\n");
print_debug_minefield(minefield);


// TODO: Scan in commands to play the game until the game ends.
// A game ends when the player wins, loses, or enters EOF (Ctrl+D).
// You should display the minefield after each command has been processed.


return 0;

}

// Set the entire minefield to HIDDEN_SAFE.
void initialise_field(int minefield[SIZE][SIZE]) {
int i = 0;
while (i < SIZE) {
int j = 0;
while (j < SIZE) {
minefield[i][j] = HIDDEN_SAFE;
j++;
}
i++;
}
}

// Print out the actual values of the minefield.
void print_debug_minefield(int minefield[SIZE][SIZE]) {
int i = 0;
while (i < SIZE) {
int j = 0;
while (j < SIZE) {
printf("%d ", minefield[i][j]);
j++;
}
printf("\n");
i++;
}
}

  • 写回答

1条回答 默认 最新

  • 关注

    是做什么游戏呢,存在哪些问题,可以细说一下。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 已采纳回答 7月20日
  • 创建了问题 7月13日

悬赏问题

  • ¥15 不同尺寸货物如何寻找合适的包装箱型谱
  • ¥15 求解 yolo算法问题
  • ¥15 虚拟机打包apk出现错误
  • ¥30 最小化遗憾贪心算法上界
  • ¥15 用visual studi code完成html页面
  • ¥15 聚类分析或者python进行数据分析
  • ¥15 三菱伺服电机按启动按钮有使能但不动作
  • ¥15 js,页面2返回页面1时定位进入的设备
  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。