Public
Edited
Jan 25, 2023
Insert cell
Insert cell
Insert cell
viewof app = {
const app = new PIXI.Application();
app.view.value = app;
return app.view;
}
Insert cell
mutable fuel = (restarts, 100)
Insert cell
Insert cell
thruster
Insert cell
MAX_THRUST = 11
Insert cell
increaseThrust = () => adjustThrust(viewof thruster.value)
Insert cell
adjustThrust = (offset) =>
(viewof thruster.value = Math.min(viewof thruster.value + offset, MAX_THRUST))
Insert cell
app.renderer.resize(width, 400)
Insert cell
game_space = {
restarts;
const container = yield new PIXI.Container();
app.stage.addChild(container);
container.addChild(ship);
ship.x = container.addChild(ship);
}
Insert cell
// game_space.addChild(ship)
Insert cell
Insert cell
FUEL_DRIP_RATE = 1
Insert cell
fuel_usage = {
now;
if (mutable fuel == 0) return mutable fuel;
mutable fuel = Math.max(0, mutable fuel - FUEL_DRIP_RATE);
}
Insert cell
onkeychange = (window.onkeydown = window.onkeyup =
(event) => KeyBindings?.[event.key](event))
Insert cell
x = viewof thruster_juice
Insert cell
// x.dispatchEvent(new Event("input"))
Insert cell
KeyBindings = ({
w: Controls.increaseThrust,
// ArrowUp: thrust,
// ArrowDown: throttle,
ArrowLeft: _.noop,
ArrowRight: () => (ship.rotation += 100)
// w: () => ship.rotation,
// a: () => yaw(-1),
// s: throttle,
// d: () => yaw(1)
})
Insert cell
Controls = ({
increaseThrust: KeyEvent({
onkeydown: increaseThrust,
onrepeat: increaseThrust,
onkeyup: () => {}
})
})
Insert cell
KeyEvent = ({ onkeydown: keydown, onkeyup: keyup, onrepeat }) =>
(event) =>
(event.repeat ? onrepeat : { keydown, keyup }[event.type])(event)
Insert cell
mutable log = ""
Insert cell
ImageResources = ({
ship: new PIXI.ImageResource(await FileAttachment("sample.png").image())
})
Insert cell
PIXI = import(`https://cdn.skypack.dev/pixijs@7.1.1`)
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more