“Gear Madness” Documentation by “Code This Lab S.r.l.” v1.0


“Gear Madness”

Created: 10/11/2016
By: Code This Lab S.r.l.
Email: info@codethislab.com

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

  1. Description
  2. Folder Contents
  3. Getting Started
  4. HTML Structure
  5. CSS Files and Structure
  6. Source Code
  7. Game functions
  8. Change Graphic
  9. Disable Sounds
  10. Wordpress Plugin

A) Description - top

Gear Madness is a HTML5 Racing Game. 10 tracks to test your driving skills! Win as many competitions as you can to buy power-ups! Are you ready to race again the fastest cars?

The ZIP package contains the game with 1280x768 resolution that scales to fit the whole screen device
Just warning that for very wide screens, the game may not be perfectly full screen. The game is fully compatible with all most common mobile devices.
Sounds are enabled for mobile but we can't grant full audio compatibility on all mobile devices due to some well-know issue between some mobile-browser and HTML5. So if you want to avoid sound loading, please read Disable Sound section).
WARNING: Sounds can't be enabled for Windows Phone as this kind of device have unsolved issues with 'audio' and 'video' tag.


B) Folder Contents - top

The item package contains the following folders:


C)Getting Started - top

To install the game just upload on your server the game folder live_demo.


D)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 8 mapped events that can be useful eventually for stats

			
				  
				  
				 
			
		
  • Game option: You can easily customize game setting when creating a new instance of the game in index.html file
  •                                 var oMain = new CMain({
                                        //////////////////////////////////////////////////PLAYER UPGRADE PARAMS/////////////////////////////////////////////////////
    
                                        //////////GEAR (HERE BELOW, YOU WILL FIND ALL PARAMS OF GEAR UPGRADE)///////////
                                        ///WIDTH IN DEGREE OF GREEN AREA IN STARTING BATTLE BLASTOFF
                                        start_green_width: [    20,     //NO UPGRADE
                                                                30,     //LEVEL 1
                                                                40,     //LEVEL 2
                                                                55      //LEVEL 3
                                                            ],
                                        ///WIDTH IN DEGREE OF GREEN AREA DURING RACE
                                        in_race_green_width: [  4,     //NO UPGRADE
                                                                6,     //LEVEL 1
                                                                8,     //LEVEL 2
                                                                12     //LEVEL 3
                                                            ],
                                        ///DURATION (in milliseconds) OF STOP ACCELERATION IF PLAYER MISSES THE GEAR SHIFT
                                        wrong_change_gear_duration: [   1500,       //NO UPGRADE
                                                                        1350,       //LEVEL 1
                                                                        1200,       //LEVEL 2
                                                                        1000        //LEVEL 3
                                                                    ],
    
                                        //////////ENGINE SPEED (HERE BELOW, YOU WILL FIND ALL PARAMS OF ENGINE SPEED UPGRADE). THE "speed" PARAM STATES THE MAX SPEED (IN KM/H) ACHIEVABLE WITH A GEAR, AND THE "time" PARAM STATES HOW LONG DOES IT TAKE (IN MILLISECONDS) TO REACH THAT SPEED///////////
                                        player_engine: [        ///GEAR N           ///GEAR 1               //GEAR 2                //GEAR 3                //GEAR 4                    //GEAR 5                    //GEAR 6
                                                            [   {speed: 0, time:0}, {speed: 30, time:6000}, {speed: 60, time:7000}, {speed: 90, time:8000}, {speed: 120, time:9000},    {speed: 150, time:10000},   {speed: 180, time:11000}],  //NO UPGRADE
                                                            [   {speed: 0, time:0}, {speed: 30, time:5000}, {speed: 60, time:6000}, {speed: 90, time:7000}, {speed: 120, time:8000},    {speed: 150, time:9000},    {speed: 180, time:10000}],   //LEVEL 1
                                                            [   {speed: 0, time:0}, {speed: 30, time:4000}, {speed: 60, time:5000}, {speed: 90, time:6000}, {speed: 120, time:7000},    {speed: 150, time:8000},    {speed: 180, time:9000}],    //LEVEL 2
                                                            [   {speed: 0, time:0}, {speed: 40, time:3800}, {speed: 70, time:4800}, {speed: 100, time:5800},{speed: 130, time:6800},    {speed: 160, time:7800},    {speed: 200, time:8800}]    //LEVEL 3
                                                        ],
    
                                        //////////NITRO (HERE BELOW, YOU WILL FIND ALL PARAMS OF NITRO UPGRADE)///////////
                                        ///DURATION (in milliseconds) OF NITRO POWER
                                        nitro_duration: [       0,          //NO UPGRADE
                                                                1500,       //LEVEL 1
                                                                3000,       //LEVEL 2
                                                                4500        //LEVEL 3
                                                            ],
    
    
                                        ////////////////////////////////////////////////////////OPPONENT UPGRADE PARAMS/////////////////////////////////////////////////
    
                                        /////////////OPPONENTS ENGINE SPEED PARAMS . THE "speed" PARAM STATES THE MAX SPEED (IN KM/H) ACHIEVABLE WITH A GEAR, AND THE "time" PARAM STATES HOW LONG DOES IT TAKE (IN MILLISECONDS) TO REACH THAT SPEED///////////
                                        opponent_engine:    [
                                                                    //GEAR N            //GEAR 1                //GEAR 2                //GEAR 3                //GEAR 4                    //GEAR 5                    //GEAR 6
                                                                [   {speed: 0, time:0}, {speed: 30, time:4500}, {speed: 50, time:6200}, {speed: 75, time:7800}, {speed: 110, time:8000},    {speed: 120, time:9000},    {speed: 150, time:10000}],  //OPPONENT 1
                                                                [   {speed: 0, time:0}, {speed: 30, time:4000}, {speed: 50, time:6000}, {speed: 75, time:7500}, {speed: 110, time:8000},    {speed: 130, time:8500},    {speed: 160, time:9000}],   //OPPONENT 2
                                                                [   {speed: 0, time:0}, {speed: 30, time:4800}, {speed: 60, time:6900}, {speed: 90, time:7700}, {speed: 130, time:9300},    {speed: 150, time:10500},   {speed: 180, time:12000}],  //OPPONENT 3
                                                                [   {speed: 0, time:0}, {speed: 30, time:4000}, {speed: 50, time:5500}, {speed: 75, time:6900}, {speed: 110, time:8000},    {speed: 130, time:8500},    {speed: 160, time:9000}],   //OPPONENT 4
                                                                [   {speed: 0, time:0}, {speed: 30, time:3900}, {speed: 55, time:5300}, {speed: 80, time:6500}, {speed: 100, time:7000},    {speed: 120, time:8000},    {speed: 150, time:9000}],   //OPPONENT 5
                                                                [   {speed: 0, time:0}, {speed: 25, time:5500}, {speed: 65, time:6500}, {speed: 105, time:6200},{speed: 145, time:6500},    {speed: 180, time:7000},    {speed: 230, time:8000}],   //OPPONENT 6
                                                                [   {speed: 0, time:0}, {speed: 30, time:4000}, {speed: 65, time:4800}, {speed: 100, time:5300},{speed: 130, time:6000},    {speed: 150, time:6700},    {speed: 180, time:8000}],   //OPPONENT 7
                                                                [   {speed: 0, time:0}, {speed: 35, time:3800}, {speed: 70, time:4700}, {speed: 105, time:5400},{speed: 130, time:5900},    {speed: 155, time:6500},    {speed: 185, time:7200}],   //OPPONENT 8
                                                                [   {speed: 0, time:0}, {speed: 35, time:3700}, {speed: 70, time:4600}, {speed: 105, time:5200},{speed: 130, time:5700},    {speed: 155, time:6300},    {speed: 185, time:7000}],   //OPPONENT 9
                                                                [   {speed: 0, time:0}, {speed: 35, time:3700}, {speed: 70, time:4600}, {speed: 105, time:5200},{speed: 130, time:5700},    {speed: 155, time:6300},    {speed: 185, time:7000}]    //OPPONENT 10
                                                            ],
    
                                        /////////////OPPONENTS SKILLS. SETS VARIOUS OPPONENT SKILL:///////////////////////
                                        // - wronggearchangeratio: SETS THE PROBABILITY THAT AN OPPONENT MISSES THE GEAR SHIFT
                                        // - wrongearduration: DURATION (in milliseconds) OF STOP ACCELERATION IF OPPONENT DO A WRONG GEAR CHANGE
                                        // - normalizednitroshottime: THE TIME WHEN OPPONENT SHOT THE NITRO CHARGE. THE TIME IS NORMALIZED, 0 MEAN THAT OPPONENT WILL SHOT NITRO IN THE BEGINNING OF THE RACE, 1 WILL SHOT IN THE END, 0.5 WILL SHOT IN THE MIDDLE OF THE RACE
                                        // - nitroduration: DURATION (in milliseconds) OF NITRO
                                        opponent_skills: [
    
                                            {wronggearchangeratio:0.9, wrongearduration:1500, normalizednitroshottime:0, nitroduration: 0},             //OPPONENT 1
                                            {wronggearchangeratio:0.8, wrongearduration:1500, normalizednitroshottime:0, nitroduration: 0},             //OPPONENT 2
                                            {wronggearchangeratio:0.7, wrongearduration:1500, normalizednitroshottime:0, nitroduration: 0},             //OPPONENT 3
                                            {wronggearchangeratio:0.6, wrongearduration:1500, normalizednitroshottime:0, nitroduration: 0},             //OPPONENT 4
                                            {wronggearchangeratio:0.5, wrongearduration:1500, normalizednitroshottime:0.25, nitroduration: 1500},        //OPPONENT 5
                                            {wronggearchangeratio:0.4, wrongearduration:1500, normalizednitroshottime:0, nitroduration: 0},             //OPPONENT 6
                                            {wronggearchangeratio:0.3, wrongearduration:1500, normalizednitroshottime:0.4, nitroduration: 2000},        //OPPONENT 7
                                            {wronggearchangeratio:0.2, wrongearduration:1500, normalizednitroshottime:0.4, nitroduration: 3000},        //OPPONENT 8
                                            {wronggearchangeratio:0.1, wrongearduration:1500, normalizednitroshottime:0.35, nitroduration: 3000},       //OPPONENT 9
                                            {wronggearchangeratio:0, wrongearduration:1500, normalizednitroshottime:0.1, nitroduration: 4500}           //OPPONENT 10
                                        ],
    
    
                                        ////////////////////////////////////////////////////////TRACK PARAMS/////////////////////////////////////////////////                   
                                        //LENGTH (IN METERS) OF A RACE TRACK
                                        track_meter_length:    [
                                                                    300,        //TRACK 1
                                                                    500,        //TRACK 2
                                                                    1000,       //TRACK 3
                                                                    300,        //TRACK 4
                                                                    300,        //TRACK 5
                                                                    1000,       //TRACK 6
                                                                    500,        //TRACK 7
                                                                    300,        //TRACK 8
                                                                    1000,       //TRACK 9
                                                                    500         //TRACK 10
                                                                ],
    
                                        ////////////////////////////////////////////////////////REWARD PARAMS/////////////////////////////////////////////////
    
                                        /////////////FIRST TIME REWARD, FOR COMPLETING A TRACK  ///////////
                                        track_rewards: [
                                                            100,            //TRACK 1
                                                            150,            //TRACK 2
                                                            200,            //TRACK 3
                                                            250,            //TRACK 4
                                                            300,            //TRACK 5
                                                            350,            //TRACK 6
                                                            500,            //TRACK 7
                                                            550,            //TRACK 8
                                                            600,            //TRACK 9
                                                            700             //TRACK 10
                                        ],
    
                                        /////////////BONUS REWARD EACH TIME YOU WIN A RACE. BASED ON THE LENGTH OF THE TRACK, AND MULTIPLIED BY THE VALUE BELOW///////////
                                        bonus_multiplier_length_reward: 2,
    
                                        /////////////BONUS REWARD EACH TIME YOU WIN A RACE. BASED ON THE OVERTAKING DISTANCE, AND MULTIPLIED BY THE VALUE BELOW///////////
                                        bonus_multiplier_overtaking_reward: 1.5,
    
                                        /////////////BONUS REWARD EACH TIME YOU WIN A RACE. BASED ON THE LEVEL TRUCK NUMBER, AND MULTIPLIED BY THE VALUE BELOW///////////
                                        bonus_multiplier_difficulty: 10
                                    });
    				

    E) 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


    F) Source Code - top

    This game contains:

    1. jQuery
    2. Howler.js
    3. Our custom scripts
    4. CreateJs plugin
    1. jQuery is a Javascript library that greatly reduces the amount of code that you must write.
    2. 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 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 the play button
      • CGfxButton: this class create a standard button
      • CToggle: this class create a standard toggle button
      • CTextButton: this class create a standard text button
      • CGame: this class manages the game logic
      • CInterface: this class controls game GUI that contains text and buttons
      • CAreYouSurePanel: this class show are you sure panel.
      • CEndPanel: this class shows end panel.
      • CHelpPanel: this class shows help panel.
      • CCreditsPanel: this class shows credits panel.
      • CTweenController: this class manages ease interpolation.
      • CLocalStorage: this class manages user's saving state.
      • CAI: this class controls Artificial Intelligence of cars opponents.
      • carsettings: this class manages settings params of cars.
      • CBackground: this class manages background parallax.
      • CCar: this class creates a car and manages its methods.
      • CEngine: this class manages the engine of a car.
      • CGearAreaView: this class manages the area of player's car gear.
      • CHUD: this class manages the HUD of player like tachometer.
      • CLevelBut: this class creates a special button that indicate a game level.
      • CMapTrack: this class manages the map of a track.
      • CModeMenu: this class manages the selection level menu.
      • CNextLevelPanel: this class manages the end of race summary when win.
      • CRetryPanel: this class manages the end of race summary when lose.
      • CShopPanel: this class manages player's upgrade.
      • CStreet: this class manages street's movement.
      • CUpgradeButton: this class creates a special button that manages player's upgrade.
      • CVsPanel: this class manages versus intro panel.
      • CCurtain: this class manages curtain between scenes.
      • CGearButton: this class creates a button that control gear change.
      • CMsgBox: this class creates a msg info panel.
      • CScoreText: this class manages a score info text.
      • CTremble: this class manages tremble animation.
    3. 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:

    1. The index.html file calls the CMain.js file after ready event is called
    2. The main class calls CPreloader.js to init preloader text and start sprite loading
    3. When all sprites contained in "/sprites" and "/sounds" folder are loaded, the main class removes the preloader and calls the CMenu.js file that shows the main menu
    4. If the user click the Play button in main menu, the CModeMenu.js class is called and user can choose a level
    5. If the user click on a level button in level menu, the CGame.js class is called and game starts
    6. If the user click on the exit button in the down-right corner, the game returns to the menu screen

    G) Game functions - top

    In this section will be explained all the most important functions used in CGame.js file.


    H) Change Graphic - top

    You can easily change all the game graphic, replacing all the file you need in the "/sprites" folder. Just respect file format (.png or .jpg) and size if you don't want to change any code line.

    I) Disable Sounds - top

    If you want to disable all the sounds for mobile devices, you have to change the following value in settings.js file:

    var DISABLE_SOUND_MOBILE = true;


    J) Wordpress Plugin - top

    CTL Arcade will allow you to add a real arcade on your worpress website, in this way your users will be more involved and will stay connected longer.

    It's possible to add Ads banner at the beginning of each game and at the end of each level. This will give you a new tool to increase your revenues.

    Your own users will promote your website sharing their scores on the main Social Networks, with no extra costs for you.

    You'll get by default the score-sharing on Twitter. To add Facebook just follow the guideline below.

    3 widgets can be added in your pages through a shortcode.

    Minimum Requirements:

    This plugin is designed to work only with games built by Code This Lab.

    You can find it here!

    ctl arcade

    Once again, thank you so much for purchasing this game. Feel 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