|
|
|
|
/*
|
|
|
|
|
--------------------------------------
|
|
|
|
|
<EFBFBD><EFBFBD> ǽ<EFBFBD><EFBFBD> 1
|
|
|
|
|
<EFBFBD><EFBFBD> Ŀ<EFBFBD>ĵ<EFBFBD> 3
|
|
|
|
|
<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> 4
|
|
|
|
|
<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD>ĵ<EFBFBD> 3+4=7
|
|
|
|
|
<EFBFBD><EFBFBD> <EFBFBD><EFBFBD> 5
|
|
|
|
|
<EFBFBD>˵<EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD>ĵ<EFBFBD> 8
|
|
|
|
|
<EFBFBD>ո<EFBFBD> · 0
|
|
|
|
|
1.<EFBFBD><EFBFBD><EFBFBD>ƹؿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ؿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>жϹؿ<EFBFBD>
|
|
|
|
|
2.<EFBFBD><EFBFBD><EFBFBD>زģ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD>İ취<EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϸ
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <conio.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <graphics.h>
|
|
|
|
|
#include <mmsystem.h>
|
|
|
|
|
#include <string>
|
|
|
|
|
#include <ctime>
|
|
|
|
|
#include <iostream>
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
|
|
#pragma comment(lib,"winmm.lib") //<2F><>̬<EFBFBD><CCAC><EFBFBD><EFBFBD>Դ
|
|
|
|
|
|
|
|
|
|
#define ROW 12
|
|
|
|
|
#define COL 12
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const int WALL = 1;
|
|
|
|
|
const int BOX = 4;
|
|
|
|
|
const int TARGET = 3;
|
|
|
|
|
const int PLAYER = 5;
|
|
|
|
|
const int EMPTY = 0;
|
|
|
|
|
|
|
|
|
|
const int _SIZE = 12;
|
|
|
|
|
int DUISHU = 3;
|
|
|
|
|
const std::vector<std::pair<int, int>> dir = { {0, 1}, {1, 0}, {0, -1}, {-1, 0} };
|
|
|
|
|
|
|
|
|
|
class MyMap {
|
|
|
|
|
public:
|
|
|
|
|
int Map[_SIZE][_SIZE]{ WALL };
|
|
|
|
|
private:
|
|
|
|
|
int X1{}, X2{}, Y1{}, Y2{};//<2F>ֱ<EFBFBD>Ϊ1<CEAA><31>2<EFBFBD><32>֮ǰ<D6AE><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
int X{}, Y{}, Direction{};//<2F><>ǰ<EFBFBD><C7B0><EFBFBD>ꡢ<EFBFBD><EAA1A2><EFBFBD><EFBFBD>
|
|
|
|
|
int PX{}, PY{};//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
int StartX{}, StartY{};//<2F><>¼<EFBFBD><C2BC><EFBFBD>㣬<EFBFBD><E3A3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
bool test() {//һ<><D2BB><EFBFBD>̶ȱ<CCB6><C8B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û
|
|
|
|
|
int test{};
|
|
|
|
|
for (int i = 0; i < _SIZE; i++) {
|
|
|
|
|
for (int j = 0; j < _SIZE; j++) {
|
|
|
|
|
if (Map[i][j] == 3)test += 1;
|
|
|
|
|
if (Map[i][j] == 4)test += 10;
|
|
|
|
|
if (Map[i][j] == 5)test += 100;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return (test == 100 + 11 * DUISHU);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool _near(int StartX, int StartY, int X, int Y) {
|
|
|
|
|
return (StartX == X + 1 && StartY == Y ||
|
|
|
|
|
StartX == X - 1 && StartY == Y ||
|
|
|
|
|
StartY == Y + 1 && StartX == X ||
|
|
|
|
|
StartY == Y - 1 && StartX == X);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void update() {
|
|
|
|
|
X2 = X1;
|
|
|
|
|
Y2 = Y1;
|
|
|
|
|
X1 = X;
|
|
|
|
|
Y1 = Y;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void change(int x, int y) {
|
|
|
|
|
if (Map[x][y] == WALL) {
|
|
|
|
|
Map[x][y] = EMPTY;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void through() {//<2F><>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD><EFBFBD>ܱߣ<DCB1>ʹ<EFBFBD><CAB9>ÿ<EFBFBD><C3BF><EFBFBD><EFBFBD><EFBFBD>Ӷ<EFBFBD><D3B6><EFBFBD><EFBFBD>ƶ<EFBFBD>
|
|
|
|
|
int dx = StartX - PX, dy = StartY - PY;
|
|
|
|
|
if (dx == 0) {
|
|
|
|
|
change(StartX + 2 * (StartX > _SIZE / 2) - 1, StartY);
|
|
|
|
|
change(StartX + 2 * (StartX > _SIZE / 2) - 1, StartY + 1);
|
|
|
|
|
change(StartX + 2 * (StartX > _SIZE / 2) - 1, StartY - 1);
|
|
|
|
|
}
|
|
|
|
|
if (dy == 0) {
|
|
|
|
|
change(StartX, StartY + 2 * (StartX > _SIZE / 2) - 1);
|
|
|
|
|
change(StartX - 1, StartY + 2 * (StartX > _SIZE / 2) - 1);
|
|
|
|
|
change(StartX + 1, StartY + 2 * (StartX > _SIZE / 2) - 1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
MyMap() {
|
|
|
|
|
for (int i = 0; i < _SIZE; i++) {
|
|
|
|
|
for (int j = 0; j < _SIZE; j++) {
|
|
|
|
|
Map[i][j] = WALL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}//<2F><>ʼ<EFBFBD><CABC>
|
|
|
|
|
|
|
|
|
|
bool generatemap(int Complexity) {
|
|
|
|
|
int time{};
|
|
|
|
|
do {//<2F><><EFBFBD><EFBFBD>
|
|
|
|
|
for (int i = 0; i < _SIZE; i++) {
|
|
|
|
|
for (int j = 0; j < _SIZE; j++) {
|
|
|
|
|
Map[i][j] = WALL;
|
|
|
|
|
}
|
|
|
|
|
}//<2F><>ʼ<EFBFBD><CABC>
|
|
|
|
|
for (int a = 0; a < DUISHU; a++)//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD>Ķ<EFBFBD><C4B6><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
do {
|
|
|
|
|
X = rand() % (_SIZE - 4) + 2;
|
|
|
|
|
Y = rand() % (_SIZE - 4) + 2;
|
|
|
|
|
time++;
|
|
|
|
|
if (time > 100) {
|
|
|
|
|
std::cout << "error" << std::endl;
|
|
|
|
|
return 0;
|
|
|
|
|
}//<2F><><EFBFBD><EFBFBD>ѭ<EFBFBD><D1AD>
|
|
|
|
|
} while (Map[X][Y] != WALL);//<2F><>ǽ<EFBFBD><C7BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
time = 0;
|
|
|
|
|
StartX = X; StartY = Y;//<2F><>¼<EFBFBD><C2BC><EFBFBD>㣬<EFBFBD><E3A3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
do {
|
|
|
|
|
int _time{};//ʵ<><CAB5><EFBFBD>˶<EFBFBD><CBB6><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
for (int i = 0; i < Complexity; i++) {
|
|
|
|
|
int temp = rand() % 6;
|
|
|
|
|
switch (temp) {
|
|
|
|
|
case 0:
|
|
|
|
|
Direction++;
|
|
|
|
|
break;
|
|
|
|
|
case 1:
|
|
|
|
|
Direction--;
|
|
|
|
|
}//<2F><><EFBFBD><EFBFBD>ֱ<EFBFBD>ߺ<EFBFBD>ת<EFBFBD><D7AA><EFBFBD>ĸ<EFBFBD><C4B8>ʣ<EFBFBD><CAA3><EFBFBD>ҪƵ<D2AA><C6B5>ת<EFBFBD><D7AA><EFBFBD>Ҳ<EFBFBD><D2B2><EFBFBD><EFBFBD><EFBFBD>ͷ
|
|
|
|
|
Direction = (4 + Direction) % 4;//<2F><>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD>
|
|
|
|
|
if (//<2F><><EFBFBD>ֲ<EFBFBD><D6B2><EFBFBD><EFBFBD>ƶ<EFBFBD><C6B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
X + dir[Direction].first <= 2 ||
|
|
|
|
|
X + dir[Direction].first >= _SIZE - 3 ||
|
|
|
|
|
Y + dir[Direction].second <= 2 ||
|
|
|
|
|
Y + dir[Direction].second >= _SIZE - 3 ||
|
|
|
|
|
Map[X + dir[Direction].first][Y + dir[Direction].second] == BOX
|
|
|
|
|
) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
update();
|
|
|
|
|
X += dir[Direction].first;
|
|
|
|
|
Y += dir[Direction].second;
|
|
|
|
|
change(X, Y);
|
|
|
|
|
change(X - 2 * dir[Direction].first, Y - 2 * dir[Direction].second);
|
|
|
|
|
if (_time > 0) {
|
|
|
|
|
change(
|
|
|
|
|
dir[Direction].first == 0 ? X2 : X - 2 * dir[Direction].first,
|
|
|
|
|
dir[Direction].second == 0 ? Y2 : Y - 2 * dir[Direction].second
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (_time == 0) {
|
|
|
|
|
PX = X - 2 * dir[Direction].first;
|
|
|
|
|
PY = Y - 2 * dir[Direction].second;
|
|
|
|
|
|
|
|
|
|
}//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
_time++;
|
|
|
|
|
}
|
|
|
|
|
Map[StartX][StartY] = BOX;
|
|
|
|
|
Map[X][Y] = TARGET;
|
|
|
|
|
} while (_near(StartX, StartY, X, Y));
|
|
|
|
|
through();
|
|
|
|
|
}
|
|
|
|
|
Map[PX][PY] = PLAYER;
|
|
|
|
|
} while (test() == 0);
|
|
|
|
|
for (int i = 0; i < _SIZE; i++)//<2F><EFBFBD>ǽ<EFBFBD><C7BD>
|
|
|
|
|
{
|
|
|
|
|
for (int j = 0; j < _SIZE; j++) {
|
|
|
|
|
if (i == 0 || j == 0 || i == _SIZE - 1 || j == _SIZE - 1) {
|
|
|
|
|
Map[i][j] = WALL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void printmap() {
|
|
|
|
|
std::cout << std::endl;
|
|
|
|
|
for (int i = 0; i < _SIZE; i++) {
|
|
|
|
|
for (int j = 0; j < _SIZE; j++) {
|
|
|
|
|
std::cout << Map[i][j] << ' ';
|
|
|
|
|
}
|
|
|
|
|
std::cout << std::endl;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>ά<EFBFBD><CEAC><EFBFBD><EFBFBD><EFBFBD>ض<EFBFBD><D8B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ
|
|
|
|
|
int cas = 0;//<2F><>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD>
|
|
|
|
|
int _count = 0;//<2F><><EFBFBD>߲<EFBFBD><DFB2><EFBFBD>
|
|
|
|
|
wchar_t result[10] = { L"0" };//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>
|
|
|
|
|
int temp_map[ROW][COL] = { 0 };//<2F><><EFBFBD><EFBFBD><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
char c[10] = { 0 };
|
|
|
|
|
int map[4][ROW][COL] = { 0 };
|
|
|
|
|
//{
|
|
|
|
|
// 1,1,1,1,1,1,1,1,
|
|
|
|
|
// 1,3,4,0,0,4,3,1,
|
|
|
|
|
// 1,0,1,3,0,1,0,1,
|
|
|
|
|
// 1,0,1,4,0,1,0,1,
|
|
|
|
|
// 1,0,0,5,0,0,0,1,
|
|
|
|
|
// 1,0,1,0,0,1,0,1,
|
|
|
|
|
// 1,3,4,0,0,4,3,1,
|
|
|
|
|
// 1,1,1,1,1,1,1,1,
|
|
|
|
|
//
|
|
|
|
|
// 1,1,1,1,1,1,1,1,
|
|
|
|
|
// 1,3,4,0,0,4,3,1,
|
|
|
|
|
// 1,0,1,3,0,1,0,1,
|
|
|
|
|
// 1,0,1,4,0,1,0,1,
|
|
|
|
|
// 1,3,4,5,0,0,0,1,
|
|
|
|
|
// 1,0,1,0,0,1,0,1,
|
|
|
|
|
// 1,3,4,0,0,4,3,1,
|
|
|
|
|
// 1,1,1,1,1,1,1,1,
|
|
|
|
|
//
|
|
|
|
|
// 1,1,1,1,1,1,1,1,
|
|
|
|
|
// 1,3,4,0,0,4,3,1,
|
|
|
|
|
// 1,0,1,3,0,1,0,1,
|
|
|
|
|
// 1,0,1,4,0,1,0,1,
|
|
|
|
|
// 1,3,4,0,0,4,3,1,
|
|
|
|
|
// 1,0,1,0,0,1,0,1,
|
|
|
|
|
// 1,3,4,5,0,4,3,1,
|
|
|
|
|
// 1,1,1,1,1,1,1,1,
|
|
|
|
|
//
|
|
|
|
|
// 1,1,1,1,1,1,1,1,
|
|
|
|
|
// 1,3,4,0,0,4,3,1,
|
|
|
|
|
// 1,0,1,3,0,1,3,1,
|
|
|
|
|
// 1,3,1,4,0,1,4,1,
|
|
|
|
|
// 1,4,0,0,0,5,0,1,
|
|
|
|
|
// 1,0,0,0,0,1,0,1,
|
|
|
|
|
// 1,3,4,0,0,4,3,1,
|
|
|
|
|
// 1,1,1,1,1,1,1,1,
|
|
|
|
|
//
|
|
|
|
|
//};
|
|
|
|
|
IMAGE img[6]; //6<><36>ͼƬ<CDBC><C6AC>6<EFBFBD><36><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
IMAGE* bacground=new IMAGE;
|
|
|
|
|
void loadResource()
|
|
|
|
|
{
|
|
|
|
|
loadimage(img + 0, L"0.bmp", 50, 50);
|
|
|
|
|
loadimage(img + 1, L"1.bmp", 50, 50);
|
|
|
|
|
loadimage(img + 2, L"3.bmp", 50, 50);
|
|
|
|
|
loadimage(img + 3, L"4.bmp", 50, 50);
|
|
|
|
|
loadimage(img + 4, L"5.bmp", 50, 50);
|
|
|
|
|
loadimage(img + 5, L"7.bmp", 50, 50);
|
|
|
|
|
loadimage(bacground, L"<EFBFBD><EFBFBD><EFBFBD><EFBFBD>.png", 50, 50);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD>Ƶ<EFBFBD>ͼ
|
|
|
|
|
void drawGraph()
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < ROW; i++)
|
|
|
|
|
{
|
|
|
|
|
for (int j = 0; j < COL; j++)
|
|
|
|
|
{
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
int x = 50 * j;
|
|
|
|
|
int y = 50 * i;
|
|
|
|
|
switch (map[cas][i][j])
|
|
|
|
|
{
|
|
|
|
|
case 0:
|
|
|
|
|
//һ<><D2BB><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
|
|
|
|
|
//printf(" ");
|
|
|
|
|
putimage(x, y, img + 0);
|
|
|
|
|
break;
|
|
|
|
|
case 1:
|
|
|
|
|
putimage(x, y, img + 1);
|
|
|
|
|
//printf("<22><>");
|
|
|
|
|
break;
|
|
|
|
|
case 3:
|
|
|
|
|
putimage(x, y, img + 2);
|
|
|
|
|
//printf("<22><>");
|
|
|
|
|
break;
|
|
|
|
|
case 4:
|
|
|
|
|
putimage(x, y, img + 3);
|
|
|
|
|
//printf("<22><>");
|
|
|
|
|
break;
|
|
|
|
|
case 5:
|
|
|
|
|
case 8:
|
|
|
|
|
putimage(x, y, img + 4);
|
|
|
|
|
//printf("<22><>");
|
|
|
|
|
break;
|
|
|
|
|
case 7:
|
|
|
|
|
putimage(x, y, img + 5);
|
|
|
|
|
//printf("<22><>");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//printf("\n");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void drawGraph1()//<2F><><EFBFBD>Ʊ<EFBFBD><C6B1><EFBFBD>ͼ
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < ROW; i++)
|
|
|
|
|
{
|
|
|
|
|
for (int j = 0; j < COL; j++)
|
|
|
|
|
{
|
|
|
|
|
int x = 50 * j;
|
|
|
|
|
int y = 50 * i;
|
|
|
|
|
putimage(x, y, bacground);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>Ϸ
|
|
|
|
|
void keyDown()
|
|
|
|
|
{
|
|
|
|
|
int userKey = _getch(); //<2F><><EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
//<2F><>λ<EFBFBD><CEBB><EFBFBD>ҵ<EFBFBD><D2B5>˵<EFBFBD>λ<EFBFBD><CEBB>
|
|
|
|
|
int i = 0;
|
|
|
|
|
int j = 0;
|
|
|
|
|
for (i = 1; i < ROW; i++)
|
|
|
|
|
{
|
|
|
|
|
for (j = 1; j < COL; j++)
|
|
|
|
|
{
|
|
|
|
|
if (map[cas][i][j] == 5 || map[cas][i][j] == 8)
|
|
|
|
|
{
|
|
|
|
|
goto NEXT;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
NEXT:
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϸ<EFBFBD><CFB7>ʲô<CAB2><C3B4><EFBFBD><EFBFBD>ȥ<EFBFBD><C8A5>
|
|
|
|
|
switch (userKey)
|
|
|
|
|
{
|
|
|
|
|
case 'W':
|
|
|
|
|
case 'w':
|
|
|
|
|
case 72:
|
|
|
|
|
if (map[cas][i - 1][j] == 0 || map[cas][i - 1][j] == 3)
|
|
|
|
|
{
|
|
|
|
|
map[cas][i][j] -= 5;
|
|
|
|
|
map[cas][i - 1][j] += 5;
|
|
|
|
|
_count++;
|
|
|
|
|
}
|
|
|
|
|
if (map[cas][i - 1][j] == 4 || map[cas][i - 1][j] == 7)
|
|
|
|
|
{
|
|
|
|
|
if (map[cas][i - 2][j] == 0 || map[cas][i - 2][j] == 3)
|
|
|
|
|
{
|
|
|
|
|
map[cas][i][j] -= 5;
|
|
|
|
|
map[cas][i - 1][j] += 1;
|
|
|
|
|
map[cas][i - 2][j] += 4;
|
|
|
|
|
_count++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 's':
|
|
|
|
|
case 'S':
|
|
|
|
|
case 80:
|
|
|
|
|
if (map[cas][i + 1][j] == 0 || map[cas][i + 1][j] == 3)
|
|
|
|
|
{
|
|
|
|
|
map[cas][i][j] -= 5;
|
|
|
|
|
map[cas][i + 1][j] += 5;
|
|
|
|
|
_count++;
|
|
|
|
|
}
|
|
|
|
|
if (map[cas][i + 1][j] == 4 || map[cas][i + 1][j] == 7)
|
|
|
|
|
{
|
|
|
|
|
if (map[cas][i + 2][j] == 0 || map[cas][i + 2][j] == 3)
|
|
|
|
|
{
|
|
|
|
|
map[cas][i][j] -= 5;
|
|
|
|
|
map[cas][i + 1][j] += 1;
|
|
|
|
|
map[cas][i + 2][j] += 4;
|
|
|
|
|
_count++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 'a':
|
|
|
|
|
case 'A':
|
|
|
|
|
case 75:
|
|
|
|
|
if (map[cas][i][j - 1] == 0 || map[cas][i][j - 1] == 3)
|
|
|
|
|
{
|
|
|
|
|
//a+=1 a=a+1 <20><><EFBFBD>ϸ<EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
map[cas][i][j] -= 5;
|
|
|
|
|
map[cas][i][j - 1] += 5;
|
|
|
|
|
_count++;
|
|
|
|
|
}
|
|
|
|
|
if (map[cas][i][j - 1] == 4 || map[cas][i][j - 1] == 7)
|
|
|
|
|
{
|
|
|
|
|
if (map[cas][i][j - 2] == 0 || map[cas][i][j - 2] == 3)
|
|
|
|
|
{
|
|
|
|
|
map[cas][i][j] -= 5;
|
|
|
|
|
map[cas][i][j - 1] += 1;
|
|
|
|
|
map[cas][i][j - 2] += 4;
|
|
|
|
|
_count++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 'd':
|
|
|
|
|
case 'D':
|
|
|
|
|
case 77:
|
|
|
|
|
if (map[cas][i][j + 1] == 0 || map[cas][i][j + 1] == 3)
|
|
|
|
|
{
|
|
|
|
|
map[cas][i][j] -= 5;
|
|
|
|
|
map[cas][i][j + 1] += 5;
|
|
|
|
|
_count++;
|
|
|
|
|
}
|
|
|
|
|
if (map[cas][i][j + 1] == 4 || map[cas][i][j + 1] == 7)
|
|
|
|
|
{
|
|
|
|
|
if (map[cas][i][j + 2] == 0 || map[cas][i][j + 2] == 3)
|
|
|
|
|
{
|
|
|
|
|
map[cas][i][j] -= 5;
|
|
|
|
|
map[cas][i][j + 1] += 1;
|
|
|
|
|
map[cas][i][j + 2] += 4;
|
|
|
|
|
_count++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case 'z'://<2F><><EFBFBD><EFBFBD>z<EFBFBD><7A><EFBFBD><EFBFBD>
|
|
|
|
|
case 'Z':
|
|
|
|
|
for (int i = 0; i < ROW; i++)
|
|
|
|
|
{
|
|
|
|
|
for (int j = 0; j < COL; j++)
|
|
|
|
|
{
|
|
|
|
|
map[cas][i][j] = temp_map[i][j];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
_count = 0;
|
|
|
|
|
for (int k = 0; k < 10; k++)
|
|
|
|
|
{
|
|
|
|
|
result[k] = 0;
|
|
|
|
|
}
|
|
|
|
|
result[0] = L'0';
|
|
|
|
|
drawGraph();
|
|
|
|
|
setbkmode(TRANSPARENT);
|
|
|
|
|
settextcolor(BLACK);
|
|
|
|
|
settextstyle(20, 0, _T("<EFBFBD><EFBFBD><EFBFBD>ź<EFBFBD>"));
|
|
|
|
|
outtextxy(145, 55, L"<EFBFBD><EFBFBD><EFBFBD>߲<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
outtextxy(230, 55, result);
|
|
|
|
|
break;
|
|
|
|
|
case 'x':
|
|
|
|
|
case 'X':
|
|
|
|
|
|
|
|
|
|
cas = 3;
|
|
|
|
|
for (int i = 0; i < ROW; i++)
|
|
|
|
|
{
|
|
|
|
|
for (int j = 0; j < COL; j++)
|
|
|
|
|
{
|
|
|
|
|
map[cas][i][j] = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//ʤ<><CAA4><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>:
|
|
|
|
|
int gameOver()
|
|
|
|
|
{
|
|
|
|
|
//<2F><>ͼ<EFBFBD><CDBC>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>ӾͿ<D3BE><CDBF>Խ<EFBFBD><D4BD><EFBFBD>
|
|
|
|
|
for (int i = 0; i < ROW; i++)
|
|
|
|
|
{
|
|
|
|
|
for (int j = 0; j < COL; j++)
|
|
|
|
|
{
|
|
|
|
|
if (map[cas][i][j] == 4)
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class Button
|
|
|
|
|
{
|
|
|
|
|
private:
|
|
|
|
|
int x; // <20><>ť<EFBFBD><C5A5><EFBFBD>Ͻ<EFBFBD>x<EFBFBD><78><EFBFBD><EFBFBD>
|
|
|
|
|
int y; // <20><>ť<EFBFBD><C5A5><EFBFBD>Ͻ<EFBFBD>y<EFBFBD><79><EFBFBD><EFBFBD>
|
|
|
|
|
int width; // <20><>ť<EFBFBD><C5A5><EFBFBD><EFBFBD>
|
|
|
|
|
int height; // <20><>ť<EFBFBD>߶<EFBFBD>
|
|
|
|
|
float scale; // <20><><EFBFBD>ű<EFBFBD><C5B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͣЧ<CDA3><D0A7>
|
|
|
|
|
bool isMouseOver; // <20><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7>ڰ<EFBFBD>ť<EFBFBD>Ϸ<EFBFBD>
|
|
|
|
|
bool has_been_clicked;//<2F><>ʾ<EFBFBD>˰<EFBFBD>ť<EFBFBD>Ƿ<C7B7><F1B1BBB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>Ѷ<EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>
|
|
|
|
|
wstring text; // <20><>ť<EFBFBD>ı<EFBFBD>
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
Button(int x, int y, int width, int height, const wstring& text)
|
|
|
|
|
: x(x), y(y), width(width), height(height), text(text), scale(1.0f), isMouseOver(false),has_been_clicked(false)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7>ڰ<EFBFBD>ť<EFBFBD>Ϸ<EFBFBD>
|
|
|
|
|
void checkMouseOver(int mouseX, int mouseY)
|
|
|
|
|
{
|
|
|
|
|
isMouseOver = (mouseX >= x && mouseX <= x + width && mouseY >= y && mouseY <= y + height);
|
|
|
|
|
|
|
|
|
|
if (isMouseOver) {
|
|
|
|
|
scale = 1.0f; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͣʱ<CDA3><CAB1><EFBFBD>Ű<EFBFBD>ť
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
scale = 1.0f; // <20>ָ<EFBFBD><D6B8><EFBFBD>ťԭʼ<D4AD><CABC>С
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7>ڰ<EFBFBD>ť<EFBFBD>ڣ<EFBFBD><DAA3><EFBFBD>ִ<EFBFBD>к<EFBFBD><D0BA><EFBFBD>
|
|
|
|
|
bool checkClick(int mouseX, int mouseY)
|
|
|
|
|
{
|
|
|
|
|
if (mouseX >= x && mouseX <= x + width && mouseY >= y && mouseY <= y + height)
|
|
|
|
|
{
|
|
|
|
|
has_been_clicked_convert();
|
|
|
|
|
isMouseOver = false;
|
|
|
|
|
scale = 1.0f;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void has_been_clicked_convert()
|
|
|
|
|
{
|
|
|
|
|
if (has_been_clicked == false)
|
|
|
|
|
has_been_clicked = true;
|
|
|
|
|
else
|
|
|
|
|
has_been_clicked = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool get_has_been_clicked()
|
|
|
|
|
{
|
|
|
|
|
return has_been_clicked;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD>ư<EFBFBD>ť
|
|
|
|
|
void draw()
|
|
|
|
|
{
|
|
|
|
|
int scaledWidth = width * scale; // <20><><EFBFBD>ź<EFBFBD><C5BA>İ<EFBFBD>ť<EFBFBD><C5A5><EFBFBD><EFBFBD>
|
|
|
|
|
int scaledHeight = height * scale; // <20><><EFBFBD>ź<EFBFBD><C5BA>İ<EFBFBD>ť<EFBFBD>߶<EFBFBD>
|
|
|
|
|
int scaledX = x + (width - scaledWidth) / 2; // <20><><EFBFBD>ź<EFBFBD><C5BA>İ<EFBFBD>ťx<C5A5><78><EFBFBD><EFBFBD>
|
|
|
|
|
int scaledY = y + (height - scaledHeight) / 2; // <20><><EFBFBD>ź<EFBFBD><C5BA>İ<EFBFBD>ťy<C5A5><79><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
if (isMouseOver || has_been_clicked)
|
|
|
|
|
{
|
|
|
|
|
setlinecolor(RGB(0, 120, 215)); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͣʱ<CDA3><CAB1>ť<EFBFBD>߿<EFBFBD><DFBF><EFBFBD>ɫ
|
|
|
|
|
setfillcolor(RGB(229, 241, 251)); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͣʱ<CDA3><CAB1>ť<EFBFBD><C5A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
setlinecolor(RGB(173, 173, 173)); // <20><>ť<EFBFBD>߿<EFBFBD><DFBF><EFBFBD>ɫ
|
|
|
|
|
setfillcolor(RGB(225, 225, 225)); // <20><>ť<EFBFBD><C5A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fillrectangle(scaledX, scaledY, scaledX + scaledWidth, scaledY + scaledHeight); // <20><><EFBFBD>ư<EFBFBD>ť
|
|
|
|
|
settextcolor(BLACK); // <20><><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><C4B1><EFBFBD>ɫΪ<C9AB><CEAA>ɫ
|
|
|
|
|
setbkmode(TRANSPARENT); // <20><><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><C4B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><CDB8>
|
|
|
|
|
settextstyle(20 * scale, 0, _T("<EFBFBD><EFBFBD><EFBFBD>ź<EFBFBD>")); // <20><><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><C4B1><EFBFBD>С<EFBFBD><D0A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>ť<EFBFBD>ı<EFBFBD>
|
|
|
|
|
int textX = scaledX + (scaledWidth - textwidth(text.c_str())) / 2; // <20><><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><C4B1>ڰ<EFBFBD>ť<EFBFBD><C5A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>x<EFBFBD><78><EFBFBD><EFBFBD>
|
|
|
|
|
int textY = scaledY + (scaledHeight - textheight(_T("<EFBFBD><EFBFBD><EFBFBD>ź<EFBFBD>"))) / 2; // <20><><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><C4B1>ڰ<EFBFBD>ť<EFBFBD><C5A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>y<EFBFBD><79><EFBFBD><EFBFBD>
|
|
|
|
|
outtextxy(textX, textY, text.c_str()); // <20>ڰ<EFBFBD>ť<EFBFBD>ϻ<EFBFBD><CFBB><EFBFBD><EFBFBD>ı<EFBFBD>
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
void play_easy()
|
|
|
|
|
{
|
|
|
|
|
const wchar_t* mapping = L"0123456789";
|
|
|
|
|
_count = 0;
|
|
|
|
|
std::srand(static_cast<unsigned int>(std::time(0)));
|
|
|
|
|
MyMap _map{};
|
|
|
|
|
DUISHU = 2;
|
|
|
|
|
for (int i = 0; i < 4; i++)
|
|
|
|
|
{
|
|
|
|
|
while (!_map.generatemap(50))
|
|
|
|
|
{
|
|
|
|
|
if (_map.generatemap(50))
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for (int j = 0; j < ROW; j++)
|
|
|
|
|
{
|
|
|
|
|
for (int k = 0; k < COL; k++)
|
|
|
|
|
{
|
|
|
|
|
map[i][j][k] = _map.Map[j][k];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < ROW; i++)
|
|
|
|
|
{
|
|
|
|
|
for (int j = 0; j < COL; j++)
|
|
|
|
|
{
|
|
|
|
|
temp_map[i][j] = map[cas][i][j];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/*Button* restart = new Button{ 100, 300, 100, 25, L"<22><><EFBFBD><EFBFBD>" };*/
|
|
|
|
|
/*ExMessage msg;*/
|
|
|
|
|
while (1)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
drawGraph();
|
|
|
|
|
setbkmode(TRANSPARENT);
|
|
|
|
|
settextcolor(BLACK);
|
|
|
|
|
settextstyle(20, 0, _T("<EFBFBD><EFBFBD><EFBFBD>ź<EFBFBD>"));
|
|
|
|
|
outtextxy(500, 570, L"<EFBFBD><EFBFBD><EFBFBD>߲<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
outtextxy(100, 570, L"<EFBFBD><EFBFBD><EFBFBD>ã<EFBFBD>Z");
|
|
|
|
|
outtextxy(200, 570, L"<EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD><EFBFBD>X");
|
|
|
|
|
int q = 0;
|
|
|
|
|
int temp = _count;
|
|
|
|
|
while (temp != 0)
|
|
|
|
|
{
|
|
|
|
|
c[q] = mapping[temp % 10];
|
|
|
|
|
temp /= 10;
|
|
|
|
|
q++;
|
|
|
|
|
}
|
|
|
|
|
if (q != 0)
|
|
|
|
|
{
|
|
|
|
|
for (int j = 0; j < q; j++)
|
|
|
|
|
{
|
|
|
|
|
result[j] = c[q - j - 1];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
outtextxy(570, 570, result);
|
|
|
|
|
if (gameOver())//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϸ<EFBFBD><CFB7><EFBFBD><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
cas++; //<2F>任<EFBFBD>ؿ<EFBFBD>
|
|
|
|
|
_count = 0;
|
|
|
|
|
for (int i = 0; i < 10; i++)
|
|
|
|
|
result[i] = 0;
|
|
|
|
|
result[0] = { L'0' };
|
|
|
|
|
for (int i = 0; i < 10; i++)
|
|
|
|
|
c[i] = 0;
|
|
|
|
|
if (cas != 4)
|
|
|
|
|
{
|
|
|
|
|
Sleep(500);
|
|
|
|
|
drawGraph();
|
|
|
|
|
setbkmode(TRANSPARENT);
|
|
|
|
|
settextcolor(BLACK);
|
|
|
|
|
settextstyle(20, 0, _T("<EFBFBD><EFBFBD><EFBFBD>ź<EFBFBD>"));
|
|
|
|
|
outtextxy(500, 570, L"<EFBFBD><EFBFBD><EFBFBD>߲<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
outtextxy(570, 570, result);
|
|
|
|
|
outtextxy(100, 570, L"<EFBFBD><EFBFBD><EFBFBD>ã<EFBFBD>Z");
|
|
|
|
|
outtextxy(200, 570, L"<EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD><EFBFBD>X");
|
|
|
|
|
for (int i = 0; i < ROW; i++)
|
|
|
|
|
{
|
|
|
|
|
for (int j = 0; j < COL; j++)
|
|
|
|
|
{
|
|
|
|
|
temp_map[i][j] = map[cas][i][j];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (cas == 4)
|
|
|
|
|
{
|
|
|
|
|
cas = 0;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
FlushBatchDraw(); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>Ļ<EFBFBD><C4BB>
|
|
|
|
|
Sleep(10);
|
|
|
|
|
keyDown();//ѭ<><D1AD><EFBFBD><EFBFBD><EFBFBD>°<EFBFBD><C2B0><EFBFBD>
|
|
|
|
|
//system("cls");
|
|
|
|
|
}
|
|
|
|
|
/*delete restart;*/
|
|
|
|
|
}
|
|
|
|
|
void play_normal()
|
|
|
|
|
{
|
|
|
|
|
const wchar_t* mapping = L"0123456789";
|
|
|
|
|
_count = 0;
|
|
|
|
|
std::srand(static_cast<unsigned int>(std::time(0)));
|
|
|
|
|
MyMap _map{};
|
|
|
|
|
DUISHU = 4;
|
|
|
|
|
for (int i = 0; i < 4; i++)
|
|
|
|
|
{
|
|
|
|
|
while (!_map.generatemap(30))
|
|
|
|
|
{
|
|
|
|
|
if (_map.generatemap(30))
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for (int j = 0; j < ROW; j++)
|
|
|
|
|
{
|
|
|
|
|
for (int k = 0; k < COL; k++)
|
|
|
|
|
{
|
|
|
|
|
map[i][j][k] = _map.Map[j][k];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for (int i = 0; i < ROW; i++)
|
|
|
|
|
{
|
|
|
|
|
for (int j = 0; j < COL; j++)
|
|
|
|
|
{
|
|
|
|
|
temp_map[i][j] = map[cas][i][j];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
while (1)
|
|
|
|
|
{
|
|
|
|
|
drawGraph();
|
|
|
|
|
setbkmode(TRANSPARENT);
|
|
|
|
|
settextcolor(BLACK);
|
|
|
|
|
settextstyle(20, 0, _T("<EFBFBD><EFBFBD><EFBFBD>ź<EFBFBD>"));
|
|
|
|
|
outtextxy(500, 570, L"<EFBFBD><EFBFBD><EFBFBD>߲<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
outtextxy(100, 570, L"<EFBFBD><EFBFBD><EFBFBD>ã<EFBFBD>Z");
|
|
|
|
|
outtextxy(200, 570, L"<EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD><EFBFBD>X");
|
|
|
|
|
int q = 0;
|
|
|
|
|
int temp = _count;
|
|
|
|
|
while (temp != 0)
|
|
|
|
|
{
|
|
|
|
|
c[q] = mapping[temp % 10];
|
|
|
|
|
temp /= 10;
|
|
|
|
|
q++;
|
|
|
|
|
}
|
|
|
|
|
if (q != 0)
|
|
|
|
|
{
|
|
|
|
|
for (int j = 0; j < q; j++)
|
|
|
|
|
{
|
|
|
|
|
result[j] = c[q - j - 1];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
outtextxy(570, 570, result);
|
|
|
|
|
if (gameOver())//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϸ<EFBFBD><CFB7><EFBFBD><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
cas++; //<2F>任<EFBFBD>ؿ<EFBFBD>
|
|
|
|
|
_count = 0;
|
|
|
|
|
for (int i = 0; i < 10; i++)
|
|
|
|
|
result[i] = 0;
|
|
|
|
|
result[0] = { L'0' };
|
|
|
|
|
for (int i = 0; i < 10; i++)
|
|
|
|
|
c[i] = 0;
|
|
|
|
|
if (cas != 4)
|
|
|
|
|
{
|
|
|
|
|
Sleep(500);
|
|
|
|
|
drawGraph();
|
|
|
|
|
setbkmode(TRANSPARENT);
|
|
|
|
|
settextcolor(BLACK);
|
|
|
|
|
settextstyle(20, 0, _T("<EFBFBD><EFBFBD><EFBFBD>ź<EFBFBD>"));
|
|
|
|
|
outtextxy(500, 570, L"<EFBFBD><EFBFBD><EFBFBD>߲<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
outtextxy(570, 570, result);
|
|
|
|
|
outtextxy(100, 570, L"<EFBFBD><EFBFBD><EFBFBD>ã<EFBFBD>Z");
|
|
|
|
|
outtextxy(200, 570, L"<EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD><EFBFBD>X");
|
|
|
|
|
for (int i = 0; i < ROW; i++)
|
|
|
|
|
{
|
|
|
|
|
for (int j = 0; j < COL; j++)
|
|
|
|
|
{
|
|
|
|
|
temp_map[i][j] = map[cas][i][j];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (cas == 4)
|
|
|
|
|
{
|
|
|
|
|
cas = 0;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
FlushBatchDraw(); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>Ļ<EFBFBD><C4BB>
|
|
|
|
|
Sleep(10);
|
|
|
|
|
keyDown();//ѭ<><D1AD><EFBFBD><EFBFBD><EFBFBD>°<EFBFBD><C2B0><EFBFBD>
|
|
|
|
|
//system("cls");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
void play_hard()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
const wchar_t* mapping = L"0123456789";
|
|
|
|
|
_count = 0;
|
|
|
|
|
std::srand(static_cast<unsigned int>(std::time(0)));
|
|
|
|
|
MyMap _map{};
|
|
|
|
|
DUISHU = 6;
|
|
|
|
|
for (int i = 0; i < 4; i++)
|
|
|
|
|
{
|
|
|
|
|
while (!_map.generatemap(8))
|
|
|
|
|
{
|
|
|
|
|
if (_map.generatemap(8))
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for (int j = 0; j < ROW; j++)
|
|
|
|
|
{
|
|
|
|
|
for (int k = 0; k < COL; k++)
|
|
|
|
|
{
|
|
|
|
|
map[i][j][k] = _map.Map[j][k];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for (int i = 0; i < ROW; i++)
|
|
|
|
|
{
|
|
|
|
|
for (int j = 0; j < COL; j++)
|
|
|
|
|
{
|
|
|
|
|
temp_map[i][j] = map[cas][i][j];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
while (1)
|
|
|
|
|
{
|
|
|
|
|
drawGraph();
|
|
|
|
|
setbkmode(TRANSPARENT);
|
|
|
|
|
settextcolor(BLACK);
|
|
|
|
|
settextstyle(20, 0, _T("<EFBFBD><EFBFBD><EFBFBD>ź<EFBFBD>"));
|
|
|
|
|
outtextxy(500, 570, L"<EFBFBD><EFBFBD><EFBFBD>߲<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
outtextxy(100, 570, L"<EFBFBD><EFBFBD><EFBFBD>ã<EFBFBD>Z");
|
|
|
|
|
outtextxy(200, 570, L"<EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD><EFBFBD>X");
|
|
|
|
|
int q = 0;
|
|
|
|
|
int temp = _count;
|
|
|
|
|
while (temp != 0)
|
|
|
|
|
{
|
|
|
|
|
c[q] = mapping[temp % 10];
|
|
|
|
|
temp /= 10;
|
|
|
|
|
q++;
|
|
|
|
|
}
|
|
|
|
|
if (q != 0)
|
|
|
|
|
{
|
|
|
|
|
for (int j = 0; j < q; j++)
|
|
|
|
|
{
|
|
|
|
|
result[j] = c[q - j - 1];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
outtextxy(570, 570, result);
|
|
|
|
|
if (gameOver())//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϸ<EFBFBD><CFB7><EFBFBD><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
cas++; //<2F>任<EFBFBD>ؿ<EFBFBD>
|
|
|
|
|
_count = 0;
|
|
|
|
|
for (int i = 0; i < 10; i++)
|
|
|
|
|
result[i] = 0;
|
|
|
|
|
result[0] = { L'0' };
|
|
|
|
|
for (int i = 0; i < 10; i++)
|
|
|
|
|
c[i] = 0;
|
|
|
|
|
if (cas != 4)
|
|
|
|
|
{
|
|
|
|
|
Sleep(500);
|
|
|
|
|
drawGraph();
|
|
|
|
|
setbkmode(TRANSPARENT);
|
|
|
|
|
settextcolor(BLACK);
|
|
|
|
|
settextstyle(20, 0, _T("<EFBFBD><EFBFBD><EFBFBD>ź<EFBFBD>"));
|
|
|
|
|
outtextxy(500, 570, L"<EFBFBD><EFBFBD><EFBFBD>߲<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
outtextxy(570, 570, result);
|
|
|
|
|
outtextxy(100, 570, L"<EFBFBD><EFBFBD><EFBFBD>ã<EFBFBD>Z");
|
|
|
|
|
outtextxy(200, 570, L"<EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD><EFBFBD>X");
|
|
|
|
|
for (int i = 0; i < ROW; i++)
|
|
|
|
|
{
|
|
|
|
|
for (int j = 0; j < COL; j++)
|
|
|
|
|
{
|
|
|
|
|
temp_map[i][j] = map[cas][i][j];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (cas == 4)
|
|
|
|
|
{
|
|
|
|
|
cas = 0;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
FlushBatchDraw(); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>Ļ<EFBFBD><C4BB>
|
|
|
|
|
Sleep(10);
|
|
|
|
|
keyDown();//ѭ<><D1AD><EFBFBD><EFBFBD><EFBFBD>°<EFBFBD><C2B0><EFBFBD>
|
|
|
|
|
//system("cls");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int main()
|
|
|
|
|
{
|
|
|
|
|
loadResource();//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD><D4B4><EFBFBD><EFBFBD>
|
|
|
|
|
//mciSendString(L"open 1.mp3", 0, 0, 0);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
//mciSendString(L"play 1.mp3 repeat", 0, 0, 0);//ѭ<><D1AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ
|
|
|
|
|
initgraph(50 * ROW, 50 * COL);
|
|
|
|
|
Button* start = new Button{ 150, 400, 100, 25, L"<EFBFBD><EFBFBD>ʼ" };
|
|
|
|
|
Button* easy = new Button{ 100, 300, 100, 25, L"<EFBFBD><EFBFBD><EFBFBD><EFBFBD>" };
|
|
|
|
|
Button* normal = new Button{ 250, 300, 100, 25, L"<EFBFBD>е<EFBFBD>" };
|
|
|
|
|
Button* hard = new Button{ 400, 300, 100, 25, L"<EFBFBD><EFBFBD><EFBFBD><EFBFBD>" };
|
|
|
|
|
Button* exit = new Button{ 350, 400, 100, 25, L"<EFBFBD>˳<EFBFBD>" };
|
|
|
|
|
while (1)
|
|
|
|
|
{
|
|
|
|
|
if (start->get_has_been_clicked())
|
|
|
|
|
start->has_been_clicked_convert();
|
|
|
|
|
if (easy->get_has_been_clicked())
|
|
|
|
|
easy->has_been_clicked_convert();
|
|
|
|
|
if (normal->get_has_been_clicked())
|
|
|
|
|
normal->has_been_clicked_convert();
|
|
|
|
|
if (hard->get_has_been_clicked())
|
|
|
|
|
hard->has_been_clicked_convert();
|
|
|
|
|
if (exit->get_has_been_clicked())
|
|
|
|
|
exit->has_been_clicked_convert();
|
|
|
|
|
drawGraph1();
|
|
|
|
|
setbkmode(TRANSPARENT);
|
|
|
|
|
settextcolor(BLACK);
|
|
|
|
|
settextstyle(50, 0, _T("<EFBFBD><EFBFBD><EFBFBD>ź<EFBFBD>"));
|
|
|
|
|
outtextxy(250, 150, L"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
ExMessage msg;
|
|
|
|
|
while (true)
|
|
|
|
|
{
|
|
|
|
|
if (peekmessage(&msg)) // <20><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
|
|
|
|
{
|
|
|
|
|
int mouseX = msg.x; // <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>x<EFBFBD><78><EFBFBD><EFBFBD>
|
|
|
|
|
int mouseY = msg.y; // <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>y<EFBFBD><79><EFBFBD><EFBFBD>
|
|
|
|
|
if (msg.message == WM_LBUTTONDOWN)
|
|
|
|
|
{
|
|
|
|
|
if (start->checkClick(mouseX, mouseY))
|
|
|
|
|
{
|
|
|
|
|
if (easy->get_has_been_clicked())
|
|
|
|
|
{
|
|
|
|
|
play_easy();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
else if (normal->get_has_been_clicked())
|
|
|
|
|
{
|
|
|
|
|
play_normal();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
else if(hard->get_has_been_clicked())
|
|
|
|
|
{
|
|
|
|
|
play_hard();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (easy->checkClick(mouseX, mouseY))
|
|
|
|
|
{
|
|
|
|
|
if (normal->get_has_been_clicked())
|
|
|
|
|
normal->has_been_clicked_convert();
|
|
|
|
|
if (hard->get_has_been_clicked())
|
|
|
|
|
hard->has_been_clicked_convert();
|
|
|
|
|
}
|
|
|
|
|
else if (normal->checkClick(mouseX, mouseY))
|
|
|
|
|
{
|
|
|
|
|
if (easy->get_has_been_clicked())
|
|
|
|
|
easy->has_been_clicked_convert();
|
|
|
|
|
if (hard->get_has_been_clicked())
|
|
|
|
|
hard->has_been_clicked_convert();
|
|
|
|
|
}
|
|
|
|
|
else if (hard->checkClick(mouseX, mouseY))
|
|
|
|
|
{
|
|
|
|
|
if (normal->get_has_been_clicked())
|
|
|
|
|
normal->has_been_clicked_convert();
|
|
|
|
|
if (easy->get_has_been_clicked())
|
|
|
|
|
easy->has_been_clicked_convert();
|
|
|
|
|
}
|
|
|
|
|
else if (exit->checkClick(mouseX, mouseY))
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (msg.message == WM_MOUSEMOVE)
|
|
|
|
|
{
|
|
|
|
|
start->checkMouseOver(mouseX, mouseY);
|
|
|
|
|
easy->checkMouseOver(mouseX, mouseY);
|
|
|
|
|
normal->checkMouseOver(mouseX, mouseY);
|
|
|
|
|
hard->checkMouseOver(mouseX, mouseY);
|
|
|
|
|
exit->checkMouseOver(mouseX, mouseY);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
start->draw(); // <20><><EFBFBD>Ƶ<EFBFBD>ǰҳ<C7B0><D2B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
easy->draw();
|
|
|
|
|
normal->draw();
|
|
|
|
|
hard->draw();
|
|
|
|
|
exit->draw();
|
|
|
|
|
FlushBatchDraw(); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>Ļ<EFBFBD><C4BB>
|
|
|
|
|
Sleep(10);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
delete start;
|
|
|
|
|
delete easy;
|
|
|
|
|
delete normal;
|
|
|
|
|
delete hard;
|
|
|
|
|
delete exit;
|
|
|
|
|
delete bacground;
|
|
|
|
|
closegraph();//<2F>رմ<D8B1><D5B4><EFBFBD>
|
|
|
|
|
return 0;
|
|
|
|
|
}
|