-
Notifications
You must be signed in to change notification settings - Fork 114
Making a Game
Daan van Yperen edited this page May 31, 2019
·
2 revisions
This guide creates the smallest possible project for artemis-odb. It assumes you are aware how to set up an empty Java project and add dependencies.
You can find a gradle version of this project in the https://github.com/DaanVanYperen/artemis-odb-examples/ folder.
Create a new blank project in IntellIJ or Eclipse and add a dependency on net.onedaybeard.artemis:artemis-odb:2.2.0
.
Create Hello.java
in package my.game.components
containing:
public class Hello extends Component {
public String message;
public void set(String message) {
this.message = message;
}
}
Create HelloWorldSystem.java
in package my.game.systems
containing:
@All(Hello.class)
public class HelloWorldSystem extends IteratingSystem {
protected ComponentMapper<Hello> mHello;
@Override
protected void process(int id) {
System.out.print(mHello.get(id).message);
}
}
Create GameLauncher .java
in package my.game
containing:
public class GameLauncher {
public static void main( String[] args ) {
// 1. Register any plugins, setup the world.
WorldConfiguration setup = new WorldConfigurationBuilder()
.with(new HelloWorldSystem())
.build();
// 2. Create the world.
World world = new World(setup);
// 3. Create entity. You can do it here or inside systems.
int entityId = world.create();
world.edit(entityId).create(Hello.class).message = "\n\rHello world!\n\r";
// 4. Run the world. HelloWorldSystem should print the hello world message.
world.process();
}
}
Run GameLauncher#main
. The world should process and should print Hello World
.
- Overview
- Concepts
- Getting Started
- Using
- More guides
- Plugins
- Game Gallery
- Tools and Frameworks
- API reference