A delightfully simple and lightweight 2D game engine for the D programming language.
Find a file
2024-06-08 09:50:50 +03:00
examples Made web script noob friendly. 2024-06-08 09:25:20 +03:00
source/popka Fixed a raylib-d bug with DUB. 2024-06-08 09:50:50 +03:00
web Fixed a raylib-d bug with DUB. 2024-06-08 09:50:50 +03:00
.gitignore Small ldc change and small README.md change. 2024-03-09 16:22:18 +02:00
dub.json Made web script noob friendly. 2024-06-08 09:25:20 +03:00
LICENSE First. 2024-03-05 07:59:55 +02:00
README.md Fixed a raylib-d bug with DUB. 2024-06-08 09:50:50 +03:00
TODO.md Added custom origin and small qol things. 2024-05-16 01:40:59 +03:00

Popka

Popka is a lightweight and beginner-friendly 2D game engine for the D programming language. It focuses on providing a simple foundation for building 2D games.

import popka;

bool gameLoop() {
    draw("Hello world!");
    return false;
}

void gameStart(string path) {
    openWindow(640, 360);
    updateWindow!gameLoop();
    closeWindow();
}

mixin addGameStart!gameStart;

Warning

This is alpha software. Use it only if you are very cool.

Supported Platforms

  • Windows
  • Linux
  • MacOS
  • Web

Games Made With Popka

Dependencies

To use Popka, you'll need the raylib library (version 5.0) installed on your system. The official raylib instructions will guide you through the process.

Installation

This guide shows how to install Popka and its dependency, raylib, using DUB. While DUB simplifies the setup process, Popka itself doesn't require DUB.

  1. Install Popka and raylib

    Navigate to the folder containing your dub.json file and run the following command:

    dub add popka raylib-d && dub run raylib-d:install
    

    Popka doesn't require raylib-d, but we include it as a dependency for its convenient raylib download script. It is recommended to remove raylib-d from your dub.json file after the installation is complete.

  2. Compile example

    Once the installation is complete, you should be able to compile the provided hello-world example by running:

    dub run
    

    For more info about exporting to web, see this.

Documentation

For an initial understanding, the examples folder and the engine.d file can be a good starting point.

Project Layout

  • core: A standard library designed specifically for game development.
  • vendor: A collection of third-party libraries.
  • game: A set of tools for creating 2D games.

Attributes and BetterC Support

This project offers support for some attributes (@safe, @nogc, nothrow) and aims for good compatibility with BetterC.

Web Support

For exporting to web, your project needs to be compatible with BetterC. The web folder contains a helper script to assist with the web export process. If you use DUB, you can run the script with:

dub run popka:web

raylib Bindings

Popka provides bindings for raylib that are compatible with BetterC and the web. Additionally, it provides helper functions to reduce some boilerplate code. All the helper functions are inside the raylibpp.d file.

import popka.vendor.ray;

bool rayLoop() {
    BeginDrawing();
    ClearBackground(RAYWHITE);
    DrawText("Congrats! You created your first window!", 190, 200, 20, LIGHTGRAY);
    EndDrawing();
    return false;
}

void rayStart(const(char)[] path) {
    InitWindow(800, 450, "raylib");
    updateWindow!rayLoop();
    CloseWindow();
}

mixin addRayStart!rayStart;

Note

I add things to Popka when I need them.

License

The project is released under the terms of the MIT License. Please refer to the LICENSE file.