Skip to content

leonkasovan/spry

 
 

Repository files navigation

Spry

Spry is a 2D game framework made for rapid prototyping.

Basic example

The following code creates a window and draws Hello, World! to the screen.

function spry.start()
  font = spry.default_font()
end

function spry.frame(dt)
  font:draw('Hello, World!', 100, 100)
end

Spry vs. LÖVE

Spry takes heavy inspiration from LÖVE. Below is a non-exhaustive list of differences between the two:

  • Spry's API uses short function names more suitable for prototyping.
  • Spry implicitly loads all Lua scripts in a project.
  • Spry projects can be deployed to the web.
  • Spry has hot reload support for images, sprites, and tilemaps.
  • Spry can load Aseprite and LDtk files without needing to convert/export assets to .json. LÖVE cannot load these files directly.
  • Spry is a single executable, weighting in at about 1.6mb (0.8mb zipped). LÖVE is 10mb.
  • LÖVE uses LuaJIT 2.1. Spry uses PUC Lua 5.4.
  • LÖVE has lots of documentation and community support.
  • LÖVE is mature, stable, and battle-tested.
  • LÖVE uses conf.lua for configuration options. Spry does not need a separate config file.
  • LÖVE has more overall features, such as touchscreen support and filesystem access. Spry also has gamepad input, networking sockets, system threads, and HTTP/HTTPS support.

Run the examples

This repository includes project examples. You can run them with:

spry examples/basic          # Basic image loading and input
spry examples/planes         # Top-down shmup with atlas/sprites
spry examples/dungeon        # Dungeon game with tilemaps and A*
spry examples/jump           # Platformer with physics and LDtk
spry examples/boxes          # Box2D physics demo
spry examples/nuklear_demo   # Nuklear UI demo
spry examples/microui        # Microui UI demo
spry examples/ecs            # Entity Component System pattern
spry examples/gamepad        # Gamepad/joystick API demo
spry examples/http           # HTTP client demo
spry examples/inheritance    # Class inheritance system demo
spry examples/novel          # Visual novel demo
spry examples/particles      # Particle effects
spry examples/particle_maker # Interactive particle editor
spry examples/pathfinding    # A* pathfinding demo
spry examples/sampler        # Sound playback demo
spry examples/networking     # UDP multiplayer demo (start server too)

Spry can also run single Lua files:

spry myscript.lua
spry path/to/script.lua

When running a single file, only that script is loaded (not all .lua files in the directory). The script can still require() other modules from the same directory.

Building from source

Requires CMake and one of the following C/C++ compilers depending on the platform:

  • Visual Studio for Windows
  • Clang for Linux
  • Emscripten for web browsers

Other compilers might work, but they haven't been tested.

In the command line:

Build for Linux

cmake -B build (default, use X11 backend)
OR
cmake -B build -DUSE_DRM=ON (use DRM backend)
OR
cmake -B build -DUSE_WAYLAND=ON (use Wayland backend)
OR
cmake -B build . -DCMAKE_BUILD_TYPE=Release
cmake -B build . -DCMAKE_BUILD_TYPE=Debug

cmake --build build --parallel

Build for Windows (using VS 2022, multi config)

cmake -B build
cmake --build build
cmake --build build --config Debug
OR
cmake --build build --config Release

Build for Windows (using w64devkit)

cmake -B build-w64devkit-release -G Ninja -DCMAKE_BUILD_TYPE=Release
cmake --build build-w64devkit-release --parallel
OR
cmake -B build-w64devkit-debug -G Ninja -DCMAKE_BUILD_TYPE=Debug
cmake --build build-w64devkit-debug --parallel

The first cmake command might need extra flags depending on the environment. For example, the command below generates a release build for a Linux machine that has both gcc and clang installed, since CMake would likely choose gcc over clang:

cmake -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang -DCMAKE_BUILD_TYPE=Release ..

Build options

Spry supports the following CMake options:

USE_NETWORK (default: ON)

  • Builds with HTTP/HTTPS client module and luasocket networking support
  • Set to OFF to exclude network modules and reduce binary size
cmake -B build -DUSE_NETWORK=OFF

USE_NUKLEAR (default: ON)

  • Builds with the Nuklear immediate-mode GUI module (spry.nuklear)
  • Set to OFF to exclude the Nuklear UI module
cmake -B build -DUSE_NUKLEAR=OFF

USE_WAYLAND (Linux only, default: OFF)

  • Use Wayland display server instead of X11

USE_DRM (Linux only, default: OFF)

  • Use DRM/KMS for direct rendering without a display server

This command should be used when building for web browsers:

emcmake cmake -DCMAKE_BUILD_TYPE=Release ..

Shoutouts

Special thanks to:

  • floooh, for making Sokol.
  • RandyGaul, for making cute_headers.
  • Erin Catto for making Box2D.
  • Casey Muratori, for showing me that I don't need to a huge engine to make games through Handmade Hero.
  • rxi, for making lite. It was my introduction to creating programs with Lua.
  • LÖVE, for being an awesome framework, and for being the main inspiration for this project.

About

2D game framework made for rapid prototyping

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • C 83.6%
  • C++ 11.9%
  • Objective-C 1.9%
  • PHP 1.7%
  • Lua 0.8%
  • CMake 0.1%