Open source (MIT License) extended print function to automatically go to line, align text and much more.
Documentation at https://github.com/nesbox/TIC-80/wiki/Extended-Print-Function
`eprint(text, [x=0], [align_x=-1], [y=0], [align_y=-1], [color=15], [fixed=false], [scale=1], [smallfont=false], [offset=0], [interline=1*scale], [allow_smallfont=false], [shadow_col=false]) -> text_width, text_height`
- x, y: Coordinates for printing the text.
They can be:
- Integer: it will align from this position.
- Table with two values: it will limit the text between these two positions, going to line if it is too long or switching to smallfont if `allow_smallfont` is true.
- Empty table: it will limit the text to stay on screen, going to line if it is too long or switching to smallfont if `allow_smallfont` is true.
- align_x, align_y: Determine how the text is aligned vertically and horizontally.
They can take the values:
- `-1` to align to the left/top.
- `0` to center.
- `1` to align to the right/bottom.
- color: The color to use to draw the text to the screen.
- fixed: A flag indicating whether fixed width printing is required.
- scale: Font scaling.
- smallfont: Use small font if true.
- offset: Space between the border of the frame or screen and the text. Not used when aligned on a point.
- interline: Vertical space between two lines.
- allow_smallfont: If `true` it will switch to small font when the text does not fit horizontally or vertically.
- shadow_col: Add shadow with the color `shadow_col`. Set to false to not have shadow.
- text_width: returns the width of the text in pixels.
- text_height: returns the height of the text in pixels.
This deserves a big thank you.
If it's useful for people, next time I'll do something to make menus easily. I already have many ideas ^^.
This is very cool and useful.