A89: Re: C question... actually two C questions...
[Prev][Next][Index][Thread]
A89: Re: C question... actually two C questions...
Hi!
> I have a newbie C question. Two actually.
As I can see, three (sprites, input, keypresses)... :-)
> Whenever I attempt to use Sprite32 to draw a four level
> grayscale sprite (32x32), TI-GCC gives me an error on
> compilation.
Which error??? I am receiving a lot of mails every day in
which users tell me "my program don't compile, why?"
without any extra informations. I am not an oracle which
can predict what is in everyone's program...
> What seems to be the problem here? Can't Sprite32
> handle grayscale sprites?
To make a grayscale sprite, you in fact need to have two
independent sprites, "light plane sprite" and "dark plane
sprite", and to call Sprite32 twice, passing GetPlane(0)
and GetPlane(1) as the parameter:
Sprite32(x,y,height,light_data,GetPlane(0),A_XOR);
Sprite32(x,y,height,dark_data,GetPlane(1),A_XOR);
> That's sort of necessary for making any games...
Yes.
> Second of all, does anyone know if there's a way to
> accept user input like one would from DOS on the
> PC only on a TI-89? Is that how people work high
> score input (probably not)?
You need something like InputStr in TI-Basic? See
description of "gets" in "stdio.h". "gets" is extremely
limited, without any editing capabilities, but the
documentation gives an example how to make a bit
better input function... If I pick it from my minds,
as I remember, I suggested something like:
void InputStr(char *buffer,int maxlen)
{
SCR_STATE ss;
int key,i=0;
buffer[0]=0;
SaveScrState(&ss);
do
{
MoveTo(ss.CurX,ss.CurY);
printf("%s_ ",buffer);
key=ngetchx();
if(key>=' '&&key<='~'&&i<maxlen) buffer[i++]=key;
if(key==257&&i) i--;
buffer[i]=0;
} while(key!=13);
}
> Is there a better way to detect keypresses then using
> a loop and saying Do ... While(RowRead... blablabla ?
There is about 9637 ways to detect a keypress :-)
Cheers,
Zeljko Juric