1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
//****************************************************************************
void Init_Stars()
{
// this function initializes all the stars
for (int index=0; index < NUM_STARS; index++)
{
// select random position
stars[index].x = rand()%SCREEN_WIDTH;
stars[index].y = rand()%SCREEN_HEIGHT;
// set random velocity
stars[index].vel = 1 + rand()%16;
}
}
//****************************************************************************
void Move_Stars()
{
// this function moves all the stars and wraps them around the
// screen boundaries
for (int index=0; index < NUM_STARS; index++)
{
// move the star and test for edge
stars[index].y+=stars[index].vel;
if (stars[index].y >= SCREEN_HEIGHT)
stars[index].y -= SCREEN_HEIGHT;
}
}
//****************************************************************************
void Draw_Stars(BITMAP * buffer)
{
// this function draws all the stars
for (int index=0; index < NUM_STARS; index++)
putpixel( buffer, stars[index].x, stars[index].y, 15);
}
//****************************************************************************
|