2d planet game help

For questions about using Classic.

Post » Sun Dec 11, 2011 8:44 pm

In the custom movement behavior you can move objects "horizontally" and "vertically" according to a specified angle of orientation. I thought, "this will be perfect for my 2d planet game where there is no 'up' or 'down'-- its all relative! I now realize this might be more math than I anticipated.

Is there a way to get this relative "horizontal" and "vertical" speed of an object, and not just it's X and Y speed?

Better yet, can someone take a look at this cap and tell me if there is a better way to do this? In addition to this road block I have hit, there are numerous other little flaws in my custom movement platform behavior. I feel there is some sort of elegant trigonometric solution to all my problems that I am unable to see...

http://dl.dropbox.com/u/19590484/compass.cap

aldo2011-12-11 20:50:26
B
5
S
1
G
2
Posts: 99
Reputation: 1,575

Post » Mon Dec 12, 2011 1:11 am

Maybe I am misunderstanding this. but "horizontal" and "vertical" relative to the angle of motion doesn't make much sense.

When your object moves with 50 pixel per second at an angle of 10, then the speed's x-component is cos(10) * 50 (ca 49.24), and the y-component is sin(10) * 50 (ca 8.68)

But a relative "vertical" component to an object moving at any angle would just be the speed (cos(0)) and the "horizontal" one would always be 0 (sin(90))
Image
B
23
S
8
G
10
Posts: 1,820
Reputation: 8,242

Post » Mon Dec 12, 2011 2:00 am

My apologies, I meant angle of the sprite and not the angle of motion.

At any rate, even with you misunderstanding what I meant you still answered my question for a trigonometric solution to calculating X and Y. I am still trying to understand where these triangles are being formed.

Thank you so much!
B
5
S
1
G
2
Posts: 99
Reputation: 1,575

Post » Mon Dec 12, 2011 3:53 am

[QUOTE=aldo] I am still trying to understand where these triangles are being formed.[/QUOTE]
object starting point is red
object ending point is pink
light grey lines are examples of nonrelative x and y offsets.
black are examples of directions of motion.

when you're trying to get the speed relative to an angle, you're trying to get the black part of the triangles.
lucid2011-12-12 03:56:55
Spriter Dev
B
87
S
21
G
12
Posts: 3,240
Reputation: 16,461

Post » Mon Dec 12, 2011 6:24 am

[QUOTE=aldo] My apologies, I meant angle of the sprite and not the angle of motion.[/QUOTE]
Ah, yes, that makes sense. And lucid's graphic should make it more clear.

But here is a practical example:
Again, the sprite is moving with 50 pixel per second at an angle of 10

x-component 49.24
y-component 8.68

Now the sprite rotates to 330. The player hits the thrust button (max speed again 50 pps)[or a planet gets into the influence of another mass, something like that]. Now you need to aim for a final

x-component cos(330) * 50 -> ca 43,3
y-component sin(330) * 50 -> -25

So you need to interpolate (qarp should do) between

x 49.24 and 43,3
y 8.68 and -25

for whatever time feels right for your game.
Image
B
23
S
8
G
10
Posts: 1,820
Reputation: 8,242


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 0 guests