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. Use split screen mode to create local multiplayer games.
- Physics System Move objects and resolve collisions. Detect obstacles via raycasting and use pathfinding to move around.
- Asset Management Load game assets without interrupting the game flow.
- Particle Effects Add particle effects to create some nice visuals.
- Basic UI Create an animated interactive game ui in an instant.
- Input Support Receive player interactions via keyboard and mouse.
- Scene Management Use scenes to structure different game situations. Add animated transitions to smoothly switch between the scenes.
- Audio Support Play wav and midi sounds. Control the volume and pan manually or automatically based on the position of the sound source. Get information on whats currently playing.
- Archivements Add archivements to challange players with custom goals.
- Support for Tiled Editor Import your game map and tilesets in Json format from the Tiled Editor
-
Create a new Maven project using Java 21+ and add the
screwbox-core
dependency:<dependency> <groupId>io.github.srcimon</groupId> <artifactId>screwbox-core</artifactId> <version>2.12.0</version> </dependency>
-
Create a minimal application using example code:
import io.github.srcimon.screwbox.core.Engine; import io.github.srcimon.screwbox.core.ScrewBox; import io.github.srcimon.screwbox.core.graphics.drawoptions.TextDrawOptions; import static io.github.srcimon.screwbox.core.assets.FontBundle.BOLDZILLA; public class HelloWorldApp { public static void main(String[] args) { Engine screwBox = ScrewBox.createEngine(); screwBox.environment().addSystem(engine -> engine.graphics().canvas().drawText( engine.mouse().offset(), "current fps is: " + engine.loop().fps(), TextDrawOptions.font(BOLDZILLA).scale(3).alignCenter())); screwBox.start(); }
-
Run main method (it's recommended to use JVM option
-Dsun.java2d.opengl=true
for much better performance)
Here is a quick overview over all modules contained in this project:
BOM to manage all project dependencies.
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.github.srcimon</groupId>
<artifactId>screwbox</artifactId>
<version>2.12.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. If you have any questions please let me know by creating an Issue.
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. |
playground | Just a playground, containing whatever is currently in focus of development. |
- 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.