too much Gravity

Talk about making games.

too much Gravity

Postby The achievement » Tue Feb 14, 2006 11:12 pm

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.
User avatar
The achievement
 
Posts: 220
Joined: Sun Feb 12, 2006 11:01 pm
Location: United States,Massachusetts
Score: 0 Give a positive score

Postby Kodo » Tue Feb 14, 2006 11:51 pm

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!

}
Inogames: http://www.inogames.com iOS gaming
Firetop Adventure (app store): http://itunes.apple.com/us/app/firetop- ... ?mt=8&ls=1
User avatar
Kodo
 
Posts: 449
Joined: Thu Oct 20, 2005 8:20 pm
Location: UK
Score: 23 Give a positive score

Postby The achievement » Wed Feb 15, 2006 12:13 am

When i try to type in the code it keeps saying Undeclared identifier on_platform? What does that mean?
User avatar
The achievement
 
Posts: 220
Joined: Sun Feb 12, 2006 11:01 pm
Location: United States,Massachusetts
Score: 0 Give a positive score

Postby Kodo » Wed Feb 15, 2006 12:49 am

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! :)
Inogames: http://www.inogames.com iOS gaming
Firetop Adventure (app store): http://itunes.apple.com/us/app/firetop- ... ?mt=8&ls=1
User avatar
Kodo
 
Posts: 449
Joined: Thu Oct 20, 2005 8:20 pm
Location: UK
Score: 23 Give a positive score

Postby speckford123 » Fri May 05, 2006 6:42 pm

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:
speckford123
 
Posts: 334
Joined: Fri May 05, 2006 6:33 pm
Score: 49 Give a positive score

Postby The achievement » Fri May 05, 2006 7:18 pm

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:
User avatar
The achievement
 
Posts: 220
Joined: Sun Feb 12, 2006 11:01 pm
Location: United States,Massachusetts
Score: 0 Give a positive score

Postby Fuzzy » Fri May 05, 2006 7:53 pm

[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;
Mortal Enemy of IF....THEN(and Inspector Gadget)

Still ThreeFingerPete to tekdino
User avatar
Fuzzy
 
Posts: 1068
Joined: Thu Mar 03, 2005 9:32 am
Location: Plymostic Programmer
Score: 95 Give a positive score

Postby Troodon » Tue May 09, 2006 5:42 pm

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:
I can't die, I already tried
~on the forums since GE 1.3.3~
User avatar
Troodon
 
Posts: 1539
Joined: Thu Jan 12, 2006 3:29 pm
Location: HELL
Score: 56 Give a positive score

Postby speckford123 » Thu Jun 08, 2006 9:27 pm

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:
speckford123
 
Posts: 334
Joined: Fri May 05, 2006 6:33 pm
Score: 49 Give a positive score

Postby Hyperyon » Mon Jun 26, 2006 1:42 pm

...I dont get it :cry:
Lets keep our dreams alive!
Hyperyon
 
Posts: 148
Joined: Sat Jun 24, 2006 1:29 pm
Score: 0 Give a positive score


Return to Game Development

Who is online

Users browsing this forum: No registered users and 1 guest