easy way to center any text on the screen, just copy and paste the hcenter(s)
function _init()
-- table with all the text
texts={
a="center text",
b="easy",
c="compact",
e="simple"
}
end
function _draw()
cls()
print(texts.a,hcenter(texts.a),64,7)
print(texts.b,hcenter(texts.b),70,7)
print(texts.c,hcenter(texts.c),76,7)
print(texts.e,hcenter(texts.e),82,7)
end
function hcenter(s)
-- takes a string
-- gets 64, rests the string
-- lenght and multiplys by 2
return 64-#s*2
end
P#87550 2021-02-12 20:38
[Please log in to post a comment]