Pixel UI/Games & sound/Breakout

Breakout

Your words are the bricks. Press play and the text becomes a level.

<piix-breakout>DOM + canvas

Pointer or arrow keys move, Space launches.

Break every word in this heading

And this line too, if you can.

Ball & paddle
Speed
Lives

Whatever you put inside stays normal, readable content until someone presses Play. Then every word becomes a brick right where it sits: a ball comes off a paddle with a pal riding it, and each word it hits shatters into pixels of its own colour and is gone from the page. Clear them all to win; lose every ball and the words fly back into place. Words inside an element with data-solid are steel: the ball bounces off them, but they never break.

Installation

<!-- once, anywhere on the page: every component -->
<script src="https://cdn.jsdelivr.net/npm/piixpal@0.6/piixpal.min.js"></script>

Usage

<piix-breakout pal="bitbug">
  <h2 class="ex-h2">Break every word in this heading</h2>
  <p>And this line too, <b data-solid>if</b> you can.</p>
</piix-breakout>

Examples

A whole section

Bold, links and different sizes all become bricks of their own colour.

Changelog

Faster builds, smaller bundles

Cold starts are 3× quicker, and the core is now 29 KB gzipped.

React to the score

Every brick, win and loss is an event.

Clear this line to unlock a coupon

API reference

AttributeWhat it doesDefault
palthe pal riding the paddle, or nonebitbug
livesballs you get3
speedhow fast the ball is, 0.5 to 21
tonelime coral violet sky sun mint ink paperlime
fieldroom under the words for the paddle, in px150
soundmake sounds even without <piix-chiptune>; off keeps it silent–
data-solidon any element inside: its words are steel and never break–

Events

EventWhen
starta game begins
bricka word breaks: detail.word, detail.score
winevery word is gone: detail.score
losethe last ball is lost: detail.score

Methods

MethodWhat it does
play()start a new game
pause()pause it
reset()put every word back and stop

Accessibility