#include "bg.h"
#include "graphics.h"
#include "stage.h"

Star stars[NUM_STARS];


void InitStars()
{ 
	for(int i = 0; i < NUM_STARS; i ++)
	{
		stars[i].x = rand()%1000 - 500;
		stars[i].y = rand()%1000 - 500;
		stars[i].z = rand()%10001;
		stars[i].brightness = rand()%1000;
	}
}

void UpdateStars()
{

	for(int i = 0; i < NUM_STARS; i++)
	{
		if(stars[i].z < 1000 && stars[i].z > 0)
		{	
			int w = (stages[currentStage].width / 2);
			int h = (stages[currentStage].height / 2);
			int sX = (stars[i].x * w / stars[i].z) + w - xAxis;
			int sY = (stars[i].y * h / stars[i].z) + h - yAxis;
			gxDrawRect(sX-2, sY-2, 4, 4, gxRGB32(stars[i].brightness, stars[i].brightness, stars[i].brightness));
		}
		
		 
		 stars[i].z-=10;

		 if(stars[i].z <=0)
			stars[i].z = 10001;
	}
}