Log In  

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

btw my fav way of saving text is with tables so

gmeovr={
msg="you lost",
adv="press x to play again",
hgscr="you score: "
}

and if anyone can think of a way to include variables, please comment

P#87551 2021-02-12 20:40

[Please log in to post a comment]