WeChat public platform development 2048 ways to achieve the game, public 2048_php tutorial

Source: Internet
Author: User
Tags cdata

Public platform to develop the method of realizing 2048 games, the public 2048


The example of this paper describes the development of the public platform to achieve 2048 game methods. Share to everyone for your reference. Specific as follows:

One, 2048 games overview

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

Then 2048 will appear various versions, take the big platform. The version that was transplanted to iOS by Ketchapp is the hottest, and now has about 10 million downloads, the same name as the original. The best-known version of the derivative version is the 20,486-edged edition, which ranked the top 200 in the board game in 81 countries around the world. Android version is very popular with the "Challenge 2048", its 2.0.0 version has joined the two-man battle. Secondly, there are 2048 Chinese dynasties editions that are more special. There are more than 2048 custom versions, you can define your own text and pictures. "2048" is one of the popular iOS models.

How to Play:use yourarrow keysto move the tiles. When both 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 is derivatives or fakes, and should is used with caution.
Created by Gabriele cirulli.based on 1024x768 by Veewo Studioand conceptually similar to threes by Ashe Vollmer.

The rules of the game is very simple, each time you can choose to swipe up and down in one direction, each slide once, all the digital blocks will move toward the direction of the slide, the system will be in the blank place a number of random squares, the same number of squares in close, collision will be added. The system gives the number box is not 2 is 4, the player should find a way in this small 16-block range of "2048" this number block.

The game screen is very simple, at the beginning of the whole 16 squares are mostly gray, when the player puzzles appear after the number will change the color, the overall style is very simple.

In the rules of play is very simple, the beginning of the box will appear 2 or 4 of these two small numbers, the player only need to move up and down one of the directions to the movement of the numbers, all the numbers will be moving toward the direction of sliding, and the slide out of the blank square will randomly appear a number, the same number will overlap when the collision And then all the time, the constant overlay that finally pieced together the number 2048 was successful.

If you're a digital enthusiast, or a gifted math genius, you'll be fascinated by how you get started. Even if not a mathematical genius, the average player can also play this game, interested in the download experience.

The game is open source, so there's no need to re-develop it.

Full instance code click here to download this site.

Second, the public platform

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

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

When the user replies 2048, reply to the text message, the text with 2048 game links.

The complete code is shown below.

<?php/* Double Studio CopyRight 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 = simplexml_load_string ($postStr, ' simplexmlelement ', libxml_nocdata);       $RX _type = Trim ($postObj->msgtype);     Message type detach 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 double studio \ n Reply 2048 start game";  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;    }//Receive text message Private function Receivetext ($object) {$keyword = Trim ($object->content);   if (Strstr ($keyword, "2048")) {$content = array (); $content [] = Array ("Title" = "2048 Game", "Description" and "=" game rule is very simple, each can choose to swipe up and down in one direction, each slide once, all the digital blocks will move in the direction of sliding, The system will also appear in the blank place a number of random squares, the same number of squares in close, collision will be added. The system gives the number box is not 2 is 4, the player should find a way in this small 16-block range of "2048" this number block. "," 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 double 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 = "
 
   
    %s 
    %s 
 
    
    %s 
 
    
    text 
 
    
    %s 
 
    
 
 
 
 
 

  
 ";  $result = sprintf ($XMLTPL, $object->fromusername, $object->tousername, Time (), $content); return $result;  }//Reply text message private function transmitnews ($object, $newsArray) {if (!is_array ($newsArray)) {return; } $ITEMTPL = "
 
    
 
   <! [cdata[%s]]>  
 
   %s
 
     
 
   %s
 
     
 
   %s
 
    

  
 ";  $item _str = ""; foreach ($newsArray as $item) {$item _str. = sprintf ($ITEMTPL, $item [' Title '], $item [' Description '], $item [' Picurl '], $it  em[' URL ']); } $XMLTPL = "
 
   
   
    %s%s$item_str %s 
 
    
    %s 
 
    
    news 
 
    
    
   
 
 
 
 
  
 ";  $result = sprintf ($XMLTPL, $object->fromusername, $object->tousername, Time (), Count ($newsArray)); return $result; }}?>

It is hoped that this article will help you to develop PHP-based public platform.

http://www.bkjia.com/PHPjc/984614.html www.bkjia.com true http://www.bkjia.com/PHPjc/984614.html techarticle public platform to develop the method of realizing 2048 games, the public 2048 This paper describes the public platform for the development of 2048 game methods. Share to everyone for your reference. Specific as follows: ...

  • 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.