• Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!

### #ActualKhatharr

Posted 05 December 2012 - 06:37 AM

I'm really tired, but that's a lot easier to read right now. I'm sorting it around and looking at what you're doing.

I think I found what's been bothering me here.

Isn't your loop and lerp there the same as:
[source lang="cpp"] accumulator = ( DWORD )( ( ( tNow - tPrev ) * 1000 ) / tFreq ); star.Pos.x = ((float)accumulator / UPDATE_TICKS) * star.Vel.x; if(star.Pos.x > (800 - 32)) { star.Pos.x = ((800 - 32) * 2) - star.Pos.x; star.Vel.x = -star.Vel.x; } if(star.Pos.x < 0) { star.Pos.x = -star.Pos.x; star.Vel.x = -star.Vel.x; } gfx.Clear(); gfx.BeginScene(); sprite.Begin(); sprite.Translate( &(star.Pos) );[/source]

I'm not lucid enough to be confident in that, but I'll check in again in the morning when I can open my eyes all the way.

Anyway, I think the problem has something to do with applying 'lerp' in the render but not applying it to the position of the sprite. since you don't remove the lerp'ed value from the accumulator I suppose it carries over, but then any discrepancy in the float division may cause different results. DX vectors store their members as floats. Why not just set the position correctly in the star's vector and render it where it really is instead of trying to interpolate between two integrals?

Good luck.

### #7Khatharr

Posted 05 December 2012 - 06:09 AM

I'm really tired, but that's a lot easier to read right now. I'm sorting it around and looking at what you're doing.

I think I found what's been bothering me here.

Isn't your loop and lerp there the same as:
[source lang="cpp"] accumulator = ( DWORD )( ( ( tNow - tPrev ) * 1000 ) / tFreq ); star.Pos.x = ((float)accumulator / UPDATE_TICKS) * star.Vel.x; if(star.Pos.x > (800 - 32)) { star.Pos.x = ((800 - 32) * 2) - star.Pos.x; star.Vel.x = -star.Vel.x; } if(star.Pos.x < 0) { star.Pos.x = -star.Pos.x; star.Vel.x = -star.Vel.x; } gfx.Clear(); gfx.BeginScene(); sprite.Begin(); sprite.Translate( &(star.Pos) );[/source]

I'm not lucid enough to be confident in that, but I'll check in again in the morning when I can open my eyes all the way.

Good luck.

### #6Khatharr

Posted 05 December 2012 - 06:08 AM

I'm really tired, but that's a lot easier to read right now. I'm sorting it around and looking at what you're doing.

I think I found what's been bothering me here.

Isn't your loop and lerp there the same as:
[source lang="cpp"] accumulator = ( DWORD )( ( ( tNow - tPrev ) * 1000 ) / tFreq ); star.Pos.x = ((float)accumulator / UPDATE_TICKS) * star.Vel.x; if(star.Pos.x > (800 - 32)) { star.Pos.x = ((800 - 32) * 2) - star.Pos.x; star.Vel.x = -star.Vel.x; } if(star.Pos.x < 0) { star.Pos.x = -star.Pos.x; star.Vel.x = -star.Vel.x; } gfx.Clear(); gfx.BeginScene(); sprite.Begin(); sprite.Translate( &(star.Pos) );[/source]

### #5Khatharr

Posted 05 December 2012 - 06:06 AM

I'm really tired, but that's a lot easier to read right now. I'm sorting it around and looking at what you're doing.

I think I found what's been bothering me here.

Isn't your loop and lerp there the same as:

GAH I'm botching this really bad. 1 sec and I'll fix it.
[source lang="cpp"] accumulator = ( DWORD )( ( ( tNow - tPrev ) * 1000 ) / tFreq ); float (float)accumulator / UPDATE_TICKS; if(star.Pos.x > (800 - 32)) { star.Pos.x = ((800 - 32) * 2) - star.Pos.x; star.Vel.x = -star.Vel.x; } if(star.Pos.x < 0) { star.Pos.x = -star.Pos.x; star.Vel.x = -star.Vel.x; } gfx.Clear(); gfx.BeginScene(); sprite.Begin(); sprite.Translate( &(star.Pos) );[/source]

### #4Khatharr

Posted 05 December 2012 - 06:05 AM

I'm really tired, but that's a lot easier to read right now. I'm sorting it around and looking at what you're doing.

I think I found what's been bothering me here.

Isn't your loop and lerp there the same as:
[source lang="cpp"] accumulator = ( DWORD )( ( ( tNow - tPrev ) * 1000 ) / tFreq ); (float)accumulator /= UPDATE_TICKS; if(star.Pos.x > (800 - 32)) { star.Pos.x = ((800 - 32) * 2) - star.Pos.x; star.Vel.x = -star.Vel.x; } if(star.Pos.x < 0) { star.Pos.x = -star.Pos.x; star.Vel.x = -star.Vel.x; } gfx.Clear(); gfx.BeginScene(); sprite.Begin(); sprite.Translate( &(star.Pos) );[/source]

### #3Khatharr

Posted 05 December 2012 - 06:04 AM

I'm really tired, but that's a lot easier to read right now. I'm sorting it around and looking at what you're doing.

I think I found what's been bothering me here.

Isn't your loop and lerp there the same as:
[source lang="cpp"] (float)accumulator /= UPDATE_TICKS; if(star.Pos.x > (800 - 32)) { star.Pos.x = ((800 - 32) * 2) - star.Pos.x; star.Vel.x = -star.Vel.x; } if(star.Pos.x < 0) { star.Pos.x = -star.Pos.x; star.Vel.x = -star.Vel.x; } gfx.Clear(); gfx.BeginScene(); sprite.Begin(); sprite.Translate( &(star.Pos) );[/source]

PARTNERS