簡易版推箱子

2021-08-14 10:48:39 字數 1301 閱讀 6532

最近學了一些c語言的視覺化程式設計,因此編了小遊戲玩玩,途中也遇到了一些問題,要記得放的時候要把存在資料夾裡,這些可以只寫相對路徑,不然如果直接寫相對路徑而又忘記把放在資料夾裡就不能夠顯示出想要的結果。廢話了這麼多,是時候上**了

#include#include#includeimage backimg, wall, blank, box, people, end, dbox;

const int rows = 7;

const int cols = 8;

// 0 空地, 1 牆, 3 目的地, 4 箱子, 5 人

int map[7][8] = ;

//載入資源

void loadimg()

//初始化遊戲介面

void initgame()

} }}//玩遊戲

//上下左右-------w s a d

//ascii碼:上:72 下:80 左:75 右:77

void playgame()

if (map[i][j] == 5 || map[i][j] == 8)

break;

} initgame();

user = _getch();

switch (user)

else if (map[i][j - 1] == 4 || map[i][j - 1] == 7)

}break;

case 77:

case 'd':

case 'd':

if (map[i][j + 1] == 0 || map[i][j + 1] == 3)

else if (map[i][j + 1] == 4 || map[i][j + 1] == 7)

}break;

case 72:

case 'w':

case 'w':

if (map[i - 1][j] == 0 || map[i - 1][j] == 3)

else if (map[i - 1][j] == 4 || map[i - 1][j] == 7)

}break;

case 80:

case 's':

case 's':

if (map[i + 1][j] == 0 || map[i + 1][j] == 3)

else if (map[i + 1][j] == 4 || map[i + 1][j] == 7)

}break;

} }}int main()

注釋有點少,希望大家不要介意,畢竟萌新。

簡易版推箱子問題

房間是n 行n列的矩陣,其中0代表空的地板,1代表牆,2代表箱子的起始位置,3代表箱子要被推去的位置,4代表搬運工的起始位置,求最後搬運工推箱子的步數。問題實質就是五個狀態 箱子的位置 bx,by 人的位置 px,py 推箱子的步數。然後用廣搜去一一搜尋。include include includ...

推箱子遊戲(簡易)

標頭檔案 boxman.h define key up w define key down s define key left a define key right d define key quite q define map x 9 define map y 12 define ratio 61...

推箱子(歐冠版)

簡單遊戲推箱子,老樣子。分檔案編寫 ifndef box h define box h include include 該標頭檔案只在cpp檔案中使用 畫圖標頭檔案 include 清屏 標頭檔案 include 聲音輸入 pragma comment lib,winmm.lib pragma wa...