Skip to content

ReScript & KAPLAY

ReScript bindings for KAPLAY!

NPM Version

Install the package using your favorite package manager:

npm i @nojaf/rescript-kaplay

and add @nojaf/rescript-kaplay to your rescript.json:

{
"bs-dependencies": [
"@nojaf/rescript-kaplay",
]
}

After installing the package , you can use bindings for KAPLAY.

open Kaplay
// Create a new Kaplay context
let k = Context.kaplay(
~initOptions={
background: "#05df72",
width: 500,
height: 500,
},
)
// Create your first GameObject
module Bean = {
type t
include Sprite.Comp({type t = t})
include Pos.Comp({type t = t})
let make = () => {
k->Context.add([
k->addSprite("bean", ~options={width: 50., height: 50.}),
k->addPos(200., 100.),
])
}
}
// Load the bean sprite
k->Context.loadBean
// Create a bean
let bean = Bean.make()

Tada!

Result