Lancelotbronner / swift-raylib

13 stars 0 forks source link

Swift bindings for raylib, a simple and easy-to-use library to enjoy videogames programming.

NOTE for ADVENTURERS: raylib is a programming library to enjoy videogames programming; no fancy interface, no visual helpers, no debug button... just coding in the most pure spartan-programmers way.

~raysan5

Ready to learn? Jump to code examples!

Chat on Discord Chat on Reddit


RaylibKit

A swifty interface and app lifecycle to ease development with raylib!

Features

import RaylibKit

@main struct MinimalWindow: Applet {

    init() {
        Window.create(800, by: 450, title: "Example - Core - Basic Window")
        Application.target(fps: 60)
    }

    func draw() {
        Renderer2D.text(center: "Congrats! You created your first window!", color: .lightGray)
    }

}

The result of the above snippet

๐Ÿš€ Getting Started

First you'll need to install raylib as a system library and add this package as a dependency.

You can then start learning! Check out the examples to quickly get an idea and make sure your installation works!

Documentation is available via DocC. For Xcode users simply go to Product > Build Documentation or press โŒƒโ‡งโŒ˜D (alt-shift-command-D). For others the documentation is available in the releases as a website you can run locally.

Install raylib as a system library

You should start by installing raylib as a system library, see the official guide here.

The easiest way is via one of the supported package managers.

Add swift-raylib as a package dependency

Add the following line to your Package.swift dependencies...

.package(url: "https://github.com/Lancelotbronner/swift-raylib.git", from: "4.5.0")

...along with the following line to your target dependencies and import RaylibKit!

.product(name: "RaylibKit", package: "RaylibKit"),

Interop with C

If you still need to interop, you can import raylib and use the cheatsheet for reference.

๐Ÿ— Contributing

There is a fully configured workspace for this repository, associated examples and developer tools at swift-raylib-workspace. The goal is to reduce the clone size of swift-raylib as its used as a dependency and avoids adding too many automatically generated Xcode schemes.