推箱子遊戲使用C語言實現的簡單例項

2021-08-31 13:39:04 字數 1803 閱讀 5877

/*

1.遊戲實現步驟

1).遊戲一開始,就顯示遊戲地圖。

while(1)

2.根據步驟 搭建專案框架

*/#include #include #include//行和列,該遊戲一共有10行、10列。

#define row 10

#define col 11

//初始化乙個地圖

char map[row][col] = ;

//列印地圖

void showmap();

//接收小人的方向

char enterdirection();

//小人向上移動的方法

void movetoup();

//小人向下移動的方法

void movetodown();

//小人向右移動的方法

void movetoright();

//小人向左移動的方法

void movetoleft();

//當前小人的座標

int currentpersonrow = 3;

int currentpersoncol = 2;

//當前箱子的座標

int currentboxrow = 3;

int currentboxcol = 3;

int main(int argc, char *argv)

//showmap();

if (currentboxrow == 8 & currentboxcol == 9) }}

/*方法的實現

*///列印地圖

void showmap()

printf("\n\n\n\n\n");

printf("w:上,s:下, a:左, d:右。q:退出");

printf("\n\n\n\n\n");

}//接收小人的方向

char enterdirection()

//小人向上移動的方法

void movetoup()

//如果小人的下乙個座標是牆

if (map[nextpersonrow][nextpersoncol] == '#')

//如果小人的下乙個座標是箱子

if (map[nextpersonrow][nextpersoncol] == 'x') }}

//小人向下移動的方法

void movetodown()

//如果小人的下乙個座標是牆

if (map[nextpersonrow][nextpersoncol] == '#')

//如果小人的下乙個座標是箱子

if (map[nextpersonrow][nextpersoncol] == 'x') }}

//小人向右移動的方法

void movetoright()

//如果小人的下乙個座標是牆

if (map[nextpersonrow][nextpersoncol] == '#')

//如果小人的下乙個座標是箱子

if (map[nextpersonrow][nextpersoncol] == 'x') }}

//小人向左移動的方法

void movetoleft()

//如果小人的下乙個座標是牆

if (map[nextpersonrow][nextpersoncol] == '#')

//如果小人的下乙個座標是箱子

if (map[nextpersonrow][nextpersoncol] == 'x')

}}

C語言實現推箱子遊戲

hello,程式設計小白的我又回來了,繼上次的c語言迷宮文章,我沉寂了兩天,這次帶來的是用c語言實現小時候的推箱子遊戲,中間挺難的,條件寫了刪,刪了寫,沒頭緒的時候都想放棄了,但我堅信寫的出迷宮的我也能寫出這個推箱子,哈哈,終於功夫不負有心人,在又乙個早上後,終於搞定了!下面我們來聊聊這個玩法簡單的...

C語言實現推箱子小遊戲

include include include define n 1000 r目的地 o箱子 i人 x牆 路 空格 w上 a左 d右 s下 void menu int level1 int level2 void swap char char int opera char p,int ren,int...

C語言實現推箱子

二 實現 在網上學習並完成這個推箱子的小遊戲,記錄下來 1 easyx圖形庫工具 2 vs2013及以上都可以 include include include include resource.h include pragma comment lib,winmm.lib int arr 10 10 ...