Menu ▾ ▴

Script - Getting started

Jeroen Broekhuizen

In Crafter 2D scripting plays an important role. Most game logic will be written in scripts. Ideally you would not have to write any C++ code, although this is still unlikely.

Packages

Java programmers should be familiar with this concept and can skip this section as nothing new will be explained here. A package is just a folder on your harddrive. They can be empty or contain several classes and/or sub-packages. There is one folder that is the root pacakge. In Crafter 2D this is often the script subfolder.

To denote to which package a certain class belongs, you can use the package keyword and the folder path the class remains in. An example will be shown below.

Class

A class is the place where the action occurs. Note in the following code sample that the class is placed directly below the package definition.

:::Java
package engine.game;

class Client
{
    public Client()
    {
    }
}

All possibilities of a class will be explained in more depth on other pages.


Related

Wiki: Scripting