Celadon engine Pure JavaScript build HTML5 game second play--"jumping block" Part 4

Source: Internet
Author: User

After the last introduction of the "Magic Hexagon" of the complete game development process ( Click here to see ), this time will introduce another magic game "jumping block" of the complete development process.

(click on the image to enter the game experience)

Because of the content too much, for the convenience of everyone to read, so many times to explain.

To see all of your documents at once, you can also click here .

Pick up (jumping block Part 3)

Four. Data processing

The data is divided into two main categories:

    1. Local data persistence. For example, historical highest score, pause when the current level data, and so on.
      Local data can be implemented using the storage functionality provided by the engine.
    2. Network data. such as the submission of history of the highest score, login information, leaderboard information.
      Network data need to build the server part, you can choose a variety of handy language, such as: PHP, Java, ASP. The Assetsutil function provided by the engine is then communicated to the server.

Next, start implementing these features step-by-step

    1. Database creation and Connectivity
    2. Add support
    3. Score Upload and leaderboard query
    4. Server connection
    5. Local data storage
    6. Working with Game data

(i) database creation and connectionCreate a database

MySQL is used as the storage data here. A user table is required to store the player's ID, name, Avatar, and history's highest score information. Create a database using the following script.

1 / * *
2 * create database
3 * /
4 CREATE DATABASE `JumpingBrick` /*!40100 DEFAULT CHARACTER SET utf8 COLLATE utf8_bin */;
6 / * *
7 * create user score table
8 * /
9 CREATE TABLE `user_info` (
10   `open_id` varchar(64) COLLATE utf8_bin NOT NULL,
11   `name` varchar(255) COLLATE utf8_bin NOT NULL,
12   `head_icon` varchar(512) COLLATE utf8_bin DEFAULT NULL,
13   `score` int(11) DEFAULT ‘0‘,
14   `update_time` int(11) DEFAULT NULL,
15   PRIMARY KEY (`open_id`),
16   KEY `score_time` (`score`,`update_time`)
View Code

PHP Connection Script

This uses PHP to implement a simple server side, the database operation, record, query database data. Separate the database configuration into one PHP. For example: db.php.

1 < < PHP
2 / * *
3 * MySQL database configuration
4 * /
5 class DB {
6     private static $sqlConfig = array (
7         "host"=>"",
8         "port"=>3306,
9         "user"=>"root",
10         "password"=>"root",
11         "database"=>"JumpingBrick"
14     public static function getDB() {
15         return new mysqli(
16             DB::$sqlConfig["host"],
17             DB::$sqlConfig["user"],
18             DB::$sqlConfig["password"],
19             DB::$sqlConfig["database"],
20             DB::$sqlConfig["port"]);
23? > 
View Code

Next time, we'll show you how to add support, so stay tuned!


Open source free HTML5 game engine--Celadon engine (Qici engines) 1.0 official release!

JS Development HTML5 Game "Magic Hexagon" (a)

Celadon engine Pure JavaScript build HTML5 game second play--"jumping block" Part 3


Celadon engine Pure JavaScript build HTML5 game second play--"jumping block" Part 4

Related Article

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.