Minimalist 2D Java game engine. Result of covid lockdown.
ScrewBox is a small pure Java 2D game engine. I started developing ScrewBox in february 2021 right during too much time at hand because of covid lockdown. I use it to learn about Java and have some fun. If you want to get something startet in a few minutes ScrewBox might be a fun choice.
Create a new Maven project and add screwbox-core
dependency (Java 21 required):
<dependency>
<groupId>io.github.srcimon</groupId>
<artifactId>screwbox-core</artifactId>
<version>2.3.1</version>
</dependency>
Create new class and run (JVM option -Dsun.java2d.opengl=true
highly recommended)
import io.github.srcimon.screwbox.core.Engine;
import io.github.srcimon.screwbox.core.ScrewBox;
import static io.github.srcimon.screwbox.core.assets.FontBundle.BOLDZILLA;
import static io.github.srcimon.screwbox.core.graphics.drawoptions.TextDrawOptions.font;
public class HelloWorldApp {
public static void main(String[] args) {
Engine screwBox = ScrewBox.createEngine();
screwBox.environment().addSystem(engine -> {
var screen = engine.graphics().screen();
var drawOptions = font(BOLDZILLA).scale(4).alignCenter();
screen.drawText(screen.center(), "Hello world!", drawOptions);
});
screwBox.start();
}
}
Here is a quick overview over all modules contained in this library:
BOM to manage all library dependencies.
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.github.srcimon</groupId>
<artifactId>screwbox</artifactId>
<version>2.3.1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
Adds the core functionality of the ScrewBox engine. Nothing more needed to make game.
<dependency>
<groupId>io.github.srcimon</groupId>
<artifactId>screwbox-core</artifactId>
</dependency>
// creating a fancy black window
ScrewBox.createEngine().start();
Adds support for tilesets and maps made with Tiled Editor. For real code have a look at the pathfinding example.
<dependency>
<groupId>io.github.srcimon</groupId>
<artifactId>screwbox-tiled</artifactId>
</dependency>
// loading a map made with Tiled Editor
Map map = Map.fromJson("underworld_map.json");
ScrewBox packs some examples. You can inspect these examples to learn how to use the engine.
Example | Description |
---|---|
hello-world | Hello world application with some interactive particle effects. |
pathfinding | Example application showing how to use pathfinding and importing maps from Tiled Editor |
game-of-life | An interactive game of life implementation. |
platformer | A much more complex example showing how to make a platformer. |
vacuum-outlaw | Example for a top down game. |
The project idea was inspired by Gurkenlabs Litiengine.