News:

*NEW* Current Version on STEAM16.793

Webchat:
Visit the chat



text

Previous topic - Next topic

Richard Rae

Is there any way to centre justify printed text or any other justification(left,right)

Schranz0r

I make a small function for you, one moment pls ;)
I <3 DGArray's :D

PC:
AMD Ryzen 7 3800X 16@4.5GHz, 16GB Corsair Vengeance LPX DDR4-3200 RAM, ASUS Dual GeForce RTX™ 3060 OC Edition 12GB GDDR6, Windows 11 Pro 64Bit, MSi Tomahawk B350 Mainboard

Schranz0r

So i got it  :D

CENTER TEXT:

Code (glbasic) Select
// SX = String X (Center);    SY = StringY (Center)

FUNCTION Print_C: String$,SX,SY,Font_number

SETFONT Font_number

GETFONTSIZE FontX, FontY

PRINT String$, SX - (LEN(String$)*FontX)/2, SY - FontY / 2

ENDFUNCTION
TEXT RIGHT:
Code (glbasic) Select
FUNCTION Print_R: String$,SX,SY,Font_number

SETFONT Font_number

GETFONTSIZE FontX, FontY

PRINT String$, SX - (LEN(String$)*FontX), SY - FontY / 2

ENDFUNCTION
Text to the left are the normal Print ;)

For Example:

Code (glbasic) Select
GLOBAL WinX = 800
GLOBAL WinY = 600

SETSCREEN WinX,WinY,0




WHILE TRUE

PRINT "Whats up there",0,WinY/2+10
Print_R("Test at the right side of life..... XD",WinX,WinY/2,0) // Set the Text to the right
Print_C("Hello World",WinX/2,WinY/2+10,0) // Center Text

SHOWSCREEN
WEND
END




FUNCTION Print_C: String$,SX,SY,Font_number

SETFONT Font_number

GETFONTSIZE FontX, FontY

PRINT String$, SX - (LEN(String$)*FontX)/2, SY - FontY / 2

ENDFUNCTION



FUNCTION Print_R: String$,SX,SY,Font_number

SETFONT Font_number

GETFONTSIZE FontX, FontY

PRINT String$, SX - (LEN(String$)*FontX), SY - FontY / 2

ENDFUNCTION
I <3 DGArray's :D

PC:
AMD Ryzen 7 3800X 16@4.5GHz, 16GB Corsair Vengeance LPX DDR4-3200 RAM, ASUS Dual GeForce RTX™ 3060 OC Edition 12GB GDDR6, Windows 11 Pro 64Bit, MSi Tomahawk B350 Mainboard

Richard Rae

Works great.Thank you.

Schranz0r

no problem ;)
I <3 DGArray's :D

PC:
AMD Ryzen 7 3800X 16@4.5GHz, 16GB Corsair Vengeance LPX DDR4-3200 RAM, ASUS Dual GeForce RTX™ 3060 OC Edition 12GB GDDR6, Windows 11 Pro 64Bit, MSi Tomahawk B350 Mainboard