Physic Spaceship with Speedlimit

Get help using Construct 2

Post » Fri Dec 14, 2012 11:52 pm

+++ Update +++

I made the code more readable and changed my initial approach. I Studied some Geometry:
Polar and Cartesian Coordinates

I looked for the right way to Convert the Polar Coordinates (Angle and Force) to Cartesian Coordinates (VelocityX VelocityY). So when the Spaceship is about to exceed Max_Speed I want to get the Angle of current motion + Acceleratio * dt.
Then use that Angle and set VelocityX VelocityY with new Angle but old Speed.

Here is the CAPX
(at update_Spaceship/Apply_Input marked with comments (3x))
(Use Arrow Keys and Ctrl)

This is my approach:


Accel_Angle seems to not change at all once Max_Speed is reached

Still not sure if I picked the right formulas.
B
4
S
1
G
1
Posts: 49
Reputation: 997

Post » Tue Dec 18, 2012 3:08 am

anyone?
B
4
S
1
G
1
Posts: 49
Reputation: 997

Post » Tue Dec 18, 2012 9:51 am

I've been working on a top-down spaceship game for the last couple of days. I'm pretty new to C2, but I hunted through the forums here and got the math needed to calculate current speed using physics (wish I had paid more attention in school, actually). Apologies for not crediting whomever I got the formula from. I guess we'll put it down to Pythagoras :P

Once I had CurrentSpeed calculated, for me to limit that speed I created a variable MaxSpeed, and only apply the force when the arrow key is pressed and the CurrentSpeed is less than MaxSpeed. I don't have nearly the amount of fancy physics you have going on in your project, but it seems to do what you need it to do. There's also a neat little thruster particle effect that I'm working on; you're welcome to it if you like.

Oh, and I should mention that this method only works if there's at least a small amount of linear damping on the player object. Otherwise all keypresses that would increase force are simply not registered, because the player quickly gets up to MaxSpeed with no way of slowing down. I realise that this isn't realistic, but since you mentioned you're going for a semi-arcade feel (exactly what I'm going for as well), I feel that it's a good compromise.

http://dl.dropbox.com/u/14522925/Spaceship%20movement.capxGeometriX2012-12-18 17:11:12
B
56
S
15
G
10
Posts: 910
Reputation: 11,942

Post » Tue Dec 18, 2012 11:54 pm

Thanks but I just need the correct Angle_of_motion when Acceleration is added, the rest works fine. I've send you PM and edited your sample how to use 100% Physic in your game^^

Maybe you can figure out what is going on with the angle?
B
4
S
1
G
1
Posts: 49
Reputation: 997

Post » Sat Feb 09, 2013 8:15 am

I replaced the impulses with forces, as forces are applied slowly over time, I also replaced the non-physics rotation with physics-based - the angles seem reliable now.

May have also thrown in some rocks and bullets [ space to fire! ]

http://www.johnnysix.net/games/shh/

CAPX http://www.johnnysix.net/games/shh/Shh.capx

Image
B
27
S
9
G
5
Posts: 487
Reputation: 11,939

Previous

Return to How do I....?

Who is online

Users browsing this forum: Yahoo [Bot] and 22 guests