The development of micro-credit public platform to realize the 2048 game method

Source: Internet
Author: User
Tags exit cdata sprintf trim valid

Specifically as follows:

First, 2048 game overview

"2048" is a more popular digital game. The original 2048 first published on the GitHub, the original author is Gabriele Cirulli. It is based on the "1024" and "Small 3 legends" of the play developed by the new digital game.

Then 2048 appeared various versions, take each big platform. The version of Ketchapp, which was ported to iOS by the company, is the hottest, with about 10 million downloads now, the same name as the original. The most notable of the derivative editions is the 20,486-side version, which has ranked the top 200 in board game in 81 countries around the world. Android version is very popular with the "Challenge 2048", its 2.0.0 version also joined the two-person battle. Second, there are more special 2048 Chinese dynasty edition. There are more than 2048 custom editions, you can define text and pictures yourself. "2048" is one of the popular models in iOS.

How to Play:use yourarrow keysto move the tiles. When two tiles and the same number touch, theymerge into one!
Note:this site is the official version of 2048. Can play it on your phone via. All other apps or sites are derivatives or fakes, and should is used with caution.
Created by Gabriele cirulli.based in 1024 by Veewo Studioand conceptually similar to threes by Ashe.

The rules of the game is very simple, each can choose to go up and down in one direction to slide, each slide once, all the number of squares will move towards the direction of the slide, the system will be in the blank place a number of Chaos Number box, the same number of squares in close, collision will add. The system gives the number box is not 2 is 4, the player wants to find a way in this small 16 lattice range to gather out "2048" this number square.

The screen of the game is very simple, the beginning of the whole 16 squares are mostly gray, when the number of players in the puzzle will change color, the overall style is very simple.

In the rules of play is also very simple, the first square will appear in 2 or 4 of these two small numbers, players only need to move up or down one of the direction of the number, all the numbers will be in the direction of the slide, and the slide out of the blank box will randomly appear a number, the same number of collisions will overlap, And then all the way, the constant superposition eventually pieced together 2048 of this number even if successful.

If you are a digital enthusiast, or a gifted mathematical genius, you will be fascinated by it. Even if not a mathematical genius, the average player can also play the game, interested in the download experience.

The current game is open source, so there's no need to recreate it.

Second, micro-trust public platform

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

When the user is concerned, prompt reply 2048 can play this game,

When the user replies 2048, reply The text message, the picture and text with 2048 game links.

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 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 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 The 96 97 98 99 100 101 102 103 104 105 106 107 108 109 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-1 MB 143 144 <?php/* Square Times Studio CopyRight 2014 All Rights Reserved * * Define ("TOKEN", "Weixin"); $WECHATOBJ = new Wechatcallbackapitest (); if (!isset ($_get[' echostr ')) {$WECHATOBJ->responsemsg ();} else{$wechatObj->valid ();} class Wechatcallbackapitest {//Verify signature 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;}} Response message Public Function responsemsg () {$postStr = $GLOBALS [' Http_raw_post_data ']; if (!empty ($POSTSTR)) {$POSTOBJ = simple Xml_load_string ($postStr, ' simplexmlelement ', libxml_nocdata); $RX _type = Trim ($postObj->msgtype);  //Message type separation switch ($RX _type) {case ' event ': $result = $this->receiveevent ($POSTOBJ); break; case "text": $result = $this->receivetext ($POSTOBJ); Break echo $result; }else {EchO ""; Exit }///Receive event message Private function Receiveevent ($object) {$content = ""; Switch ($object->event) {case "subscribe": $content = "Welcome to square Times Studio N reply 2048 start game"; break;} if (Is_array ($content)) {if (i Sset ($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; //Receive text message Private function Receivetext ($object) {$keyword = Trim ($object->content)   if (Strstr ($keyword, "2048 ")) {$content = array (); $content [] = Array ("Title" => "2048 games", "Description" => "game rule is very simple, each can choose to go up and down in one direction to slide, each slide once, all the number of squares will move towards the direction of sliding, The system will also be in the blank place a number of random number of squares, the same number of squares in close, collision will add. The system gives the number box is not 2 is 4, the player wants to find a way in this small 16 lattice range to gather out "2048" this number square. "," Picurl "=>" Http://img.laohu.com/www/201403/27/1395908994962.png "," Url "=>" http:// gabrielecirulli.github.io/2048/"); }else{$content = Date ("Y-m-d h:i:s", Time ()). " N Technical Support Square times 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 text message private function Transmittext ($object, $content) {$xmlTpl = "<xml> <tousername><![ Cdata[%s]]></tousername> <fromusername><! [cdata[%s]]></fromusername> <CreateTime>%s</CreateTime> <msgtype><! [cdata[text]]></msgtype> <content><! [cdata[%s]]></content> </xml> "; $result = sprintf ($XMLTPL, $object->fromusername, $object->tousername, Time (), $content); return $result;  //reply to Text message private function transmitnews ($object, $newsArray) {if (!is_array ($newsArray)) {return;} $ITEMTPL = "& Lt;item> <title><! [cdata[%s]]></title> <description><! [cdata[%s]]></description> <picurl><! [cdata[%s]]></picurl> <url><! [cdata[%s]]></url> </item> "; $item _str = ""; foreach ($newsArray as $item) {$item _str. = sprintf ($ITEMTPL, $item [' Title '], $item [' Description '], $item [' Picurl '], $ item[' URL ']); } $XMLTPL = "<xml> <tousername><! [cdata[%s]]></tousername> <fromusername><! [cdata[%s]]></fromusername> <CreateTime>%s</CreateTime> <msgtype><! [cdata[news]]></msgtype> <ArticleCount>%s</ArticleCount> <Articles> $item _str</ Articles> </xml> "; $result = sprintf ($XMLTPL, $object->fromusername, $object->tousername, Time (), Count ($newsArray)); return $result; }}?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.