Game Maker's Garage Forum

Game Creation => Code Exchange => Topic started by: Gan on November 01, 2011, 11:30:05 AM

Title: Space Movement- How would you do it?
Post by: Gan on November 01, 2011, 11:30:05 AM
How would you guys make movement if you were making a space game?

How would you account for inertia, lack of friction and even propulsion as a space ship would like to move of it's own accord?
What about max speeds? Surely a ship shouldn't be able to propel itself to an infinite increasing velocity.
Title: Re: Space Movement- How would you do it?
Post by: GMG Kurt on November 01, 2011, 03:16:55 PM
"Now three researchers think they have found the source of inertia — and it turns out to be much closer to home. Inertia, they say, comes from the apparently empty space that surrounds us all — or rather, from the buzz of activity that, according to quantum theory, fills even a perfect vacuum, where subatomic particles are being created and annihilated in the blink of an eye. It is this ever-present sea of energy that the researchers believe resists the acceleration of mass, and so creates inertia." (http://www.calphysics.org/haisch/science.html, paragraph 3.)

So yes there is inertia, and because of that, it can't gain speed over that cap, or velocity over space terminal velocity.
Title: Re: Space Movement- How would you do it?
Post by: Charlo on November 01, 2011, 07:25:11 PM
Just make it so that you keep moving in the direction you were accelerating, even after letting go of the button and attempting to turn.

The max speed thing shouldn't be an issue, since you're making a game, not a space simulator.  Just cap it at something where it's not so fast as to be unplayable.
Title: Re: Space Movement- How would you do it?
Post by: Gan on November 01, 2011, 11:04:47 PM
What about outside forces?

Lets say your ship gets struck by a missile that on detonation propels it at a greater velocity than that of the ship's top speed, how would you compensate?
I foresee the problem being when the player attempts to move, it'll jump this ship's velocity to under the ship's max velocity. The jump would most likely be very noticeable.
Title: Re: Space Movement- How would you do it?
Post by: GMG Kurt on November 03, 2011, 03:42:53 PM
I've never taken a physics class, but if it was me i'd make all the velocity change to zero, and then remake a large amount of velocity in the direction of the rockets collision course as push-back.
Title: Re: Space Movement- How would you do it?
Post by: x on November 05, 2011, 06:08:12 AM
Newton worked this one out in the 18th century.

I made an implementation of vector based newtonian space movement a while ago -- here is a really shitty example: http://mirrorimg.net/im1/oht.zip

Obviously I introduced some inconsistencies to make it more fun to move around -- for example there is no friction in space, but I simulated friction anyways so it feels more natural.

Sorry its only compiled for Windows. I could compile it for Linux, but since I don't have a mac I can't compile it for mac.
Title: Re: Space Movement- How would you do it?
Post by: Connors on January 06, 2012, 06:38:27 PM
If you don't want it to suddenly go down to the speed limit when they hit go just program it so it only accelerates if it wouldn't go over the cap, and if it would add more than the cap add exactly enough speed to match it. It avoids automatically resetting speed. Another idea is to add friction only above a certain speed, again, not exactly realistic but possibly good for gameplay.
Of course it should always allow movement if it would slow you down.

Speaking of platformers... Oh no sorry got sidetracked there.
Title: Re: Space Movement- How would you do it?
Post by: EqwanoX on January 13, 2012, 08:48:52 AM
i would like to make a terminal velocity clone but whats the math equation for determining the trajectory of projectiles that coincide with the ships rotation, i know its something with pi but im not good with complex mathamamatics
Title: Re: Space Movement- How would you do it?
Post by: Connors on January 13, 2012, 10:03:58 AM
Yeah I just remembered I was gonna ask Gan how you fire projectiles based on rotation... Or fly the ship for that matter.
Title: Re: Space Movement- How would you do it?
Post by: Gan on January 13, 2012, 10:11:15 AM
I can create a shooting projectile demo based on real world physics using trigonometry after I finish the HTML5 GM.
Title: Re: Space Movement- How would you do it?
Post by: Connors on January 13, 2012, 03:46:55 PM
No I mean like in that nova space game how do you move based on rotation?
Title: Re: Space Movement- How would you do it?
Post by: Gan on January 13, 2012, 04:14:40 PM
I have an acceleration and velocity vector. Just some fancy trigonometry. Just a few angles, rotation and magnitude calculations.