Page 1 of 1

How do you jump normal?

PostPosted: Fri Jul 27, 2007 3:22 pm
by supa-tails
I know alot of scripts, but how do you make a good script for jumping up and down without the ability to jump infinitly? Also, I am making a game where you play as Tails(A two tailed flying fox) and how can I put a limit to how high he goes before he gets tired and slowly descends?

PostPosted: Fri Jul 27, 2007 3:38 pm
by d-soldier
Welcome to the forum! Keep in mind that most issues you will run into when starting have most likely been addressed in the past, and probably more then once. So try using the search button:

Most of your question can be answered here:
http://game-editor.com/forum/viewtopic. ... light=jump

As far as tails being able to slowly hover down after a jump, you will need to set up a variable.
His normal draw actor script should have something like:

yvelocity += .8;
if(yvelocity > 20) yvelocity = 20;

which acts as gravity pulling him down. If you were to setup a variable called "float" and set it to your jump key:
Keydown event:
float=1;
KeyUp event:
float=0;
then you would have to find the optimum time to check if the key is down (after the jump animation is done?)/??
And the new draw actor script would be something like:
if (float==0)
{
yvelocity += .8;
if(yvelocity > 20) yvelocity = 20;
}
if (float==1 && canjump==0)
{
yvelocity += .2;
if(yvelocity > 20) yvelocity = 20;
}

- which has normal gravity all the time, except when you are not in contact with the ground and the jump key is held down... this of course after you script everything as it is in the first link I posted. Hope this helped.

PostPosted: Fri Jul 27, 2007 4:26 pm
by supa-tails
Thank you so much! But, I read the view topic thingie and it said to Click up on SCRIPT menubar, then add an actor variable called "canjump".
What is the actor variable and how do you add one :?:

PostPosted: Fri Jul 27, 2007 4:39 pm
by d-soldier
Click up on SCRIPT, then GLOBAL CODE, then the button on the bottom right which says "VARIABLES" click "ADD", put "float" in the NAME box, then CLICK "ADD".

PostPosted: Fri Jul 27, 2007 4:57 pm
by supa-tails
Oh my gosh! Thank you! You solved my ultimate problem in GE so far, now I can make a worthy Tails game!!! :D :D :D

PostPosted: Fri Jul 27, 2007 11:58 pm
by Game A Gogo
welcome to the forum, hehe, I love the over-sized chaos emeralds ;)

PostPosted: Sat Jul 28, 2007 1:32 pm
by pavel329
this is good.
it worked well for me.

PostPosted: Sun Jul 29, 2007 12:57 pm
by supa-tails
Oh, and just a little thing I discovered, it wont let you put float because there is already a variable named that so you have too put floater. And once again, thank you so much for the help. :D

PostPosted: Sun Jul 29, 2007 11:32 pm
by Game A Gogo
supa-tails wrote:Oh, and just a little thing I discovered, it wont let you put float because there is already a variable named that so you have too put floater. And once again, thank you so much for the help. :D


its not that its a variable, its a function to declare a variable inside a script (Actor variable, and can only be used inside the script) like
Code: Select all
float MyVar=1.0123
Floats has only 4 decimal places and double is like float but whit greater precision, twice as big. but I'm not sure about htis in GE, i think its the same :O

PostPosted: Mon Jul 30, 2007 3:04 am
by Sgt. Sparky
Game A Gogo wrote:
supa-tails wrote:
Code: Select all
float MyVar=1.0123
Floats has only 4 decimal places

I have used it with alot more decimal places than that and printed them onto a text actor and it came up with the exact numbers I started with. :D

PostPosted: Mon Jul 30, 2007 4:51 am
by Fuzzy
float is a 16 bit floating point number. the number of decimal places that it will display are not limited to 4 or even 16, but rather, the precision of the number can suffer when its really big or has a really small portion.

A double on the other hand is 32 bit, so its math is a lot more precise.