Physic Spaceship with Speedlimit

0 favourites
From the Asset Store
Physics Block Puzzle game template for Construct 3
  • I would do something like this using custom movement behaviour:

    If Custom Movement Overall speed > Max speed

    Set Custom movement Overall speed to Sprite.CustomMovement.Speed*0.99

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • You dont have to calculate the direction, the acceleration or anything since the Custom movement speed is the final speed in the direction your sprite travels. So slowing that down when it's exceeding max speed will give you a speed limit.

  • If you want to see how my ships moves you can try my demo.

    dl.dropbox.com/u/48649374/Space%20Combat%20II%20v0.13.zip

  • The red Ship looks cool :D

    But sorry it runs too slow on my machine, its an old 2.4 Ghz (1FPS or so) and the ship is off screen too fast to judge handling.

    You used Construct right? ;)

    I think using Custom Behavior is no option for me. Its just not interactive enough for me. I have to do all the calculations, I would have to write my own Boxed2d Physic for things that collide, no thanks <img src="smileys/smiley6.gif" border="0" align="middle" />

    I prefer letting Physic behavior work it out with proper input and tweaking. The rotation already works really well with so little effort.

    I just want the math to work right (Angle_of_Motion). I'm just not seeing the flaw, if you or anyone could help me with that, I'm all happy ^^

    But thanks for your suggestions.

  • +++ 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:

    <img src="https://dl.dropbox.com/u/34146606/Source.png" border="0">

    Accel_Angle seems to not change at all once Max_Speed is reached <img src="smileys/smiley5.gif" border="0" align="middle">

    Still not sure if I picked the right formulas. <img src="smileys/smiley24.gif" border="0" align="middle">

  • anyone?

  • 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.

    dl.dropbox.com/u/14522925/Spaceship%20movement.capx

  • 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? <img src="smileys/smiley7.gif" border="0" align="middle" />

  • 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! ] <img src="smileys/smiley36.gif" border="0" align="middle">

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

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

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)