Cogollos (nft)
How it started
This project started after staying a week at a friend's house, right when NFTs were popular. They are artists and I am a programmer, so we used their art to generate random avatars from different hand-drawn eyes, mouths, arms and other pieces, to post them as NFTs with bots.
I had such a fun time building this alongside my friends. I felt very inspired, and the code is a piece of art for me for its style, which was the result of 10 years of an evolving coding style.
What it is
Cogollos is a small character generator. Press C and a new cogollo appears: an arm, a body, a face and feet picked at random from folders of PNG pictures, each layer tinted a random colour. A second scene is a tiled map where two cogollos walk around and drop bombs, one on the arrow keys and one on WASD.
In the browser, N switches scenes, since the browser keeps Ctrl+S for itself.
How it's built
It is a C++ prototype from 2022 on SFML and Dear ImGui. In 2026 I moved it onto my own library, kazilib, and SFML 3.1, and compiled the same code to WebAssembly so it runs on this site.
- The pictures are sorted into folders (
arm,body,face,feet): each folder becomes a category, and generating a cogollo copies the template and keeps one random picture per category. - Scenes run on kazilib's scene manager. The map is read from a text file holding its size and then one word per tile with its flags.
- The web build uses kazilib's SFML web port: SFML's window on SDL3, with its OpenGL drawing emulated on WebGL2. The ImGui panel works in the browser too.
- The port fixed an old bug in the map loader: a
while(!eof)loop made one extra tile from an empty word and read its flags past the end of the string. - A headless browser test makes four cogollos, switches scenes and walks the map, both on a local build and on the live page.
Timeline
Written between March and May 2022 without AI; ported to SFML 3.1 and the web with AI help in November 2026.
Technologies
- C++23
- SFML 3.1
- Dear ImGui
- kazilib
- WebAssembly