Code Monkey home page Code Monkey logo

playdate-type-annotations's Introduction

Playdate Type Annotations

A set of EmmyLua-style type annotations for the PlayDate Lua SDK, mainly intended for use with the Lua extension in VSCode. Most of the current state of this file is based on the SDK documentation.

Usage

Setup

Place playdate-type-annotations as a git submodule or regular folder outside of your source directory, and add the following to your .vscode/settings.json file to have the sumneko Lua extension pick up the appropriate type annotations in your other source files.

	"Lua.workspace.library": [
		"$PLAYDATE_SDK_PATH",
		"playdate-type-annotations"
	],

You should not import any of these files in your project source code.

Keeping the playdate_type_annotations folder separate from your source directory will ensure these files are not compiled into your .pdx file when running the pdc command.

Type Annotations

These EmmyLua-style type annotations are designed with sumneko.Lua's type annotation support in mind. See the sumneko.Lua wiki to learn more about how you can use these on your end.

Example: Custom Sprite Class

The following examples show how you could create a custom Sprite class using these annotations:

---@class MySpriteClass : playdate.graphics.sprite
MySpriteClass = {} -- While the .extends() call below will add a global table entry, the VSCode extension really needs this to recognize that there is a table with that name.
class('MySpriteClass', {}).extends(playdate.graphics.sprite)
---@class mynamespace.MySpriteClass : playdate.graphics.sprite
mynamespace.MySpriteClass = {} -- While the .extends() call below will add a global table entry, the VSCode extension really needs this to recognize that there is a table with that name.
class('MySpriteClass', {}, mynamespace).extends(playdate.graphics.sprite)

Contributing

Feel free to file issues or make Pull Requests. Where possible, please try to verify the types of your changes at runtime to verify accuracy when the SDK documentation is unclear.

License

Consider this file public domain; I made it for my own sake, and I'm happy to share it to help others in the community.

playdate-type-annotations's People

Contributors

minalien 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.