当前位置:网站首页>Simple Lianliankan games based on QT

Simple Lianliankan games based on QT

2022-06-26 20:59:00 biyezuopinvip

Resource download address :https://download.csdn.net/download/sheziqiong/85788216
Resource download address :https://download.csdn.net/download/sheziqiong/85788216

Simple Lianliankan games .

Overall process

Realize the idea :

Define game model class and game window class , Use the buttons to complete the game interface settings

Algorithm

Mainly in the storage of icons and the judgment of confusion and connection

Storage and disorder of icons : Using one-dimensional array , Assign values to the array two by two , It is a pair of icons , Assign values to an array 1~ Number of icons ICON, The values in the array correspond to the corresponding numbered pictures . Then generate random numbers , Swap the values of array elements in pairs , Achieve disruption

Connection judgment : There are three main types of connections : Straight line connection 、 Connect after turning once 、 Turn twice and connect , As follows :

① Direct connection :

Case 1: Judge that the array element values on the line are all 0.

Case 2: Judge that the array element values on the line are all 0.

Connect after turning once :

Order of switching points before connection , Make the point with the smaller abscissa in front .

Case 3: The connection first turns right and then up or down , Judge the inflection point as 0, Then judge the inflection point and the starting point 、 The ends are connected in a straight line .

Case 4: The connection goes up or down and then turns right , Judge the inflection point as 0, Then judge the inflection point and the starting point 、 The ends are connected in a straight line .

③ Turn twice and connect :

The same sequence of switching points before connection , Make the point with the smaller abscissa in front .

Case 5: Go up or down to a point first , Take a turn to the end ( The points that the connection passes through initially store pictures ).

Case 6: Go left or right to a point first , Take a turn to the end ( The points that the connection passes through initially store pictures ).

Case 7、8、9、10: When connecting, the connection passes through the area where the icon is not stored

unit testing

Output through the application , Generate window , Play games

unit testing

test result

The game can run normally , Each button can be used normally

Harvest

Use multiple at the same time for the first time .cpp File implementations call each other

Learned the game design concept of separating the game model from the form

To study the Qt Many functions of the button class
Normal use

Harvest

Use multiple at the same time for the first time .cpp File implementations call each other

Learned the game design concept of separating the game model from the form

To study the Qt Many functions of the button class

Resource download address :https://download.csdn.net/download/sheziqiong/85788216
Resource download address :https://download.csdn.net/download/sheziqiong/85788216

原网站

版权声明
本文为[biyezuopinvip]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/177/202206262033101929.html