Page 1 of 1

1rs post. Newbie in SGDK.

Posted: Mon Dec 02, 2013 12:25 pm
by riper
Hi all,

First of all, sorry about my english.

I've just started reading about how to create your own code (games, demos, ...) and copile it to run in emulators or even in real hardware. It's amazing.

I've done my first pseudo ASCII pong game. Whole code is very basic and without order. I'm sure that it can be improved, but i'm just testing methods and codes.

You can find the code here: http://codetidy.com/7445/

As you can see (if you compile it) that there's no counters in this game: only walls, ball and rackets.
I've been trying to make some kind of counter, that's not difficult because you only have to increase some variable in every rebound.
My problem is when I try to write this value on the screen.
I've been trying using VDP_drawText but it looks that it doesn't accepts integers. It only accepts strings.

That's the funcion found in vdp_gb.h
void VDP_drawText(const char *str, u16 x, u16 y)

There's another function that I think I can use to convert integers to string, but I don't know how to use them. I've tried several times but without result.

Here those two functions (string.h):
void intToStr(s32 value, char *str, s16 minsize);
or maybe
void uintToStr(u32 value, char *str, s16 minsize);

I just only want to convert my rebounds counter into string to be displayed in VDP_drawText.

Any idea or example to do that? Thank you!

Posted: Mon Dec 02, 2013 1:47 pm
by Stef
Hi riper,

Welcome on the board :) We are always pleased to see the user and developers here ! That ASCII pong made me remember of my old school days spent in developing on my TI 82 calculator :p

About how writing value with SGDK, you were really close indeed:

Code: Select all

char str[8];

intToStr(value, str, 1);
VDP_drawText(str, 10, 10);
And that is it !

Posted: Mon Dec 02, 2013 11:35 pm
by riper
Stef wrote: About how writing value with SGDK, you were really close indeed:

Code: Select all

char str[8];

intToStr(value, str, 1);
VDP_drawText(str, 10, 10);
And that is it !
Yeah, It works! Thank you!
Now my ASCII Pongs looks better with point counter.
I want to try to put some beep sound when the ball touches the rackets or the walls, some kind of intro screen and some credits too.
:D

Stay in touch!