Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
sdlBasic library to render text on the fly with various alignments relative to the given coordinates.
' textalign.sdlbas: sdlBasic library to render text on the fly
' with various alignments relative to the given coordinates.
' 2019-05-06 No Time To Play <https://notimetoplay.org/>
' Use as you like; please keep the attribution if you will.
' Set to a number the game leaves unused otherwise.
' Slot 0 (zero) is the mouse cursor in full screen.
dim common _temp_text_slot = 1
sub print_centered(message$, size, x, y)
textrender(message$, size, _temp_text_slot)
hotspot(_temp_text_slot, 1, 1)
pastebob(x, y, _temp_text_slot)
end sub
sub print_north(message$, size, x, y)
textrender(message$, size, _temp_text_slot)
hotspot(_temp_text_slot, 1, 2)
pastebob(x, y, _temp_text_slot)
end sub
sub print_south(message$, size, x, y)
textrender(message$, size, _temp_text_slot)
hotspot(_temp_text_slot, 1, 0)
pastebob(x, y, _temp_text_slot)
end sub
sub print_east(message$, size, x, y)
textrender(message$, size, _temp_text_slot)
hotspot(_temp_text_slot, 0, 1)
pastebob(x, y, _temp_text_slot)
end sub
sub print_west(message$, size, x, y)
textrender(message$, size, _temp_text_slot)
hotspot(_temp_text_slot, 2, 1)
pastebob(x, y, _temp_text_slot)
end sub
sub print_nw(message$, size, x, y)
textrender(message$, size, _temp_text_slot)
hotspot(_temp_text_slot, 2, 2)
pastebob(x, y, _temp_text_slot)
end sub
sub print_ne(message$, size, x, y)
textrender(message$, size, _temp_text_slot)
hotspot(_temp_text_slot, 0, 2)
pastebob(x, y, _temp_text_slot)
end sub
sub print_sw(message$, size, x, y)
textrender(message$, size, _temp_text_slot)
hotspot(_temp_text_slot, 2, 0)
pastebob(x, y, _temp_text_slot)
end sub
sub print_se(message$, size, x, y)
textrender(message$, size, _temp_text_slot)
hotspot(_temp_text_slot, 0, 0)
pastebob(x, y, _temp_text_slot)
end sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.