Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Changing angle while advancing

Author
Message
BraindeaD
16
Years of Service
User Offline
Joined: 30th Mar 2008
Location:
Posted: 20th Apr 2012 20:30
Hi all,
I'm applying a velocity to a physic object in a certain angle using this code:


I'm decreasing the object speed by multiplying the object velocity x and y by 0.98 each loop.

I'm trying to change the angle using cursor left and right with setspriteangle(obj,getspriteangle(obj)+2) or setspriteangle(obj,getspriteangle(obj)-2), depending on what key is pressed... but the object continues with its original direction.
Anybody knows how can I change the object direction to the new angle with the current object's speed...
Hope the explain is ok...

Thanks in advance.
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 20th Apr 2012 21:21
You need to change the velocity to suit the angle rather than the other way around.

SetSpritePhysicsVelocity is based on screen not sprite angle. You need to use sin and cos of the sprite angle to set the velocity.

Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 20th Apr 2012 21:45
I tried to set up a simple test, to try applying angle to vector, sort of. And to see if I could help BraindeaD figure out what to do.

And found that I cannot make the sprite move at all! The same basic code works fine in the game I'm doing, but this simple snippet won't work!



Cheers,
Ancient Lady
BraindeaD
16
Years of Service
User Offline
Joined: 30th Mar 2008
Location:
Posted: 21st Apr 2012 10:11
Hi and thanks for the replies.
The main idea is emulate the aftertouch effect in games like kickoff and sensible soccer.
Finally I get something similar using:

You must add or subtract 90 to the angle depending on the key pressed to emulate the left or right aftertouch.
thanks again for your help.

Login to post a reply

Server time is: 2024-11-23 08:54:31
Your offset time is: 2024-11-23 08:54:31