“Flappy Purupuru” Documentation by “Code This Lab S.r.l.” v1.0
“Flappy Purupuru”
Thank you for purchasing our game. If you have any questions that are beyond the scope of this help file, please feel free to email via user page contact form here. Thanks so much!
Table of Contents
- Description
- Getting Started
- HTML Structure
- CSS Files and Structure
- JavaScript
- Game functions
- Events
- Enable Sounds
A) Description - top
Flappy Purupuru is a HTML5 action game. The game is freely inspired to the popular game "Flappy Bird". The goal of the player is to tap the screen to let Purupuru survive as long as possible avoiding the obstacles.
The ZIP package contains the game with 768x1024 resolution that automatically scales to fit proportionally current screen device.
The game is fully compatible with all most common mobile devices.
Sounds are DISABLED ON MOBILE DEVICES to avoid compatibility issues but can be easily enabled (read Enable Sound section). Anyway we can't grant full compatibility on all mobile devices if this feature is enabled.
B) Getting Started - top
To install the game just upload on your server the files contained into the folder 'game768x1024'. WARNING: The game won't run locally with some browser like Chrome due to some security restrictions so please upload it on your server space.
- Game Resize: All game resolution automatically center itself and fits on the screen thanks to the ctl_utils.js file.
If you want to avoid this, comment this function:
$(window).ready(function() {
sizeHandler();
});
Save Score: if you need to call your php function for saving score, you can add it in the index.html file:
$(oMain).on("save_score", function(evt,score,best_score) {
//ADD CODE HERE
});
Localization: You can easily change game text for different languages, changing string in CLang.js
TEXT_GAMEOVER = "GAME OVER";
TEXT_CONGRATS = "CONGRATULATIONS";
TEXT_SCORE = "SCORE";
TEXT_BEST_SCORE = "BEST SCORE";
TEXT_TIME = "TIME";
TEXT_PLAY = "PLAY";
TEXT_HELP = "TAP THE SCREEN\n TO JUMP AND\nAVOID THE OBSTACLES";
Game option: You can easily customize game setting when creating a new instance of the game in index.html file
var oMain = new CMain({
hero_x : 150, //STARTING HERO X POSITION
hero_y : CANVAS_HEIGHT/2, //STARTING HERO Y POSITION
hero_down_speed : 3, //HERO FALLING SPEED
bg_speed : 9, //SPEED OF SCROLLING BACKGROUND
time_training: 3000, //NUMBER OF MILLISECONDS BEFORE USER STARTS PLAYING
dist_among_obst: 350, //PIXEL DISTANCE AMONG TWO SERIES OF OBSTACLE
obst_height_dist: 250 //PIXEL DISTANCE BETWEEN TWO OBSTACLE POSITIONED IN THE SAME X
});
C) HTML Structure - top
This game have the canvas tag in the body. The ready event into the body calls the main function of the game: CMain().
The head section declares all the javascript functions of the game. The whole project uses a typical object-oriented approach.
In the init function there are 3 mapped events that can be useful eventually for stats
D) CSS Files and Structure - top
The game use two CSS files. The first one is a generic reset file. Many browser interpret the default behavior of html elements differently. By using a general reset CSS file, we can work round this.
Keep in mind, that these values might be overridden somewhere else in the file.
The second file contains all of the specific stylings for the canvas and some hack to be fully compatible with all most popular mobile devices
E) JavaScript - top
This game contains:
- jQuery
- Our custom scripts
- CreateJs plugin
- jQuery is a Javascript library that greatly reduces the amount of code that you must write.
- The game have the following js files:
- CMain: the main class called by the index file.
This file controls the sprite_lib.js file that manages the sprite loading, the game sounds, the loop game and initialize the canvas with the CreateJs library
- ctl_utils: this file manages the canvas resize and its centering
- sprite_lib: this class loads all images declared in the main class
- settings: general game settings
- CLang: global string variables for language localization
- CPreloader: simple text preloader to show resources loading progress
- CMenu: simple menu with play button
- CGfxButton: this class create a standard button
- CTextButton: this class create a standard text button
- CToggle: this class create a standard toggle button
- CHelpPanel: this class manages the help panel that appears when game starts
- CGame: this class manages the game logic
- CHero: The Hero controlled by the player
- CObstacle: this class controls the obstacles
- CScrollingBg: the scrolling background
- CInterface: this class controls game GUI that contains text and buttons
- CEndPanel: this class controls the game over panel that appears when player lose all the lives
- CreateJs is a suite of modular libraries and tools which work together to enable rich interactive content on open web technologies via HTML5.
Resuming, the complete game flow is the following:
- The index.html file calls the CMain.js file after ready event is called
- The main class calls CPreloader.js to init preloader text and start sprite loading
- When all sprites contained in "/sprites" folder and sounds (if not mobile) are loaded, the main class removes the preloader and calls the CMenu.js file that shows the main menu
- If user click on the play button in main menu, the CGame.js class is called and the game starts
- The game class shows immediately a help screen that explain briefly the game instructions. When the player tap the first time, the game starts
- If Purupuru hit an obstacle or falls to the ground, the game is over
- If the user click on game over panel, the game restart
F) Game functions - top
In this section will be explained all the most important functions used in
CGame.js file.
- _init()
This function attach on the canvas all game sprites like background (oBg), GUI and help panel.
- unload()
This function removes event listeners on buttons. It's called when user decide to exit from the game.
- tapScreen()
This function is called when screen is clicked
- _resetLevel
This function is called when player restart the level
- update()
This function manages the game loop.
G) Events - top
The game trigger the following events:
- game_start: this event is called when user click play button in the main menu.
- save_score: this event is called each time game is over. It passes also the final and the best score.
- restart: this event is called when user exit from the game
I) Enable Sounds - top
The game avoid sound playing if loaded on any mobile device. If you want to enable sounds also on mobiles, you have to change the following value in settings.js file:
var DISABLE_SOUND_MOBILE = false;
Once again, thank you so much for purchasing this game. Fell free to contact us if you have any questions or issue relating to this game. No guarantees, but we'll do our best to assist.
CODE THIS LAB S.R.L.
Go To Table of Contents