Skip to content
Martin Kelm edited this page Aug 9, 2013 · 50 revisions

This article contains information about details how to change different parts of the game to add own modifications in the game.

Look into the logic article to get an overview about the the game logic.

What you should use

Here is a concept of what you should use to change / add things in Mass Control Tycoon:

  • JavaScript logic for all logic related contents
  • JSON files for all types of definition files and data resources
  • PNG/XCF files for graphics (more about it)
  • OGG files for music and effects
  • HTML/CSS files if you want to add special DOM layers offering additional interfaces in front of the graphics renderer
  • Text files for documentation / descriptions
  • Shell scripts if you want to add automatic processes
  • Useful tools, binaries or html/css/javascript files
  • using node.js modules by the internal node-webkit api or by external modules

Notes for using timers:

  • use global.setTimeout instead of setTimeout to get a more accurate timer function
  • save the interval id of setInterval / for clearInterval in mct.status.intervals[intervalName]
  • use functionName.curry(parameters) instead of function() { functionName(parameters); } to set a callback

Editor settings

If you want to add / edit files please use these editor settings:

  • indent two spaces
  • indent type spaces (not TAB)
  • max. line length round about 100 chars
  • break line type LF (Unix)!
  • charset UTF-8

Developer tools

node-webkit contains developer tools, which contain e.g. a console for log messages or a tab for ressources, like the Web SQL Database.

You have to change the package.json file in the project root folder, and set fullscreen to false and toolbar to true. You will get a window with the minimum screen size from the package.json file.

Click on the wheel in the upper right corner to open developer tools.

You can write debugging console log messages by using console.log(variables) in the javascript source. The console is accessible by using the button in the lower left corner of the developer tools window.

Or you can monitoring the Frames performance or the memory usage in the "Timeline" tab.

The developer tools offer a very powerful, in-depth tool for profiling too. Go to the "Profiles" tab to record CPU or memory heap profiles with usage statistics for every function / element.

If you click on a javascript file in the HTML document inside the "Elements" tab, you will get a source editor in the "Sources" tab. You can edit and save the files for temporary changes to test. Note: A reload or manual refresh of the application content will reset the changes to the hard drive version. So you have to trigger the changed functionality by an in-game control/action or a special key event.

Another idea is to make the game modification and balancing process more easy by adding a special game related developer tool.

Change text styles

You can change all pixi.js text elements by using the styles.json file from lib/display/txt.

Each text style in the JSON-object has an alpha numeric key with an array containing three values:

  • text size in pixels, for base resolution 1280x1024
  • font name, like "Arial"
  • font color, like "red"

Change / add language texts

You can change existing game languages and you can add new languages by using JSON-Files in the lib/display/txt/lngs folder for general text elements.

Note: The translation concept is still in progress, e.g. the translations of some game contents are located in json files located in lib/base. But the main, display related translations will still be avaialable in the display/txt folder.

A language file has a name containing the language in two lower-case characters and the region in two upper-case characters. Each language file contains a JSON object with language text keys which contain a "lt" prefix and numeric values divided by dots, read more about it below. The text values are string values.

You have to use the same language text keys in every language file. If you want to enable another or a new language file, go to the display file init.js and change current language file in the related getJSON call to your selected file name.

If you want to change game content related translations look into lib/base folder, there are some JSON configuration files with special translation configurations, like lib/base/data/planets.json

General language text keys

A language text key contains a "lt." prefix and numeric values divided by dots, e.g. "lt.0.0.0" But you are free to use something like this "lt.titleMasterfunction1" too, if the handle describes the usage of the text well. The second solution might be preferred in future to improve the understanding of language text handles. Sound files use them too for references, like effects with "ef.handle".

Change / add company names

All planets and technology fields have their own company names. Each field has 1000 random names currently. The names have been generated with this tool. But you can change and add company names as you like. Open a names.json file and change the strings of the array elements.

Change / add graphic assets

If you want to change or add graphic assets be careful:

  • all graphic assets should be designed for a 1280x1024 screen resolution
  • the game will scale the assets in relation to this and the current screen resolution automatically
  • you have to add all graphic assets to a sprite sheet, more about that
  • add your new graphic assets by using new PIXI.Sprite.fromFrame("framename");
  • framenam is the image name of the related asset in the gfx.atlas file

Tools for spritesheets:

Note: If you purchase Spine you can edit/create advanced animations too.