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.
- Entity Component System Add and remove game objects and behaviour. Save and load the game state.
- Render Engine Fast rendering of shapes, animated graphics and text. Enhance graphics with dynamic light and shadow effects.
- Physics System Move objects and resolve collisions. Detect objects via raycasting.
- Particle Effects Add particle effects to create some nice visuals.
- Asset Management Load game assets without interrupting the game.
- Basic UI Create an animated interactive game ui in an instant.
- Input Support Receive player interactions via keyboard and mouse.
- Game Scenes Use scenes to structure different game situations.
- Audio Support Play wav and midi sounds. Control the volume, pan and balance. Get information on whats currently playing. Thats it. Only the basics.
- Support for Tiled Editior Import your game map and tilesets in Json format from the Tiled Editor
-
Create a new Maven project and add
screwbox-core
dependency (Java 21 required):<dependency> <groupId>io.github.srcimon</groupId> <artifactId>screwbox-core</artifactId> <version>1.13.0</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.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>1.13.0</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 | Very simple hello world application. Shows how to get started. |
pathfinding | Example application showing how to use pathfinding and importing maps from Tiled Editor |
particles | Demonstration of particle interaction with mouse |
game-of-life | An interactive game of life implementation. |
platformer | A much more complex example showing how to make a platformer. |
- JUnit Eclipse Public License 2.0
- FasterXML Jackson Core Apache License 2.0
- AssertJ Apache License 2.0
- Mockito MIT License
The project idea was inspired by Gurkenlabs Litiengine.