by axollyon
based on HackerSM64 v2.1
note: if you were using axotext prior to august 13, 2023, you now need to call axotext_render() after you're finished printing!
- make an
AxotextFont(example) with the help of TTF2AxoText by Fallden4 - include your font in either
bin/segment2.c(segment 2, always loaded) orlevels/<any level>/leveldata.c(segment 7, only loaded in that level) - extern your font in either
game/segment2.horgame/segment7.h - include both
"segment2.h"/"segment7.h"and"axotext.h"in the code file where you want to print your text - declare an
AxotextParamsin your function just before you want to print your text- like this:
-
AxotextParams params = { &comicsans, // font name (remember the '&') 16, // font size (in pixels on the framebuffer) 16, // line height (in pixels on the framebuffer) AXOTEXT_ALIGN_CENTER, // text alignment (AXOTEXT_ALIGN_LEFT, AXOTEXT_ALIGN_CENTER, and AXOTEXT_ALIGN_RIGHT) 255, // red 255, // green 255, // blue 255 // alpha };
-
- like this:
- call
axotext_print- like this:
-
axotext_print( 160, // x position (in pixels on the framebuffer, where 0 is the left edge) 120, // y position (in pixels on the framebuffer, where 0 is the bottom edge) ¶ms, // the params you defined earlier (remember the '&') -1, // character limit, in case you want to use text typing "hello world!" // the string you want to print );
-
- like this:
- after you've called that as many times as you need (up to 200 non-whitespace characters at once), render all of your printed text with
axotext_render- like this:
-
axotext_render(); - you can change the character buffer size,
AXOTEXT_BUFFER_SIZE, inaxotext.hto allow for more characters to be rendered - note that higher buffer sizes will use more memory
-
- like this:
- note that font size, line height, x position, and y position are actually floats. this engine allows for subpixel positioning at up to 4x precision, meaning the smallest unit for these is actually 0.25 pixels
- have fun :)