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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
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)

Can I see visitors in WeChat Moments? Can I see visitors in WeChat Moments? May 06, 2024 pm 01:30 PM

1. WeChat is a social platform that pays attention to privacy protection. Users cannot see who has visited their Moments or personal homepage. 2. This design is intended to protect user privacy and avoid potential harassment or snooping. 3. Users can only see the likes and comments records in their circle of friends, further ensuring the confidentiality of personal information.

How does WeChat know that the other party has read it? How does WeChat know that the other party has read it? Apr 24, 2024 pm 01:45 PM

1. When the other party is using WeChat, the prompt "The other party is typing" will be displayed below the user's message, which indicates that the other party may have seen the message sent by the user. 2. If the message is sent during the other party's active period and the other party does not reply for a long time, it means that the other party may have read the message but chose not to reply for some reason. 3. If the other party frequently updates the status of other platforms but ignores WeChat messages, it means that the other party has probably seen the message but chose not to reply for some reason.

There are rumors that 'iPhone 16 may not support WeChat', and Apple's technical consultant in China said that it is communicating with Tencent about app store commissions There are rumors that 'iPhone 16 may not support WeChat', and Apple's technical consultant in China said that it is communicating with Tencent about app store commissions Sep 02, 2024 pm 10:45 PM

Thanks to netizens Qing Qiechensi, HH_KK, Satomi Ishihara and Wu Yanzu of South China for submitting clues! According to news on September 2, there are recent rumors that "iPhone 16 may not support WeChat." In response to this, a reporter from Shell Finance called Apple's official hotline. Apple's technical consultant in China responded that whether iOS systems or Apple devices can continue to use WeChat, and WeChat The issue of whether it can continue to be listed and downloaded on the Apple App Store requires communication and discussion between Apple and Tencent to determine the future situation. Software App Store and WeChat Problem Description Software App Store technical consultant pointed out that developers may need to pay fees to put software on the Apple Store. After reaching a certain number of downloads, Apple will need to pay corresponding fees for subsequent downloads. Apple is actively communicating with Tencent,

Did you know that the person you blocked on WeChat has been restored? Did you know that the person you blocked on WeChat has been restored? Apr 24, 2024 pm 01:34 PM

1. After WeChat restores the blocked person, the blocked party will not receive any prompts or notifications, nor will they be aware that they have been blocked. 2. If you want to confirm whether you have been blocked by someone, you can verify it through indirect methods, such as checking the other party's circle of friends, sending messages, etc.

deepseek image generation tutorial deepseek image generation tutorial Feb 19, 2025 pm 04:15 PM

DeepSeek: A powerful AI image generation tool! DeepSeek itself is not an image generation tool, but its powerful core technology provides underlying support for many AI painting tools. Want to know how to use DeepSeek to generate images indirectly? Please continue reading! Generate images with DeepSeek-based AI tools: The following steps will guide you to use these tools: Launch the AI ​​Painting Tool: Search and open a DeepSeek-based AI Painting Tool (for example, search "Simple AI"). Select the drawing mode: select "AI Drawing" or similar function, and select the image type according to your needs, such as "Anime Avatar", "Landscape"

How to set WeChat background image How to set WeChat background image Apr 26, 2024 am 11:01 AM

1. Open the WeChat app, click [Me] at the bottom of the interface, and select the [Settings] function. 2. Click [Chat], click [Chat Background] to enter the chat background setting interface. 3. Click [Select Background Image] or [Select from Album] or [Take a Photo]. 4. Select and click the picture you want to use, and then click [Use] in the upper right corner.

How to recover deleted chat history on WeChat How to recover deleted chat history on WeChat May 06, 2024 pm 01:29 PM

1. To recover deleted WeChat chat history, you need to use two mobile phones for data migration. 2. On the old phone, click [Me] → [Settings] → [Chat] → [Chat History Migration and Backup]. 3. Select [Migrate] and set the target device platform. After selecting the chat history to be restored, click [Start]. 4. Then log in to the same account on the new phone and scan the QR code on the old phone to start the migration. 5. After the migration is completed, the deleted chat history will be restored to the new phone.

Is WeChat Lingqiantong safe? Is WeChat Lingqiantong safe? Apr 29, 2024 am 10:23 AM

1. WeChat Lingqiantong adopts a multi-layer security mechanism, including password protection, real-name authentication, mobile phone binding, etc., to ensure the security of user accounts. 2. WeChat Pay uses a variety of encryption methods, including SSL encrypted transmission, real-time monitoring, etc., to ensure transaction security. 3. WeChat Pay also cooperates with banks and financial institutions to implement risk control and prevention measures to monitor and handle abnormal transactions. 4. When using WeChat Lingqiantong, users should also strengthen the protection of personal accounts, set complex passwords, change passwords regularly, and not disclose personal information at will.

See all articles