ReScript & KAPLAY
ReScript bindings for KAPLAY!
Installation
Section titled “Installation”Install the package using your favorite package manager:
npm i @nojaf/rescript-kaplay
bun 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 contextlet k = Context.kaplay( ~initOptions={ background: "#05df72", width: 500, height: 500, },)
// Create your first GameObjectmodule 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 spritek->Context.loadBean
// Create a beanlet bean = Bean.make()
import Kaplay from "kaplay";import * as Pos$Kaplay from "@nojaf/rescript-kaplay/src/Components/Pos.res.mjs";import * as Sprite$Kaplay from "@nojaf/rescript-kaplay/src/Components/Sprite.res.mjs";
let k = Kaplay({width: 500,height: 500,background: "#05df72"});
Sprite$Kaplay.Comp({});
Pos$Kaplay.Comp({});
function make() {return k.add([k.sprite("bean", {width: 50,height: 50}),k.pos(200, 100)]);}
let Bean = {make: make};
k.loadBean();
let bean = make();
Tada!