create new stars when old ones pass
This commit is contained in:
parent
0b6c19cc0e
commit
57fc49ea54
@ -16,7 +16,9 @@ Starfield::Starfield(GnomeScreensaver & gs)
|
||||
m_last_ticks = ticks;
|
||||
srand(time(NULL) + getpid());
|
||||
for (int i = 0; i < NUM_STARS; i++)
|
||||
newStar(i, ticks - (uint64_t) (i * FLYBY_TICKS / (double)NUM_STARS));
|
||||
newStar(NUM_STARS - i - 1,
|
||||
ticks - (uint64_t) (i * FLYBY_TICKS / (double)NUM_STARS));
|
||||
m_star_idx = 0;
|
||||
}
|
||||
|
||||
Starfield::~Starfield()
|
||||
@ -43,6 +45,14 @@ bool Starfield::expose (GnomeScreensaver & gs)
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
while ((m_stars[m_star_idx].create_time + FLYBY_TICKS) <= ticks)
|
||||
{
|
||||
newStar(m_star_idx, ticks);
|
||||
m_star_idx++;
|
||||
if (m_star_idx >= NUM_STARS)
|
||||
m_star_idx = 0;
|
||||
}
|
||||
|
||||
m_last_ticks = gs.getTicks();
|
||||
|
||||
return true;
|
||||
|
@ -31,6 +31,7 @@ class Starfield : public Mode
|
||||
protected:
|
||||
LogoBox m_logobox;
|
||||
uint64_t m_last_ticks;
|
||||
int m_star_idx;
|
||||
Star m_stars[NUM_STARS];
|
||||
void getRandomAxis(float (*axis)[3]);
|
||||
void newStar(int idx, uint64_t ticks);
|
||||
|
Loading…
x
Reference in New Issue
Block a user