This is a sample game based on pixi.js which is a super fast HTML5 2D rendering engine that uses webGL with canvas fallback. For more information about Pixi, please refer to here. In the game, player controlls a paddle to prevent a ball from falling while trying to clear the bricks. The objective of the game is to clear all the bricks.
A JavaScript file handling various implementation in the application
css/style.css
Style Sheet for the whole application
img/*.png
All image files needed to use this template
res/VT323-Regular.ttf
A true type font
Required JS/CSS Components
Pixi
Source Code Explanation
js/main.js
main.js is a JavaScript file handling various functionalities of the application.
Below is the code of BB object which is the main object of this application. Its properties are screensize, paddle, balls, blocks, score and so on. Its methods are creating block map (setMap()), creating a ball (addBall()), creating a paddle (addPaddle()), resetting the game after it ended (reset()), calculating the score (addScore()), ending the game (endGame()) and so on.
When this page is loading, init() function is called when Cordova is fully loaded or when it's failed to detect the type of the device.
Here is the code of init() function. In this function, BB object is rendered according to the type of device you are using. Then, events listeners related the paddle are added. Also, it renders the paddle position according to each event.
getUa() function is used to detect the type of the device. It will return false when it failed to get this information.