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

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more