1樓:匿名使用者
#include "stdafx.h"
#include
using namespace std;
const int rows = 8,cols = 8;
hinstance hinst;
hbitmap ball;
hdc hdc,mdc,bufdc;
hwnd hwnd;
dword tpre,tnow;
char *str;
int nowpos,prepos;
bool find;
stackpath;
int mapindex[rows*cols] = ; //材8
int record[rows*cols];
atom myregisterclass(hinstance hinstance);
bool initinstance(hinstance, int);
lresult callback wndproc(hwnd, uint, wparam, lparam);
void mypaint(hdc hdc);
int apientry winmain(hinstance hinstance,
hinstance hprevinstance,
lpstr lpcmdline,
int ncmdshow)
msg msg;
myregisterclass(hinstance);
if (!initinstance (hinstance, ncmdshow))
return false;
while( msg.message!=wm_quit )
if( peekmessage( &msg, null, 0,0 ,pm_remove) )
translatemessage( &msg );
dispatchmessage( &msg );
else
tnow = gettickcount();
if(tnow-tpre >= 100)
mypaint(hdc);
return msg.wparam;
//****註冊視窗*************************
atom myregisterclass(hinstance hinstance)
wndclas*** wcex;
wcex.cbsize = sizeof(wndclas***);
wcex.style = cs_hredraw | cs_vredraw;
wcex.lpfnwndproc = (wndproc)wndproc;
wcex.cbcl***tra = 0;
wcex.cbwndextra = 0;
wcex.hinstance = hinstance;
wcex.hicon = null;
wcex.hcursor = null;
wcex.hcursor = loadcursor(null, idc_arrow);
wcex.hbrbackground = (hbrush)(color_window+1);
wcex.lpszmenuname = null;
wcex.lpszclassname = "canvas";
wcex.hiconsm = null;
return registerclas***(&wcex);
//****初始化*************************************
bool initinstance(hinstance hinstance, int ncmdshow)
hbitmap bmp;
hinst = hinstance;
cw_usedefault, 0, cw_usedefault, 0, null, null, hinstance, null);
if (!hwnd)
return false;
movewindow(hwnd,10,10,430,450,true);
showwindow(hwnd, ncmdshow);
updatewindow(hwnd);
hdc = getdc(hwnd);
mdc = createcompatibledc(hdc);
bufdc = createcompatibledc(hdc);
bmp = createcompatiblebitmap(hdc,cols*50,rows*50);
selectobject(mdc,bmp);
hbitmap tile;
int rownum,colnum;
int i,x,y;
tile = (hbitmap)loadimage(null,"tile.bmp",image_bitmap,50,50,lr_loadfromfile);
ball = (hbitmap)loadimage(null,"ball.bmp",image_bitmap,50,50,lr_loadfromfile);
for (i=0;irecord[i] = mapindex[i];
rownum = i / cols;
colnum = i % cols;
x = colnum * 50;
y = rownum * 50;
selectobject(bufdc,tile);
if(!mapindex[i])
bitblt(mdc,x,y,50,50,bufdc,0,0,srccopy);
else
if(mapindex[i] == 2)
nowpos = i;
path.push(i);
record[i] = 0;
bitblt(mdc,x,y,50,50,bufdc,0,0,whiteness);
prepos = cols * rows + 1;
mypaint(hdc);
return true;
//****核心***********************************
void mypaint(hdc hdc)
int rownum,colnum;
int x,y;
int up,down,left,right;
rownum = prepos / cols;
colnum = prepos % cols;
x = colnum * 50;
y = rownum * 50;
selectobject(bufdc,ball);
bitblt(mdc,x,y,50,50,bufdc,0,0, whiteness);
rownum = nowpos / cols;
colnum = nowpos % cols;
x = colnum * 50;
y = rownum * 50;
selectobject(bufdc,ball);
bitblt(mdc,x,y,50,50,bufdc,0,0, srccopy);
if(!find)
str = "迷宮入口";
up = nowpos - cols;
down = nowpos + cols;
left = nowpos - 1;
right = nowpos + 1;
if(up>=0 && record[up])
path.push(up);
record[up] = 0;
prepos = nowpos;
nowpos = up;
if(mapindex[nowpos] == 3)
find = true;
else if(down<=cols*rows-1 && record[down])
path.push(down);
record[down] = 0;
prepos = nowpos;
nowpos = down;
if(mapindex[nowpos] == 3)
find = true;
else if(left>=rownum*cols && record[left])
path.push(left);
record[left] = 0;
prepos = nowpos;
nowpos = left;
if(mapindex[nowpos] == 3)
find = true;
else if(right<=(rownum+1)*cols-1 && record[right])
path.push(right);
record[right] = 0;
prepos = nowpos;
nowpos = right;
if(mapindex[nowpos] == 3)
find = true;
else
if(path.size() <= 1) //
str = "***xx";
else
path.pop();
prepos = nowpos;
nowpos = path.top();
else
str = "找到出口";
textout(mdc,0,0,str,strlen(str));
bitblt(hdc,10,10,cols*50,rows*50,mdc,0,0,srccopy);
tpre = gettickcount();
//****訊息函式***********************************
lresult callback wndproc(hwnd hwnd, uint message, wparam wparam, lparam lparam)
switch (message)
case wm_keydown:
if(wparam==vk_escape)
postquitmessage(0);
break;
case wm_destroy:
deletedc(mdc);
deletedc(bufdc);
deleteobject(ball);
releasedc(hwnd,hdc);
postquitmessage(0);
break;
default:
return defwindowproc(hwnd, message, wparam, lparam);
return 0;
// 可以執行 請採納
有不懂的可以聯絡我
這個可是標準c++的 這是結果
這是源**
傳奇地下迷宮那個迷宮陣怎麼走,傳奇地下迷宮怎麼走
幻境迷宮走法 通過盟重幻境使者 344,337 可進入幻境或幻境密道,或從安全區的幻境老兵進入幻境密道。幻境1層到幻境2層從左上角座標 12.11 進入。幻境2層到幻境3層從右上角座標 362.230 進入。幻境3層到幻境4層從座標 83.83 點選幻境嚮導進入幻境4層。幻境4層到幻境5層從右上角 ...
走迷宮打一成語
迷宮裡面是彎彎繞繞,總是會把人迷暈,所以答案就是拐彎抹角。拐彎抹角 成語拼音 gu i w n m ji o 成語解釋 彎彎曲曲 繞來繞去地走。比喻說話 做事不直接了當。擴充套件資料 成語出處 元 秦簡夫 東堂老 轉彎抹角,可早來到李家門首。911cha.com 成語繁體 枴彎抹角 成語簡拼 gwm...
奧比島地下迷宮怎麼走
進去迷宮後 如圖示,方框內圖案不同 星星是向後走,月亮向前走 太陽向左走,雲向右走,你按著方框的圖案走,就能進去有水宮宮主的地方,然後把那個地方的4個方塊按下去,點選睡蓮,然後就可以拿左邊的盔甲了 選我哦!我的奧比島名字叫冰藍色呢!記得加我哦!先到外星人城堡,進入外星人指揮部,有乙個像水井蓋樣的東西...