Page 1 of 1

Big prob with Kayak game, rotation.

PostPosted: Tue Jan 23, 2007 6:34 pm
by Sgt. Sparky
here is the
Code: Select all
if (animpos < angle)animpos += 5;
if (animpos > angle)animpos -= 5;

but if the animpos is 0-5 and the angle is bout' 360 or somthin' the kayak spins round' the other way and it makes the game look stupid :cry: any help would be nice. :D [/code]
and is there a way to use between codes like:
Code: Select all
if (animpos <10, angle > 350)animpos = angle;
??? :)
EDIT: oh, I feel stupid :lol: :oops: I just figured it out. but it is choppy, I am still open to Ideas :D Here is the Code now
Code: Select all
if (animpos < 7, angle > 353)animpos = angle;
if (animpos > 353, angle < 7)animpos = angle;
if (animpos < angle-7)animpos += 5;
if (animpos > angle+7)animpos -= 5;

PostPosted: Tue Jan 23, 2007 8:51 pm
by morcior
for best results coding this style of movement, it is a good idea to store 2 angle variables.

1. the real angle variable, the angle you render the boat at
2. the directional angle, the angle the boat wants to be facing

Have a piece of code in a timer that converges the real angle towards the directional angle, then you can just have a simple piece of code in the boats drawing event to say animpos = realangle;

You're kind of doing this at the moment but using the animpos variable as the real angle, which is integer data type so you'll get jumpy results. Use float or double for angles, vectors, speeds, etc!

PostPosted: Wed Jan 24, 2007 12:34 am
by Game A Gogo
instead of using "," use "&&", when having some script, it may do the action whiteout order, which cause problems.

PostPosted: Wed Jan 24, 2007 12:58 am
by Sgt. Sparky
no thank you morcior, if the animpos = the angle the when I hit the wall all of the sudden the kayak turns a round :( wich does not look realistic :) but thank you for posting a reply :D

PostPosted: Wed Jan 24, 2007 1:20 am
by Game A Gogo
well then, do this int he draw actor also:
Code: Select all
animpos=angle/360*nframes;

and you can use the code sugjested by morcior

PostPosted: Wed Jan 24, 2007 2:16 am
by Sgt. Sparky
but it does not look realistic, :( Imagine a Plane Flying 750MPH south, then all of te Sudden it is facind North going at 750MPH :) I am content with my code :lol: :oops: I am sorry If I have bothered you. :cry:

PostPosted: Wed Jan 24, 2007 5:45 am
by morcior
Shouldn't the boat just stop if it hits a wall? The theory I provided would not turn the boat around in such an event!

Oh well you're happy so lets leave it there :)

PostPosted: Thu Jan 25, 2007 3:00 am
by Sgt. Sparky
:? argh, in the game if the boat stopped then you would have to regain all of that speed(wich is not much)and it would make the game less fun, plus there are "rapids"(they don't really look like rapids)round' some of the rocks :D and the boat kinda' turns into the rapids an' stuff :) :o :D
and when it hit a wall going fast and all of the sudden stopped, it would not look all that great :( but maybe somhow I should just get makslane to delet this topic cus' it was pointless to post it in the first place :cry: :( sorry if I seem mad :(