xvelocity and wheel spin

Posted:
Sun Jun 19, 2011 7:33 pm
by sportmaster
I need code to synchronize wheel spin and wheel's speed.
Re: xvelocity and wheel spin

Posted:
Mon Jun 20, 2011 9:03 am
by skydereign
Not sure if you want it to be physically accurate, but here is something to mess around with. If you want the wheel to spin at a 1 to 1 distance as the speed is moving you'll have to do something else, but for now I am going to bed. You need an int timer for this.
- Code: Select all
int rot = ceil(xvelocity/15);
xvelocity*=.99;
timer+=xvelocity;
if(timer>=5)
{
animpos=((int)animpos+nframes-(int)max(1, rot))%nframes;
timer=0;
}
Re: xvelocity and wheel spin

Posted:
Mon Jun 20, 2011 12:58 pm
by sportmaster
generally looks not bad but I hoped that wheel will gradually rotate faster and faster but there are only few speeds when wheel accelerates, but still it looks convincingly, I can't do better even can't understand that code I wonder for example what is function ceil.
Re: xvelocity and wheel spin

Posted:
Mon Jun 20, 2011 2:26 pm
by Jagmaster
http://game-editor.com/CeilSounds like it's kind of like the round function. (I think it's short for ceiling, but I'm not sure.)
I learned that you can simply put a function name in the search box on the home page and it will give you a definition.