Code snippet corner

hey got some neat code that is self contained and solves a very particular problem or is just neat?
spread the joy and drop it here or something

#text crawler snippet
here is a text crawler, you seen it in many games like rpgs or visual novels, the text prints character by character to the display, this is the smallest i could get it and i feel its to small to be a library or something.

#include "Pokitto.h"
Pokitto::Core game;

// needs sting for this
#include <string>
// global crawler variables
std::string crawlStr;
int crawlIndex;
void crawlInput(char * input){ crawlIndex = 0; crawlStr = input; }

int main () {

// you can call this too print text on the screen, even in a different function if you need too
crawlInput("hi there, this text is crawling.");

while (game.isRunning()) {

    if (game.update()) {
        //the actual crawler and simple way to display it
        if(crawlIndex < crawlStr.size()) crawlIndex++;
return 1;

there are some special characters in the ascii string stuff that isnt used by the pokitto print function,
but since its still parsed as a character it delays our draw speed. so use this for dramatic effects
"nothing special here. \t\t\t\t\t\t\t\t\t\t\t\t\t boo!"


@adekto Would you be willing to contribute some of this as sort of structured Wiki articles? Starting from Hello World upwards?

yea sure, but like idk this just a place to dump neat things in no particular order and just share and learn

@adekto yes I understand. But you have a good teaching style, and the Wiki should have a couple of “getting started” articles like these, only with some little more explanation of what is done with different functions.

1 Like