Meteos/Star.cpp
sigonasr2, Sig, Sigo 58a89798d7 Implement star field
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
2023-02-15 20:45:19 +00:00

29 lines
631 B
C++

#include "pixelGameEngine.h"
#include "Meteos.h"
extern Meteos*game;
void Star::Update(){
pos+=spd;
if (pos.x<0){
pos.x+=game->ScreenWidth();
}
if (pos.x>game->ScreenWidth()){
pos.x-=game->ScreenWidth();
}
if (pos.y<0){
pos.y+=game->ScreenHeight();
}
if (pos.y>game->ScreenHeight()){
pos.y-=game->ScreenHeight();
}
if (flickerTimer++>=flickerRate){
flickerTimer=0;
brightness={redDistribution(game->gen),greenDistribution(game->gen),blueDistribution(game->gen)};
}
};
void Star::Draw(){
game->FillRectDecal(pos,size,brightness);
};