Page 1 of 1

Writing integers

Posted: Mon Aug 07, 2017 6:07 am
by Staffan
Hello,
Its certainly not hard to write text to the screen in SGDK. I wonder though if there is some way to write a number (a variable), to see how many coins left on a level etc etc.

Re: Writing integers

Posted: Mon Aug 07, 2017 7:34 am
by Moon-Watcher
Use intToStr() and uintToStr() functions this way

Code: Select all

void drawInt( u32 nb, u8 x, u8 y, u8 zeros )
{
	s8 str [ zeros+1 ];
	intToStr ( nb, str, zeros );

	SYS_disableInts();
	VDP_drawText ( str, x, y );
	SYS_enableInts();
}

void drawUInt( u32 nb, u8 x, u8 y, u8 zeros )
{
	s8 str [ zeros+1 ];
	uintToStr ( nb, str, zeros );

	SYS_disableInts();
	VDP_drawText ( str, x, y );
	SYS_enableInts();
}

Re: Writing integers

Posted: Tue Aug 08, 2017 1:10 pm
by Staffan
Worked flawlessly thank you :)