srcimon / screwbox

Minimalist 2D Java game engine. Result of covid lockdown.
MIT License
8 stars 0 forks source link
2d game game-development game-engine gamedev java

Project Logo

Minimalist 2D Java game engine. Result of covid lockdown.

Maven Central javadoc Build Lines of Code Coverage

About

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.

youtube trailer
▶ Watch trailer on Youtube

Features

Getting started

  1. 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>
  2. 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();
        }
    }

Modules

Here is a quick overview over all modules contained in this library:

screwbox

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>

screwbox-core

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();

screwbox-tiled

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");

Documentation

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.

Libraries used

Acknowledgments

The project idea was inspired by Gurkenlabs Litiengine.

super hero and cat standing next to each other