Git Product home page Git Product logo

playdatekit's Introduction

PlaydateKit Logo

PlaydateKit

PlaydateKit provides easy to use Swift bindings for the Playdate C API. PlaydateKit aims to be as Swift-y as possible, replacing error pointers with throwable functions, avoiding the use of pointers and memory management as much as possible, and adding documentation comments to all functions (copied from the Playdate SDK docs).

Status

PlaydateKit provides (almost) full coverage of the Playdate C API. PlaydateKit adds wrapper types for some values (Sprite, Bitmap, FileHandle, etc) that automatically manage the allocation/deallocation of resources. While I have attempted to closely follow the C API specifications, much of it is untested, so if you run into an unexpected issue or can't do something with the Swift API, please open an issue!

Currently, the following sections of the API are implemented:

  • Display
  • File
  • Graphics
  • JSON
  • Lua
  • Scoreboards
  • Sound
    • FilePlayer
    • SamplePlayer
  • Sprite
  • System

Usage

For detailed instructions and documentation on how to get started creating a game using PlaydateKit, see here.

Summary

  1. Install a recent nightly Swift toolchain that supports the Embedded experimental feature.
  2. Install the Playdate SDK.
  3. Create a new repository using the PlaydateKitTemplate template.
  4. Build and run directly in the simulator using Xcode, or build using the command swift package pdc. When built using swift package pdc, the built pdx game file will be located at .build/plugins/PDCPlugin/outputs/PlaydateKitTemplate.pdx and can be opened in the Playdate simulator.

Your PlaydateGame object manages the game lifecycle, receiving events such as gameWillPause and deviceWillSleep.

import PlaydateKit

final class Game: PlaydateGame {
    init() {
        System.addCheckmarkMenuItem(title: "check me") { isChecked in
            System.log(isChecked ? "checked!" : "not checked")
        }
    }

    func update() -> Bool {
        System.drawFPS()
        return true
    }

    func gameWillPause() {
        System.log("Paused!")
    }
}

Contributing

I'm happy to accept contributions on this project, whether it's bug fixes, implementing missing features, or opening an issue. Please try to follow the existing conventions/style in the project. Code should be formatted before merge using swiftformat ., but I can run this before merging if you don't want to install swiftformat.

If you create a game using PlaydateKit and would like it listed here, please open an issue or pull request! I am also hoping to add some simple games to an Examples/ directory in this repo if anyone wants to demake a retro game or create a new one that demos PlaydateKit.

Acknowledgements

PlaydateKit was inspired by and would not be possible without the excellent work done by @rauhul on swift-playdate-examples. Specifically, PlaydateKit was created due to the note in the swift-playdate-examples repo:

It is not intended to be a full-featured Playdate SDK so please do not raise PRs to extend the Playdate Swift overlay to new areas.

playdatekit's People

Contributors

finnvoor avatar ricobeck avatar pcbeard avatar aechaves avatar alicerunsonfedora avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.