Hello i decided to contribute with this little code.
Istead of using a skycube with stars, that look bluured, you can use this entity based starfield.
- It blinks like real stars do
- Blue / Red color shift distribution
- Rendered bellow all entities.
- Follow player
->Add this image file to your project:
DOWNLOAD IMAGE
/// NUMBER OF STARS
int star_limit=200;
//// star props
void starf_f(ENTITY* p) {
set(p,TRANSLUCENT | BRIGHT | LIGHT );
// Add random color based on red
p.red=225-random(90);
p.green=150;
p.blue=200-random(90);
while(1){
//blinking effect
p.alpha=50+random(50);
vec_set(you.pan,camera.pan);
//keep star size all the same and not by their distance to camera
you.scale_x=vec_dist(you.x,camera.x)/8200;
you.scale_y=you.scale_x;
you.scale_z=you.scale_x;
wait(1);
}
}
//// CREATOR
VECTOR star_pos;
int starf_count=0;
var angle;
while (starf_count<star_limit) {
angle=random(360);
star_pos.x=camera.x + 100000 * cos(random(360)) * cos(random(360));
star_pos.y=camera.y + 100000 *sin(random(360)) * cos(random(360));
star_pos.z=camera.z + 100000 * sin(random(360));
you=ent_createlayer("star_point.tga",SKY,2);
you.x=star_pos.x;
you.y=star_pos.y;
you.z=star_pos.z;
starf_f(you);
starf_count++;
}
}