初學c 乙個簡單的掃雷遊戲

2021-10-10 04:37:27 字數 1412 閱讀 5140

寫了乙個簡單的掃雷遊戲,可以控制棋盤大小和雷的數量。

1. 標頭檔案 game.h

#ifndef _game_h_

#define _game_h_

#include

#include

#pragma warning(disable:4996)

#include

#include

#define col 12

#define row 12

//掃雷棋盤大小(row-2)x(col-2) 這裡為 10x10大小

#define nums 20

//雷的總數為nums

void

menu()

;void

game()

;#endif

2.主函式 main.c

#include

"game.h"

intmain1()

}printf

("遊戲結束 , 拜拜!\n");

system

("pause");

return0;

}

3.具體遊戲設計 game.c

#include

"game.h"

void

menu()

void

setmines

(char board[

][col]

,int row,

int col)}}

void

showboard

(char board[

][col]

,int row,

int col)

printf

("\n-------------------------------------------\n");

}}intgetnums

(char board[

][col]

,int row,

int col,

int x,

int y)

void

game()

if(show_board[x]

[y]!=

'*')

if(mine_board[x]

[y]==

'0')

if(mine_board[x]

[y]==

'1')

count--;}

while

(count);if

(count ==0)

}

記乙個簡單的掃雷遊戲

遊戲概述 每次輸入乙個座標,必然要判斷當前座標是不是雷,如果不是就要顯示當前座標和其周圍8個非雷座標點的周圍8個點的雷的數量。分為三部分 game.h ifndef game h define game h include include include include pragma warning...

c 實現掃雷遊戲 初學

全域性變數定義地圖和一些判斷資訊 建立三個地圖 分別表示 源地圖 顯示的效果地圖 和乙個用來判斷點位是否被選中的地圖 玩家輸入要翻開的格仔的行數和列數。用乙個函式來翻開目標格仔,如果是地雷遊戲失敗,可以選擇是否重新遊戲並且重新整理乙個新的隨機地圖,否則用乙個函式統計目標格仔周圍的地雷數。如果周圍沒有...

用C語言寫乙個簡單的掃雷小遊戲

define crt secure no warnings include include include 用 c 語言寫乙個簡單的掃雷遊戲 1.寫乙個遊戲選單 menu 2.開始遊戲 1.初始化二維陣列 init inte ce 2.列印遊戲介面 print inte ce 3.玩家掀起指定位置 ...