Log In  


keyboard-lemons.p8

  • page 1, library - 181 tokens
  • page 2, demo - 301 tokens

This cart is principally a library for interacting with the user in a query and response format using the keyboard.

Usage

You can include the library in your own cart by including only the first page:

#include keyboard-lemons.p8:1

The second page includes a demo with an old kids' game called lemons. The most salient feature is that user queries can be written straightfowardly:

answer = prompt("what's 2+2? ")

The magic—as it often does—lies in a little thing called coroutines.

Demo

Cart #keyboard_lemons-0 | 2023-10-26 | Code ▽ | Embed ▽ | No License
2


This is actually one of the first computer games I ever wrote, back then in gw-basic. It was a silly pen-and-paper game I had learned that I decided to try my hand at digitizing because I didn't know how to do anything graphical yet.

Features

The keyboard.p8 library

  • handles backspace;

  • does not accrue string unless polled;

  • ergonomic prompt interaction code;

  • echo can be on or off;

  • allows you to substitute your own reader function;

  • return and 'p' will not pop up the pico-8 menu when being polled (unless enable_menu is set to true).

Acknowlegments

Many thanks to cabledragon for their inspiring mklib, a mouse and keyboard library, project. Their keyboard code is only 62 tokens too.

2



[Please log in to post a comment]