Oh wow, that's completely awesome - thankyou so much.
It's funny: my spacebar and arrow keys conflict so the aerial movement was off for me in your example - that forced me to suck it up and actually dip into the code and tweak it. It sounds kind of silly, but that was a real useful exercise for me. I don't think I'll be doing any coding with GML any time soon, but it was great to know that maybe it's not completely beyond my understanding. I really appreciate the annotations, they were super helpful.
The way gravity still stays with the hovering object is strange, but I'm not sure it's a problem - when I was envisioning how the movement worked in my head I never made up my mind whether I wanted it to stay put or fall a little bit and require a bit of input upkeep.
Definitely get into using the code. It takes a while to nail (regularly using it, maybe a month?) but once you do it, it's 100% easier to write and maintain your games with. It's also a lot easier for reading, etc.
To be honest, I'm not even sure why the gravity is acting that way.. if you want to do a quick test, pop this into a code box in the obj_ball's draw event:
draw_sprite(sprite_index,image_index,x,y); // draw our sprite...
draw_text(x,y-16,string(gravity)); //draw the value of gravity.
You'll notice that when it 'hovers' gravity flickers between 0 and 1.
I bet it's something silly I'm doing. :p
(comes back after a few minutes testing)
Yes, yes, I'm an idiot. Sorry, here is a snippet from the Step even which I edited.
if place_free(x,y+1) // if nothing solid is beneath us...
{
gravity_direction=270; //270 is down.
gravity=1; // a nice, weak gravity.
//okay, this next bit is a little higgly. BUT it's to get the code working 100%
//all it does, is check if our vspeed is positive (i.e. we are falling)
// and if we are meant be be hovering. Simple!
if hover=true // we aren't meant to fall.. we are meant to hover.
{
if vspeed>=0 // we are falling!
{
vspeed=0; //then don't fall! Dumkoff!
gravity=0;
}
}
}
Notice the difference? Yes, the if vspeed>=0. I didn't put the '=' sign in.
Just pop that '=' sign in, over there (it means, if vspeed is larger than, or equal to 0 )
and then your good to go!
I really shouldn't be coding past 12 :p G'nite mate, hope this helps ya.