xvelocity and wheel spin

Non-platform specific questions.

xvelocity and wheel spin

Postby sportmaster » Sun Jun 19, 2011 7:33 pm

I need code to synchronize wheel spin and wheel's speed.
Attachments
wheel.rar
(336.99 KiB) Downloaded 81 times
wheel_problem.jpg
User avatar
sportmaster
 
Posts: 32
Joined: Thu Jun 25, 2009 8:29 pm
Score: 0 Give a positive score

Re: xvelocity and wheel spin

Postby skydereign » Mon Jun 20, 2011 9:03 am

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;
}
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: xvelocity and wheel spin

Postby sportmaster » Mon Jun 20, 2011 12:58 pm

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.
User avatar
sportmaster
 
Posts: 32
Joined: Thu Jun 25, 2009 8:29 pm
Score: 0 Give a positive score

Re: xvelocity and wheel spin

Postby Jagmaster » Mon Jun 20, 2011 2:26 pm

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.
User avatar
Jagmaster
 
Posts: 875
Joined: Sun May 08, 2011 4:14 pm
Location: Not where you think.
Score: 82 Give a positive score

Re: xvelocity and wheel spin

Postby schnellboot » Mon Jun 20, 2011 2:38 pm

haha ceil = ceiling xD
schnellboot
 
Posts: 819
Joined: Sat Mar 31, 2007 1:35 pm
Location: Germany
Score: 102 Give a positive score

Re: xvelocity and wheel spin

Postby Jagmaster » Mon Jun 20, 2011 3:03 pm

Well....
Ceil.png

XD
User avatar
Jagmaster
 
Posts: 875
Joined: Sun May 08, 2011 4:14 pm
Location: Not where you think.
Score: 82 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest