Page 1 of 1

xvelocity and wheel spin

PostPosted: 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

PostPosted: 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

PostPosted: 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

PostPosted: Mon Jun 20, 2011 2:26 pm
by Jagmaster
http://game-editor.com/Ceil

Sounds 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.

Re: xvelocity and wheel spin

PostPosted: Mon Jun 20, 2011 2:38 pm
by schnellboot
haha ceil = ceiling xD

Re: xvelocity and wheel spin

PostPosted: Mon Jun 20, 2011 3:03 pm
by Jagmaster
Well....
Ceil.png

XD