C++加EasyX实现多关卡推箱子(包括撤回,存档功能)

C++加EasyX实现多关卡推箱子,包括撤回,存档功能。

#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <string>
#include <graphics.h>
#include <conio.h>
#include <fstream>
using namespace std;
const int Length = 5, width = 12, height = 16;
/*-------------------------按钮---------------------------*/
class  Button
{
   
	int Buttonwidth = 80;
	int  Buttonheight = 40;
	const char* str;
	int x, y;
public:
	Button(int x, int y, const char* str, int Buttonwidth = 80, int  Buttonheight = 40)
	{
   
		this->x = x;
		this->y = y;
		this->str = str;
		this->Buttonwidth = Buttonwidth;
		this->Buttonheight = Buttonheight;
	}
	//位置(x,y)处画按钮
	void drawButton() 
	{
   
		setfillcolor(WHITE);
		fillrectangle(x, y, x + Buttonwidth, y + Buttonheight);
		setbkmode(TRANSPARENT);
		RECT r1 = {
    x,y,x + Buttonwidth,y + Buttonheight };
		settextstyle(20, 0, _T("华文楷体"),0,0,100,false, false, false);
		settextcolor(BLACK);
		drawtext(str, &r1, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
	}
};
//判断点(x,y)是不是在按钮(bx,by)范围内
bool judgeButton(int x, int y, int bx, int by, int Buttonwidth = 80, int  Buttonheight = 40) {
   
	if (x >= bx && x <= bx + Buttonwidth && y >= by && y <= by + Buttonheight)
		return true;
	return false;
}
/*---------------------------图片输出的类----------------------------*/
class PRINT
{
   
	int X, Y;
	int XX, YY;
	int t;
	int x, y;
	int n, m;
	const int fangcun = 40;
	char CH;
	IMAGE xiaozhi, wasi, jinglingqiuK, jinglingqiuP, qiang, pikaqiu, jinglingqiu, bai;
public:
	void sdfs(int t, int const& width, int const& height,
		char const CH, int const WIDTH, int const HEIGHT)
	{
   
		this->x = 0;
		this->y = 0;
		this->m = width;
		this->n = height;
		this->t = t;
		this->CH = CH;
		this->X = WIDTH;
		this->Y = HEIGHT;
		loadimage(&qiang, "qiang.jpg", fangcun, fangcun);
		loadimage(&jinglingqiuK, "jinglingqiuk.jpg", fangcun, fangcun);
		loadimage(&bai, "bai.jpg", fangcun, fangcun);
		loadimage(&xiaozhi, "xiaozhi1.jpg", fangcun, fangcun);
		loadimage(&jinglingqiuP, "jinglingqiuP.jpg", fangcun, fangcun);
		loadimage(&pikaqiu, "pikaqiu.jpg", fangcun, fangcun);
	}
	void Tihuan(char(*A)[width][height])
	{
   
		for (x = 0; x < n; x++)
			for (y = 0; y < m; y++)
			{
   
				switch (A[t][y][x])
				{
   
				case '#':
					putimage(x * fangcun, y * fangcun, &qiang);
					break;
				case 'S':
					putimage(x * fangcun, y * fangcun, &xiaozhi);
					break;
				case 'O':
					putimage(x * fangcun, y * fangcun, &pikaqiu);
					break;
				case '*':
					putimage(x * fangcun, y * fangcun, &jinglingqiuK);
					break;
				case '@':
					putimage(x * fangcun, y * fangcun, &jinglingqiuP);
					break;
				case '1':
					putimage(x * fangcun, y * fangcun, &bai);
					break;
				}
			}
	}
};
/*-----------------------------------------------------------------------------------------------------*/
class observers
{
   
public:
	void Step(int& X, int& Y, char ch)
	{
   
		switch (ch)
		{
   
		case 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值