Page 1 of 1

too much Gravity

PostPosted: Tue Feb 14, 2006 11:12 pm
by The achievement
Hi, when my character jumps when i hit the space bar and if i keep hitting the space bar he just keeps jumping? Can some one tell me a code that doesent make him keep jumping in the air? Im guessing it is yvelocity or xvelocity x=x-5; or x=x=5;?sombody help.

PostPosted: Tue Feb 14, 2006 11:51 pm
by Kodo
What you need to do is create a variable and set it to TRUE when the character is colliding with the ground (or any object you want to be able to jump from), then on Collision Finish set that variable to FALSE (this catches the times where your actor walks off of platforms, when jumping we manually set the variable to false, see code below). What you get is a variable that is true when the actor is on the ground and false if it is in the air. To stop the actor from being able to jump when already in the air all you need to do is check the variable!

if (on_platform == TRUE)
{
// do jump code here

on_platform = FALSE; // because we know the actor just jumped!

}

PostPosted: Wed Feb 15, 2006 12:13 am
by The achievement
When i try to type in the code it keeps saying Undeclared identifier on_platform? What does that mean?

PostPosted: Wed Feb 15, 2006 12:49 am
by Kodo
You need to create the variable, its just an example, er, in my example :)

In the script window where you typed the code youll notice a 'Variables' button, click it, then click 'Add'. All you need to do there is enter the name of the new variable at the top and click the 'add' button at the bottom. You'll need to do alot of that if you'll be doing much scripting.

Also, make sure that in the global code you cave the following two lines of code as they will allow you to use TRUE and FALSE in your scripts:

const FALSE = 0;
const TRUE = -1;

It's worth sticking with it mind, it can be a bit daugnting at first but youll soon get the hang of it :) If you load up the demo levels and look at them carefully you'll get a good idea how things are put together, but I realise its not always obvious so dont worry about asking! :)

PostPosted: Fri May 05, 2006 6:42 pm
by speckford123
you could also use a noob code on key up event put in the opposite of the key down event (e.g. key down / yvelocity=yvelocity-8;
key up / yvelocity=yvelocity+8; :wink:

PostPosted: Fri May 05, 2006 7:18 pm
by The achievement
that dont work dude. because thats just telling the actor how far or how long he can jump.

Its impossible to do it without a variable. :wink:

PostPosted: Fri May 05, 2006 7:53 pm
by Fuzzy
[quote="Steve"]
const FALSE = 0;
const TRUE = -1;
[quote]

This will work, but i find it more useful to say
#define TRUE 1
#define FALSE !TRUE

The reason I do it this way is because I can then use math against true and false without needing to fuss with the negative sign.

I'd also use these at times...

#define ON 1
#define OFF !ON
#define SHIELDS SHstate * energylevel

so I can pull stunts like...
[in create actor event]
SHstate = OFF;

[in a keypress event]
SHstate = !SHstate;

[in other code]
Health = Health - (Damage * SHEILDS);

freeing me up to be able to flip shields on/off without needing to figure the previous state and being able to apply damage without fussing with an if to determine if that shield is actually turned on.

I save two IFs right there.

In the case of jumping, we can do something similar

#define JUMP 1
#define JSPEED = Jstate * acceleration

[in jump keypress]
yvelocity = yvelocity + JSPEED;
Jstate = !JUMP;

[once you land]
Jstate = JUMP;

PostPosted: Tue May 09, 2006 5:42 pm
by Troodon
speckford123 wrote:you could also use a noob code on key up event put in the opposite of the key down event (e.g. key down / yvelocity=yvelocity-8;
key up / yvelocity=yvelocity+8; :wink:


I don't think that there is noob codes in GE. :wink:

PostPosted: Thu Jun 08, 2006 9:27 pm
by speckford123
tekdino wrote:
speckford123 wrote:you could also use a noob code on key up event put in the opposite of the key down event (e.g. key down / yvelocity=yvelocity-8;
key up / yvelocity=yvelocity+8; :wink:


I don't think that there is noob codes in GE. :wink:


well yeah...... but this is for when you jump, when you let go
you stop.
(p.s. use variable to prevent you from going down
while....going down)
this is what I first used because I couldn't ask you guys for help :wink:

PostPosted: Mon Jun 26, 2006 1:42 pm
by Hyperyon
...I dont get it :cry: