80 lines
1.5 KiB
C++
80 lines
1.5 KiB
C++
#include "starfield.h"
|
|
|
|
#include <azur/azur.h>
|
|
#include <azur/gint/render.h>
|
|
|
|
#include <cstdint>
|
|
#include <stdlib.h>
|
|
|
|
#include <num/num.h>
|
|
|
|
#include "MyAzurShaders.h"
|
|
|
|
|
|
|
|
Star::Star( void )
|
|
{
|
|
x = rand() % 396;
|
|
y = libnum::num( rand() % 224 );
|
|
|
|
size = 1 + ( rand() % 4 );
|
|
|
|
sy = libnum::num( size );
|
|
|
|
color = 0xFFFF;
|
|
}
|
|
|
|
Star::~Star()
|
|
{
|
|
|
|
|
|
}
|
|
|
|
void Star::Update( float dt )
|
|
{
|
|
libnum::num a = libnum::num( dt / 12000.0f );
|
|
y += sy * a;
|
|
|
|
if (y > 224)
|
|
{
|
|
x = rand() % 396;
|
|
y = 0;
|
|
}
|
|
}
|
|
|
|
void Star::Render( )
|
|
{
|
|
if (size==1)
|
|
{
|
|
azrp_pixel( x, (int) y, color );
|
|
}
|
|
else if (size==2)
|
|
{
|
|
azrp_pixel( x-1, (int) y-1, color );
|
|
azrp_pixel( x-1, (int) y, color );
|
|
azrp_pixel( x, (int) y-1, color );
|
|
azrp_pixel( x, (int) y, color );
|
|
}
|
|
else if (size==3)
|
|
{
|
|
azrp_pixel( x, (int) y-1, color );
|
|
azrp_pixel( x-1, (int) y, color );
|
|
azrp_pixel( x, (int) y, color );
|
|
azrp_pixel( x+1, (int) y, color );
|
|
azrp_pixel( x, (int) y+1, color );
|
|
}
|
|
else if (size==4)
|
|
{
|
|
azrp_pixel( x-1, (int) y-1, color );
|
|
azrp_pixel( x-1, (int) y, color );
|
|
azrp_pixel( x-1, (int) y+1, color );
|
|
azrp_pixel( x, (int) y-1, color );
|
|
azrp_pixel( x, (int) y, color );
|
|
azrp_pixel( x, (int) y+1, color );
|
|
azrp_pixel( x+1, (int) y-1, color );
|
|
azrp_pixel( x+1, (int) y, color );
|
|
azrp_pixel( x+1, (int) y+1, color );
|
|
}
|
|
}
|
|
|