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:
- 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.
- 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
- Database creation and Connectivity
- Add support
- Score Upload and leaderboard query
- Server connection
- Local data storage
- 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 */;
Five
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`)
17 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
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"=>"127.0.0.1",
8 "port"=>3306,
9 "user"=>"root",
10 "password"=>"root",
11 "database"=>"JumpingBrick"
12);
Thirteen
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"]);
21}
22}
23? >
View Code
Next time, we'll show you how to add support, so stay tuned!
Other RELATED LINKS
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