Skip to content

Instantly share code, notes, and snippets.

@mva1985
Created June 9, 2019 21:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mva1985/7c3c6f58f97242e0cad58c89f4052736 to your computer and use it in GitHub Desktop.
Save mva1985/7c3c6f58f97242e0cad58c89f4052736 to your computer and use it in GitHub Desktop.
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