Pixel UI/Games & sound/RPG dialogue

RPG dialogue

A JRPG dialogue box: a pal talks, the words type out, you pick an answer.

<piix-rpg-box>DOM + canvas

Oh! A visitor. Nobody comes down here anymore.

Want to see what I've been building?

Alright. I'll be here, typing.

Follow me! It's 124 pals deep.

Theme
Speed
Speaker

Every child is one page of dialogue. The words type out letter by letter, keeping your markup (bold, links, line breaks), while the pal in the portrait talks, with a short beat after every full stop. Click, Enter or Space finishes the page or turns to the next. A <menu> of buttons becomes a choice with a blinking cursor, and data-goto="an id" jumps to that page, so a conversation can branch. It starts typing when it scrolls into view.

Installation

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

Usage

<piix-rpg-box pal="kitty" name="Kit">
  <p>Oh! A visitor. Nobody comes down here anymore.</p>
  <p>Want to see what I've been <b>building</b>?</p>
  <menu>
    <button data-goto="tour">Show me!</button>
    <button>Maybe later</button>
  </menu>
  <p data-end>Alright. I'll be here, typing.</p>
  <p id="tour" data-clip="hop">Follow me! It's 124 pals deep.</p>
</piix-rpg-box>

Examples

Two speakers

data-pal and data-name on a page change who says it.

I crawl on headings for a living.

And I nap on paragraphs.

Wait, someone's reading this?!

Onboarding that branches

Listen for choice to act on the answer.

First time here?

Great! Start with Install in the sidebar.

Welcome back. New this week: games.

Say it from code

Click the button.

Save

API reference

AttributeWhat it doesDefault
palthe pal in the portrait (any pal name, or none)none
namethe speaker's name, shown on the box–
themeclassic dark paper limeclassic
speedletters per second40
voicehow high the typing blips are, 0.5 to 21
linesthe text area is at least this many lines tall3
autoturn the page by itself after this many ms–
loopstart again after the last page–
fontpixel or inherit (your page font)pixel
soundmake sounds even without <piix-chiptune>; off keeps it silent–
data-pal, data-nameon a page: who says this one–
data-clipon a page: the portrait's mood, any of that pal's clips–
data-speedon a page: letters per second for it–
data-endon a page: the conversation ends here–
data-gotoon a choice: the id of the page to jump to–

Events

EventWhen
pagea page starts: detail.index, detail.id
choicean answer is picked: detail.value, detail.label, detail.index
donethe conversation ends

Methods

MethodWhat it does
next()finish the page, or turn to the next
restart()from the first page
say(html, { pal, name, clip })say something new, right now

Accessibility