Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# Qt-version-dependent debugging output
build-PictureMatching3-Desktop_Qt_5_11_1_MinGW_32bit-Debug/

# Qt Creator config
*.pro.user
## E.g. PictureMatching\PictureMatching3\PictureMatching3.pro.user

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down
10 changes: 5 additions & 5 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ Copyright (c) 2017 ThreeDog
<threedog>->https://www.github.com/TheThreeDog wrote this file.
As long as you retain this notice you can do whatever you want with this stuff.
If we meet some day, and you think this stuff is worth it, you can buy me a super bottles of Sprite in return.
fork from:https://en.wikipedia.org/wiki/Beerware & https://github.com/bitdust/WamaCry/blob/master/LICENSE.txt
of course, you can copy this and modify it again.
Forked from: https://en.wikipedia.org/wiki/Beerware & https://github.com/bitdust/WamaCry/blob/master/LICENSE.txt
Of course, you can copy this and modify it again.

“雪碧软件协议”(第一版):
<threedog>->https://www.github.com/TheThreeDog 编写了此文件。
只要你还保留本协议文本,你可以以使用此软件做任何事
只要你还保留本协议文本,你可以使用此软件做任何事
如果我们在某一天相遇了,而且你认为此软件很有价值,你可以为我买一大瓶雪碧来答谢。
此协议抄袭自:https://en.wikipedia.org/wiki/Beerware 和 https://github.com/bitdust/WamaCry/blob/master/LICENSE.txt
当然,你可以按照你的喜好来修改此协议.
此协议抄袭自 https://en.wikipedia.org/wiki/Beerware 和 https://github.com/bitdust/WamaCry/blob/master/LICENSE.txt
当然你可以按照你的喜好来修改此协议
28 changes: 22 additions & 6 deletions PictureMatching3/gamemain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,15 @@
#include <QDebug>

#include <iostream>
using namespace std;
using std::cout;
using std::endl;
using std::min;
using std::max;

#include <tuple>
using std::tuple;
using std::make_tuple; // variables -> tuple
using std::tie; // tuple -> variables

GameMain::GameMain(QWidget *parent)
:TDWidget(":/img/game_main_with_logo.png",parent)
Expand Down Expand Up @@ -73,23 +81,31 @@ void GameMain::createItems()
}
//方块的图片是随机的。
}

// 坐标转位置
tuple<int,int,int,int> coordicateToIndex(MyItem *item1, MyItem *item2){
int x1 = (item1->x()-100)/65; // Gee, magic number 100, 65
int y1 = (item1->y()-100)/65;
int x2 = (item2->x()-100)/65;
int y2 = (item2->y()-100)/65;
return make_tuple(x1,y1,x2,y2);
}

//判断可以连通的函数
bool GameMain::canConnect(MyItem *item1, MyItem *item2)
{
//先校验指针不为空
if(item1 == NULL || item2 == NULL)
return false;
//提取两个方块数组中所处的位置
int x1 = (item1->x()-100)/65;
int y1 = (item1->y()-100)/65;
int x2 = (item2->x()-100)/65;
int y2 = (item2->y()-100)/65;
int x1,y1,x2,y2;
tie(x1,y1,x2,y2) = coordicateToIndex(item1,item2);
// bool ret = false;
// ret = canConnect(x1,x2,y2,y2);
// return ret;
return canConnect(x1,y1,x2,y2);

}

//重载一个连通函数接口
bool GameMain::canConnect(int x1, int y1, int x2, int y2)
{
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
- 一个王者荣耀风格的连连看游戏,实现了连连看的基本算法和功能。超过十秒没有消除就会游戏失败。全部消除游戏成功。提供重新开始、重新排列、提示(会直接消除两个方块)退出游戏的功能。

## 说明:
- 开发平台: Windows 7 X64.
- 开发平台: Windows 7 x64.
- 开发环境: Qt 5.7
- 游戏中所有的代码以及资源文件均已开源,可自行下载,欢迎更多的学习交流。

## 用法:
- 使用Qt打开项目.pro文件,编译运行。
- 使用 Qt Creator 打开项目 `.pro` 文件,编译运行。

## 项目截图:
![项目截图1](show/show_1.jpg)
Expand All @@ -20,4 +20,4 @@
![项目截图4](show/show_4.jpg)

## 开源协议:
- 雪碧软件协议
- [雪碧软件协议](./LICENSE)