Hi im a newbie and need help im tring to get a scrolling star field but all i manage to do is get a screen full of pixles
any ideas as how i should proceed?
Thanks
Rex
Thanks
Rex
A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.
#define NROFSTARS (256)
struct Star
{
int x,
int y,
int spdx
};
Star StarTab[NROFSTARS];
void InitStars(void)
{
int i;
for (i=0; i<NROFSTARS; i++)
{
StarTab[i].x = rand()&255;
StarTab[i].y = rand()%320;
StarTab[i].spdx = (rand()&7)+1;
}
};
void DrawStars(void)
{
int i;
for (i=0; i<NROFSTARS; i++)
{
StarTab[i].x += StarTab[i].spdx;
StarTab[i].x &= 255;
if(StarTab[i].x<240) //clipping
{
DrawPixel(x,y);
}
}
}