Got questions, comments, patches, etc.?
Contact Jason Woofenden
gitweb
/
vor.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
* dust.c (zero): correct lower bound for wrapping to avoid loss of precision.
[vor.git]
/
dust.c
diff --git
a/dust.c
b/dust.c
index
5ee9e20
..
96a5805
100644
(file)
--- a/
dust.c
+++ b/
dust.c
@@
-13,6
+13,9
@@
struct dust_mote {
struct dust_mote motes[N_DUST_MOTES];
struct dust_mote motes[N_DUST_MOTES];
+// lower bound to ensure that we don't lose precision when wrapping.
+static float zero;
+
void
init_dust(void)
{
void
init_dust(void)
{
@@
-24,6
+27,8
@@
init_dust(void)
b = (MAX_DUST_DEPTH - motes[i].z) * 255.0 / MAX_DUST_DEPTH;
motes[i].color = SDL_MapRGB(surf_screen->format, b, b, b);
}
b = (MAX_DUST_DEPTH - motes[i].z) * 255.0 / MAX_DUST_DEPTH;
motes[i].color = SDL_MapRGB(surf_screen->format, b, b, b);
}
+
+ zero = pow(-10, ceil(log10(XSIZE)) - FLT_DIG);
}
void
}
void
@@
-32,13
+37,15
@@
move_dust(float ticks)
int i;
float xscroll = screendx * ticks;
float yscroll = screendy * ticks;
int i;
float xscroll = screendx * ticks;
float yscroll = screendy * ticks;
+
for(i=0; i<N_DUST_MOTES; i++) {
motes[i].x -= xscroll / (1.3 + motes[i].z);
for(i=0; i<N_DUST_MOTES; i++) {
motes[i].x -= xscroll / (1.3 + motes[i].z);
- motes[i].y -= yscroll / (1.3 + motes[i].z);
if(motes[i].x >= XSIZE) motes[i].x -= XSIZE;
if(motes[i].x >= XSIZE) motes[i].x -= XSIZE;
- else if(motes[i].x < 0) motes[i].x += XSIZE;
+ else if(motes[i].x < zero) motes[i].x += XSIZE;
+
+ motes[i].y -= yscroll / (1.3 + motes[i].z);
if(motes[i].y >= YSIZE) motes[i].y -= YSIZE;
if(motes[i].y >= YSIZE) motes[i].y -= YSIZE;
- else if(motes[i].y < 0) motes[i].y += YSIZE;
+ else if(motes[i].y < zero) motes[i].y += YSIZE;
}
}
}
}