Table of Contents
The method of developing and implementing the 2048 game on WeChat public platform
Home Backend Development PHP Tutorial Methods for developing and implementing 2048 games on WeChat public platform_PHP tutorial

Methods for developing and implementing 2048 games on WeChat public platform_PHP tutorial

Jul 13, 2016 am 09:57 AM
WeChat

The method of developing and implementing the 2048 game on WeChat public platform

The details are as follows:

1. Overview of 2048 Game

"2048" is a popular digital game. The original version of 2048 was first released on github. The original author is Gabriele Cirulli. It is a new digital game developed based on the gameplay of "1024" and "Little 3 Legend".

Subsequently, various versions of 2048 appeared on various major platforms. The version ported to iOS by Ketchapp is the most popular, with about 10 million downloads now, and its name is exactly the same as the original version. The most famous of the derivative versions is the "2048 Hexagon" version, which has ranked among the top 200 board games in 81 countries around the world. The very popular Android version is "Challenge 2048", which has added two-player battles since version 2.0.0. The second, more special one is the 2048 Chinese Dynasty Edition. There is also a 2048 customized version, where you can define your own text and pictures. "2048" is a popular one on iOS.

HOW TO PLAY:Use yourarrow keys to move the tiles. When two tiles with the same number touch, theymerge into one!
NOTE:This site is the official version of 2048. You can play it on your phone via.All other apps or sites are derivatives or fakes, and should be used with caution.
Created by Gabriele Cirulli.Based on 1024 by Veewo Studioand conceptually similar to Threes by Ashe Vollmer.

The game rules are very simple. You can choose one of the up, down, left, or right directions to slide each time. Every time you slide, all the number squares will move closer to the sliding direction. The system will also randomly appear a number square in the blank space. The same Numbered squares will add up when they come close to each other and collide. The number cubes given by the system are either 2 or 4. Players have to find a way to make up the number cube "2048" in this small 16-frame range.

The screen of the game is very simple. At the beginning, most of the 16 squares are gray. When the player appears in the puzzle, the color will change. The overall style is very simple.

The gameplay rules are also very simple. At the beginning, two small numbers, such as 2 or 4, will appear in the square. Players only need to move the appearing numbers in one direction, up, down, left, or right, and all the numbers will slide in the direction. The direction is closer, and a number will appear randomly in the blank square that slides out. When the same numbers collide, they will be superimposed and moved closer. And then it will continue like this. The number 2048 will be pieced together after continuous superposition, which is considered successful.

If you are a numbers enthusiast, or a relatively talented math genius, you will be fascinated by it as soon as you get started. Even if you are not a math genius, ordinary players can play this game. If you are interested, download it and experience it.

微信公众平台开发实现2048游戏的方法 帮客之家

Currently this game is open source, so there is no need to re-develop it

2. WeChat public platform

Put the 2048 source code on your own server and get the game url.

When the user follows, the user will be prompted to reply 2048 to play this game,

When the user replies to 2048, reply with a picture and text message with a 2048 game link in the picture and text.

The complete code is shown below.

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

/*

方倍工作室

CopyRight 2014 All Rights Reserved

*/

define("TOKEN", "weixin");

$wechatObj = new wechatCallbackapiTest();

if (!isset($_GET['echostr'])) {

$wechatObj->responseMsg();

}else{

$wechatObj->valid();

}

class wechatCallbackapiTest

{

//验证签名

public function valid()

{

$echoStr = $_GET["echostr"];

$signature = $_GET["signature"];

$timestamp = $_GET["timestamp"];

$nonce = $_GET["nonce"];

$token = TOKEN;

$tmpArr = array($token, $timestamp, $nonce);

sort($tmpArr);

$tmpStr = implode($tmpArr);

$tmpStr = sha1($tmpStr);

if($tmpStr == $signature){

echo $echoStr;

exit;

}

}

//响应消息

public function responseMsg()

{

$postStr = $GLOBALS["HTTP_RAW_POST_DATA"];

if (!empty($postStr)){

$postObj = simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA);

$RX_TYPE = trim($postObj->MsgType);

 

//消息类型分离

switch ($RX_TYPE)

{

case "event":

$result = $this->receiveEvent($postObj);

break;

case "text":

$result = $this->receiveText($postObj);

break;

}

echo $result;

}else {

echo "";

exit;

}

}

//接收事件消息

private function receiveEvent($object)

{

$content = "";

switch ($object->Event)

{

case "subscribe":

$content = "欢迎关注方倍工作室n回复 2048 开始游戏";

break;

}

if(is_array($content)){

if (isset($content[0])){

$result = $this->transmitNews($object, $content);

}else if (isset($content['MusicUrl'])){

$result = $this->transmitMusic($object, $content);

}

}else{

$result = $this->transmitText($object, $content);

}

return $result;

}

//接收文本消息

private function receiveText($object)

{

$keyword = trim($object->Content);

 

if (strstr($keyword, "2048")){

$content = array();

$content[] = array("Title"=>"2048 Game", "Description"=>"The game rules are very simple. Each time you can choose one of the directions to slide up, down, left, or right. Each time you slide, all In addition to the number squares moving closer to each other in the sliding direction, the system will also randomly appear a number square in the blank space. When the squares with the same number come closer and collide, the number squares given by the system are either 2 or 4. Players have to. Find a way to make up the number square "2048" in this small 16-frame range. "Url" =>"http://gabrielecirulli.github.io/2048/");

}else{

$content = date("Y-m-d H:i:s",time())."nTechnical support Fangbei Studio";

}

if(is_array($content)){

if (isset($content[0]['PicUrl'])){

$result = $this->transmitNews($object, $content);

}else if (isset($content['MusicUrl'])){

$result = $this->transmitMusic($object, $content);

}

}else{

$result = $this->transmitText($object, $content);

}

}

//Reply to text message

private function transmitText($object, $content)

{

$xmlTpl = "

%s

";

$result = sprintf($xmlTpl, $object->FromUserName, $object->ToUserName, time(), $content);

return $result;

}

//Reply to graphic message

private function transmitNews($object, $newsArray)

{

if(!is_array($newsArray)){

return;

}

$itemTpl = "

<![CDATA[%s]]>

";

$item_str = "";

foreach ($newsArray as $item){

$item_str .= sprintf($itemTpl, $item['Title'], $item['Description'], $item['PicUrl'], $item['Url']);

}

$xmlTpl = "

%s

%s

$item_str

";

$result = sprintf($xmlTpl, $object->FromUserName, $object->ToUserName, time(), count($newsArray));

return $result;

}

}

?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/984501.htmlTechArticleThe specific methods for developing and implementing the 2048 game on the WeChat public platform are as follows: 1. Overview of the 2048 game "2048" is relatively popular A numbers game. The original version 2048 was first released on github, the original author...
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1670
14
PHP Tutorial
1274
29
C# Tutorial
1256
24
What is the difference between H5 page production and WeChat applets What is the difference between H5 page production and WeChat applets Apr 05, 2025 pm 11:51 PM

H5 is more flexible and customizable, but requires skilled technology; mini programs are quick to get started and easy to maintain, but are limited by the WeChat framework.

How to solve the problem of JS resource caching in enterprise WeChat? How to solve the problem of JS resource caching in enterprise WeChat? Apr 04, 2025 pm 05:06 PM

Discussion on the JS resource caching issue of Enterprise WeChat. When upgrading project functions, some users often encounter situations where they fail to successfully upgrade, especially in the enterprise...

Is the company's security software causing the application to fail to run? How to troubleshoot and solve it? Is the company's security software causing the application to fail to run? How to troubleshoot and solve it? Apr 19, 2025 pm 04:51 PM

Troubleshooting and solutions to the company's security software that causes some applications to not function properly. Many companies will deploy security software in order to ensure internal network security. ...

The difference between H5 and mini-programs and APPs The difference between H5 and mini-programs and APPs Apr 06, 2025 am 10:42 AM

H5. The main difference between mini programs and APP is: technical architecture: H5 is based on web technology, and mini programs and APP are independent applications. Experience and functions: H5 is light and easy to use, with limited functions; mini programs are lightweight and have good interactiveness; APPs are powerful and have smooth experience. Compatibility: H5 is cross-platform compatible, applets and APPs are restricted by the platform. Development cost: H5 has low development cost, medium mini programs, and highest APP. Applicable scenarios: H5 is suitable for information display, applets are suitable for lightweight applications, and APPs are suitable for complex functions.

Ouyi Exchange app domestic download tutorial Ouyi Exchange app domestic download tutorial Mar 21, 2025 pm 05:42 PM

This article provides a detailed guide to safe download of Ouyi OKX App in China. Due to restrictions on domestic app stores, users are advised to download the App through the official website of Ouyi OKX, or use the QR code provided by the official website to scan and download. During the download process, be sure to verify the official website address, check the application permissions, perform a security scan after installation, and enable two-factor verification. During use, please abide by local laws and regulations, use a safe network environment, protect account security, be vigilant against fraud, and invest rationally. This article is for reference only and does not constitute investment advice. Digital asset transactions are at your own risk.

What should I do if the company's security software conflicts with applications? How to troubleshoot HUES security software causes common software to fail to open? What should I do if the company's security software conflicts with applications? How to troubleshoot HUES security software causes common software to fail to open? Apr 01, 2025 pm 10:48 PM

Compatibility issues and troubleshooting methods for company security software and application. Many companies will install security software in order to ensure intranet security. However, security software sometimes...

What are the development tools for H5 and mini program? What are the development tools for H5 and mini program? Apr 06, 2025 am 09:54 AM

H5 development tools recommendations: VSCode, WebStorm, Atom, Brackets, Sublime Text; Mini Program Development Tools: WeChat Developer Tools, Alipay Mini Program Developer Tools, Baidu Smart Mini Program IDE, Toutiao Mini Program Developer Tools, Taro.

Detailed tutorial on how to buy and sell Binance virtual currency Detailed tutorial on how to buy and sell Binance virtual currency Mar 18, 2025 pm 01:36 PM

This article provides a brief guide to buying and selling of Binance virtual currency updated in 2025, and explains in detail the operation steps of virtual currency transactions on the Binance platform. The guide covers fiat currency purchase USDT, currency transaction purchase of other currencies (such as BTC), and selling operations, including market trading and limit trading. In addition, the guide also specifically reminds key risks such as payment security and network selection for fiat currency transactions, helping users to conduct Binance transactions safely and efficiently. Through this article, you can quickly master the skills of buying and selling virtual currencies on the Binance platform and reduce transaction risks.

See all articles