加中实训(1)

#include "StdAfx.h"
#include"Function.h"


void Maze :: SetMap(int( * map)[WIDETH])//定义Maze类中的SetMap函数
{
	Judger = true;
	for(int width = 0;width < WIDETH;width++)
		for(int height = 0;height < HEIGHT ;height++)
		{
			MAP[height][width] = map[height][width];
		}

}
void Maze :: SetPoint(int x,int y)//定义Maze类中的SetPoint函数
{
	iPoint.x = x;
	iPoint.y = y;

}
void Maze :: MoveUp(HWND hWnd)//定义Maze类中的MoveUp函数
{
	int num = Num.size();

	switch(MAP[iPoint.y-1][iPoint.x])
	{
	case CHANNEL : //通道
		if(Judger == true)
			iPoint.y--;
		break;
	case EXIT ://出口
		iPoint.y--;
		InvalidateRect(hWnd,NULL,FALSE);
		MessageBox (NULL, TEXT ("恭喜你成功走出迷宫!"), TEXT ("胜利"), 0);
		Judger = false;
		Num.clear();
		break;
	case KEY1 ://铲子1
		Num.push_back(MAP[iPoint.y-1][iPoint.x]);
		MAP[iPoint.y-1][iPoint.x] = CHANNEL;
		iPoint.y--;
		break;
	case DOOR1 ://蘑菇1
		for(int i = 0;i<num;i++)
			if((MAP[iPoint.y-1][iPoint.x]-1) == Num[i])
			{
				MAP[iPoint.y-1][iPoint.x] = CHANNEL;
				iPoint.y--;
			}
		break;
	case KEY2 ://铲子2
		Num.push_back(MAP[iPoint.y-1][iPoint.x]);
		MAP[iPoint.y-1][iPoint.x] = CHANNEL;
		iPoint.y--;
		break;
	case DOOR2 ://蘑菇2
		for(int i = 0;i<num;i++)
			if((MAP[iPoint.y-1][iPoint.x]-1) == Num[i])
			{
				MAP[iPoint.y-1][iPoint.x] = CHANNEL;
				iPoint.y--;
			}
		break;
	case KEY3 ://铲子3
		Num.push_back(MAP[iPoint.y-1][iPoint.x]);
		MAP[iPoint.y-1][iPoint.x] = CHANNEL;
		iPoint.y--;
		break;
	case DOOR3 ://蘑菇3
		for(int i = 0;i<num;i++)
			if((MAP[iPoint.y-1][iPoint.x]-1) == Num[i])
			{
				MAP[iPoint.y-1][iPoint.x] = CHANNEL;
				iPoint.y--;
			}
		break;
	}
	
		
}
void Maze :: MoveDown(HWND hWnd)//定义Maze类中的MoveDown函数
{
	int num = Num.size();
	switch(MAP[iPoint.y+1][iPoint.x])
	{
	case CHANNEL : //通道
		if(Judger == true)
			iPoint.y++;
		break;
	case EXIT ://出口
		iPoint.y++;
		InvalidateRect(hWnd,NULL,FALSE);
		MessageBox (NULL, TEXT ("恭喜你成功走出迷宫!"), TEXT ("胜利"), 0);
		Judger = false;
		Num.clear();
		break;
	case KEY1 ://铲子1
		Num.push_back(MAP[iPoint.y+1][iPoint.x]);
		MAP[iPoint.y+1][iPoint.x] = CHANNEL;
		iPoint.y++;
		break;
	case DOOR1 ://蘑菇1
		for(int i = 0;i<num;i++)
			if((MAP[iPoint.y+1][iPoint.x]-1) == Num[i])
			{
				MAP[iPoint.y+1][iPoint.x] = CHANNEL;
				iPoint.y++;
			}
		break;
	case KEY2 ://铲子2
		Num.push_back(MAP[iPoint.y+1][iPoint.x]);
		MAP[iPoint.y+1][iPoint.x] = CHANNEL;
		iPoint.y++;
		break;
	case DOOR2 ://蘑菇2
		for(int i = 0;i<num;i++)
			if((MAP[iPoint.y+1][iPoint.x]-1) == Num[i])
			{
				MAP[iPoint.y+1][iPoint.x] = CHANNEL;
				iPoint.y++;
			}
		break;
	case KEY3 ://铲子3
		Num.push_back(MAP[iPoint.y+1][iPoint.x]);
		MAP[iPoint.y+1][iPoint.x] = CHANNEL;
		iPoint.y++;
		break;
	case DOOR3 ://蘑菇3
		for(int i = 0;i<num;i++)
			if((MAP[iPoint.y+1][iPoint.x]-1) == Num[i])
			{
				MAP[iPoint.y+1][iPoint.x] = CHANNEL;
				iPoint.y++;
			}
		break;
	}

}
void Maze :: MoveLeft(HWND hWnd)//定义Maze类中的 MoveLeft函数
{
	int num = Num.size();
	switch(MAP[iPoint.y][iPoint.x-1])
	{
	case CHANNEL : //通道
		if(Judger == true)
			iPoint.x--;
		break;
	case EXIT ://出口
		iPoint.x--;
		InvalidateRect(hWnd,NULL,FALSE);
		MessageBox (NULL, TEXT ("恭喜你成功走出迷宫!"), TEXT ("胜利"), 0);
		Judger = false;
		Num.clear();
		break;
	case KEY1 ://铲子1
		Num.push_back(MAP[iPoint.y][iPoint.x-1]);
		MAP[iPoint.y][iPoint.x-1] = CHANNEL;
		iPoint.x--;
		break;
	case DOOR1 ://蘑菇1
		for(int i = 0;i<num;i++)
			if((MAP[iPoint.y][iPoint.x-1]-1) == Num[i])
			{
				MAP[iPoint.y][iPoint.x-1] = CHANNEL;
				iPoint.x--;
			}
		break;
	case KEY2 ://铲子2
		Num.push_back(MAP[iPoint.y][iPoint.x-1]);
		MAP[iPoint.y][iPoint.x-1] = CHANNEL;
		iPoint.x--;
		break;
	case DOOR2 ://蘑菇2
		for(int i = 0;i<num;i++)
			if((MAP[iPoint.y][iPoint.x-1]-1) == Num[i])
			{
				MAP[iPoint.y][iPoint.x-1] = CHANNEL;
				iPoint.x--;
			}
		break;
	case KEY3 ://铲子3
		Num.push_back(MAP[iPoint.y][iPoint.x-1]);
		MAP[iPoint.y][iPoint.x-1] = CHANNEL;
		iPoint.x--;
		break;
	case DOOR3 ://蘑菇3
		for(int i = 0;i<num;i++)
			if((MAP[iPoint.y][iPoint.x-1]-1) == Num[i])
			{
				MAP[iPoint.y][iPoint.x-1] = CHANNEL;
				iPoint.x--;
			}
		break;
	}


}
void Maze :: MoveRight(HWND hWnd)//定义Maze类中的MoveRight函数
{
	int num = Num.size();
	switch(MAP[iPoint.y][iPoint.x+1] )
	{
	case CHANNEL : //通道
		if(Judger == true)
			iPoint.x++;
		break;
	case EXIT ://出口
		iPoint.x++;
		InvalidateRect(hWnd,NULL,FALSE);
		MessageBox (NULL, TEXT ("恭喜你成功走出迷宫!"), TEXT ("胜利"), 0);
		Judger = false;
		Num.clear();
		break;
	case KEY1 ://铲子1
		Num.push_back(MAP[iPoint.y][iPoint.x+1]);
		MAP[iPoint.y][iPoint.x+1] = CHANNEL;
		iPoint.x++;
		break;
	case DOOR1 ://蘑菇1
		for(int i = 0;i<num;i++)
			if((MAP[iPoint.y][iPoint.x+1]-1) == Num[i])
			{
				MAP[iPoint.y][iPoint.x+1] = CHANNEL;
				iPoint.x++;
			}
		break;
	case KEY2 ://铲子2
		Num.push_back(MAP[iPoint.y][iPoint.x+1]);
		MAP[iPoint.y][iPoint.x+1] = CHANNEL;
		iPoint.x++;
		break;
	case DOOR2 ://蘑菇2
		for(int i = 0;i<num;i++)
			if((MAP[iPoint.y][iPoint.x+1]-1) == Num[i])
			{
				MAP[iPoint.y][iPoint.x+1] = CHANNEL;
				iPoint.x++;
			}
		break;
	case KEY3 ://铲子3
		Num.push_back(MAP[iPoint.y][iPoint.x+1]);
		MAP[iPoint.y][iPoint.x+1] = CHANNEL;
		iPoint.x++;
		break;
	case DOOR3 ://蘑菇3
		for(int i = 0;i<num;i++)
			if((MAP[iPoint.y][iPoint.x+1]-1) == Num[i])
			{
				MAP[iPoint.y][iPoint.x+1] = CHANNEL;
				iPoint.x++;
			}
		break;
	}

}

你可能感兴趣的:(null,include)