A downloadable asset pack

CopperCube Advanced Scripting Template

This guide and template is intended for advanced users of CopperCube or anyone with a fair knowledge of javascript in game development.

One thing about CopperCube that is a PITA to work with is the javascript side of coding your game. Clicking your way through many property windows and buttons to attach or open a script is counter productive IMO.

Using behaviour and action javascripts are fine for adhoc use or quickly prototyping some game mechanics. However, having too many of these scripts scattered throughout your game project, things can become quite complex, making debugging and management more time consuming.

I will show you a more productive way to coding and debugging script code within the game engine. Some of this is explained in the CopperCube docs but the examples don't work and my method explained here is much improved.

My method is to use a main template script for each of your game projects that can then be used to manage every aspect of the game mechanics from initialization to program flow. Not only can this template script be updated without the need to contiually refresh the plugins, it is also possible to update and debug your code without the CopperCube IDE running!

So, to see this in action lets start here.

The JavaScript template file required to use this method can be downloaded from the download link below.

  1. Create a blank project and save it with your name of choice (mygame.ccb).
  2. Copy the downloaded javascript template file into your game folder.
  3. Rename the javascript file with the same name as your game project (mygame.js).
  4. Finally, test run or publish your game executable.

If all done correctly, then the debug window should display some messages to confirm that the script is running correctly without errors.

You have now created a main game script for your game project that can be used to initialize your game and a game loop to add whatever code that you require. Whenever the code in this main game script is changed, the test run and published excutable will pickup those changes.

We can take this one step further by using this game script to test and debug your game without having the CopperCube IDE running. You will of course still require the IDE to add scene objects and design the layout etc.. of your game.

So let's begin by saving your project and closing the CopperCube IDE. We will now create a shortcut to your game executable for debugging and testing purposes.

  1. Create a shortcut to your CopperCube game execuatble (mygame.exe).
  2. Rename the shortcut to 'mygame_debug' for example.
  3. Open the properties of the shortcut and add the following parameters to mygame.exe
mygame.exe -debug -script:mygame.js

Now start your game executable using this shortcut and do some debugging and code updating.

Whenever you run your game with the debug shortcut the javascript is reloaded. To make the changes permanent within the game executable, the game requires re-publishing from the IDE.

You can also update your javascript with the IDE running but your project will need to be re-published whenever you make a change to the javascript code, if running the mygame.exe directly without the debug shortcut.

I'm sure there are many other uses and improvements to be made. Feel free to add any comments and I will do my best to respond to any questions.

Thanks for reading!

Download

Download
mygame.js 1.9 kB

Install instructions

Instructions

  1. Create a blank project and save it with your name of choice (mygame.ccb).
  2. Copy the downloaded javascript template file into your game folder.
  3. Rename the javascript file with the same name as your game project (mygame.js).
  4. Finally, test run or publish your game executable.

Leave a comment

Log in with itch.io to leave a comment.