Break text into pieces
Text and SVG artwork break where they are hit.
<h3
data-jr-breakable
>
BREAK THIS
</h3>A browser toy for vehicular misconduct. Add one script and turn your page into a destructible playground.
One script turns your existing HTML into a playground. No new layout required.
<h1
data-jr-breakable
data-jr-burnable
>
Page title
</h1>
<script
type="module"
src="https://unpkg.com/@joy-ride/game@latest/embed.js"
data-jr-mount
></script>Paste the script into your page, or mount it from JavaScript.
Make a heading breakable or an image burnable with a data attribute or ride.bind().
Use WASD or the arrow keys to drive. Click the car to choose a vehicle and tools.
Turn ordinary text, artwork, and buttons into things you can break, push, paint, or crush. Choose “Drive here” to try an example.
Text and SVG artwork break where they are hit.
<h3
data-jr-breakable
>
BREAK THIS
</h3>Each character moves independently when hit or pulled.
<h3
data-jr-pushable
>
MOVE ME
</h3>Drive through a colored element to coat your tires. Mix colors and leave tracks across the page.
<div
data-jr-liquid="paint"
style="background: #e03139; width: 144px; height: 144px;"
>
</div>
<button
data-jr-liquid="paint"
class="rounded-xl bg-sky-500 px-6 py-4 text-white"
>
Blue paint
</button>
<button
data-jr-liquid="paint"
class="rounded-xl bg-amber-400 px-6 py-4 text-black"
>
Yellow paint
</button>Drive over an image to reveal its crushed version. Add a colored spill for a messy finish.
<div
class="ant"
data-jr-crushable
data-jr-crushable-crushed-class="is-crushed"
data-jr-crushable-crushed-paint-color="#8caa27"
>
<img class="alive" src="ant.webp" alt="Ant" />
<img class="crushed" src="ant-crushed.webp" alt="" />
</div>
<style>
.ant .crushed { display: none; }
.ant.is-crushed .alive { display: none; }
.ant.is-crushed .crushed { display: block; }
</style>













The car and loose pieces collide with this element.
<div
data-jr-solid
>
WALL
</div>Choose a tool, try it in a live example, then hold its number key. Steer to aim.
await ride.ready;
ride.player.update({
"slots": {
"1": {
"action": "eject",
"liquid": "oil",
"activation": "hold",
"rate": 6,
"amount": 0.65
}
}
});Hold 3 to ignite a word, an illustration, or a puddle of oil. Let go and watch nearby materials catch.
Light one word and watch the next one catch. Separate elements can spread fire to each other.
<span
data-jr-burnable
>
SPARK
</span>
<span
data-jr-burnable
>
SPREADS
</span>Fire follows the lines of the illustration and gradually burns away the artwork.
<svg
viewBox="0 0 160 120"
data-jr-burnable
>
<path d="M8 60 46 44 73 8 89 48 144 28 118 66 152 106 92 86 64 116 54 78Z" />
</svg>A puddle keeps its shape as it burns. The flames can spread from fuel to nearby burnable objects.
<div
data-jr-liquid="oil"
>
OIL
</div>Start at the word and watch fire travel through paint, fuel, and artwork. Different materials make one chain reaction.
<span
data-jr-burnable
>
INK
</span>
<div
data-jr-burnable
style="background: #e03139"
>
SURFACE
</div>
<div
data-jr-combustible
data-jr-combustible-health="70"
>
FUEL
</div>
<svg
data-jr-burnable
viewBox="0 0 80 80"
>
<path d="M40 2 49 28 77 28 55 45 63 75 40 58 17 75 25 45 3 28 31 28Z" />
</svg>Spill oil, splash water, or mix paint with your tires. Pick a liquid, pour it, and drive back through the trail.
Burnable. Reduces grip for four seconds.
const kit = JoyRide.define({
liquids: {
'demo-oil': {
"base": "oil",
"color": "#151919",
"thickness": 0.86,
"burnable": true,
"effect": {
"lifetime": {
"unit": "seconds",
"amount": 4
},
"modifiers": {
"grip": 0.28
}
}
},
},
});
const ride = JoyRide.mount({ definitions: kit });
await ride.ready;
ride.player.update({
slots: { 1: { action: 'eject', liquid: 'demo-oil' } },
});Give the drive a purpose: press buttons, make a delivery, or collect pickups. Add points and objectives to turn a page into a game.
Park at 1 → cross 2 → park at 3.
Objectives can also count crushed, broken, or ignited targets, or challenge visitors to reach a score.
<button
data-jr-trigger="click"
>
Press me
</button>
<input
type="checkbox"
data-jr-trigger="toggle"
/>
<div
id="parking"
data-jr-trigger="parking"
data-jr-points="50"
data-jr-trigger-dwell-seconds="0.6"
data-jr-trigger-success-class="is-success"
>
Park here
</div>
<div id="pickups">
<span
data-jr-trigger="pickup"
data-jr-pickup-effect-color="#349dff"
data-jr-trigger-event="pickup-collected"
data-jr-points="10"
>
✦
</span>
<span
data-jr-trigger="pickup"
data-jr-pickup-effect-color="#ad66ff"
data-jr-trigger-event="pickup-collected"
data-jr-points="10"
>
✦
</span>
<span
data-jr-trigger="pickup"
data-jr-pickup-effect-color="#31d9ba"
data-jr-trigger-event="pickup-collected"
data-jr-points="10"
>
✦
</span>
</div>
<output
id="score"
data-jr-hud="points"
>
0
</output>ride.objective('supplies', {
type: 'collect', count: 3,
});
ride.on('objective:complete', ({ objective }) => {
console.log('Complete:', objective.id);
});
ride.objective('high-score', { type: 'score', points: 30 });
document.querySelector('#parking').addEventListener(
'joyride:trigger:stop', ({ detail }) => {
console.log('Parked:', detail.vehicle.id);
},
);
// Points update the shared score HUD automatically.
// Events bubble: one listener handles every pickup.
document.querySelector('#pickups').addEventListener(
'joyride:pickup-collected', ({ detail }) => {
console.log('Collected:', detail.object.id);
},
);Try donuts, drifts, and burnouts. Leave tire marks and smoke as you find your own way around.
Try a maneuver with your current car. Tire smoke follows its motion and flows around walls.
const kit = JoyRide.define({
vehicles: {
'my-car': {
base: 'porsche-911-997',
drift: { entrySpeedMps: 4.5, slipAngleRad: 0.3 },
},
},
});
JoyRide.mount({
definitions: kit,
player: { vehicle: 'my-car' },
});Scatter paper and leaves around an element. Drive past to disturb them.
A small mix of paper and leaves. Drive past to disturb it.
Choose where the pieces begin.
<div
data-jr-debris
data-jr-debris-anchor="fill"
data-jr-debris-amount="45"
data-jr-debris-seed="31"
>
Your content
</div>Scatter pieces, reset them, or remove them from your page.
await ride.ready;
const litter = ride.debris('.track', {
anchor: 'fill',
amount: 45,
// Paper and leaves by default.
seed: 31,
});
litter.gust({ x: 300, y: -65 });
litter.reset();
// litter.dispose();The little touches: an engine that responds, a horn, slow motion, lights, and a dashboard of your own.
Hear the engine rev and the tires squeal. Each car has its own sound and horn.
const kit = JoyRide.define({
vehicles: {
'my-car': {
base: 'porsche-911-997',
sound: {
horn: { lowHz: 380, highHz: 480, tone: 'trumpet', level: 0.6 },
},
},
},
});
const ride = JoyRide.mount({ definitions: kit, player: { vehicle: 'my-car' } });
// Start sound from a click or another user gesture.
await ride.startAudio();Take in the chaos at half speed. The action and audio slow down together.
await ride.setSlowMo(true, {
speedFactor: 0.5,
rampMs: 300,
zoomFactor: 0,
});
await ride.setSlowMo(false);Lights, tire marks, and vehicle details adapt to the ground beneath the car.
ride.updateSettings({game:{headlights: true,underglow: '#66e6ff',underglowOpacity: 0.6}});Put speed, gear, points, and other live values into your own HTML.
Use data-jr-hud-unit="kmh" for kilometres per hour, or data-jr-hud-precision="1" for a decimal place.
<output
data-jr-hud="speed"
>
0
</output> mph
<output
data-jr-hud="gear"
>
N
</output> gear
<output
data-jr-hud="rpm"
>
0
</output> rpm
<output
data-jr-hud="health"
>
0
</output> health
<output
data-jr-hud="points"
>
0
</output> points
<output
data-jr-hud="fps"
>
0
</output> fpsYour page is next
Add the script, choose what reacts, and give visitors something to play with.