continuous jumping problem
#1
Posted 07 March 2012 - 05:30 AM
http://www.mediafire...yzuhhndz3wj7l78
maybe suggest some codes, I tried the InAir variable but i think ive done it wrong
#2
Posted 07 March 2012 - 05:35 AM
This is one of the most basic of problems so if you do it just like that, it should work no trouble.
#3
Posted 07 March 2012 - 06:02 AM
#4
Posted 07 March 2012 - 07:02 AM
Looked at the game, in the up event:i have done that i think :/... which is why i added my game because i actually need my jumping checked out, i have variables and stuff set up but still i can jump as much as i wish
if InAir = false
{
if collision_free...
do this...
do that...
}
else set InAir = true. Three Problems:
1. You want InAir to be true when Mario is in the air, right? What you are currently doing is checking if he is in the air, if so doing whatever is in the block, otherwise setting it to true. Instead, you want InAir to be set to true if InAir is false, so it should go in the block.
2. the if collision_free bit only applies to the next instruction, so if you put this
if a = 2
do this
do that
GM reads it like this
if a = 2
do this
then do that (whether a = 2 or not)
so you should put a block surrounding everything you want to happen.
3. Dont use . in the name of something. This leads to problems if you want to use code. Use _ instead ie change the name of s.mario to s_mario
So this is what it should look like in the end:
if InAir = false
if collision_free...
{
(do everything to make him jump)
}
The { means start block and } means end block.
#5
Posted 07 March 2012 - 07:11 AM
check empty:
self
x = 0
y = -1
relative
(checks to see if there is nothing above you)
under the current check empty
this should fix your problem it makes sure that you are on the ground and that there is nothing above you so that you can jump
if you would like you could do this with GML coding
//add this to your step event
{
{
if place_free(x, y + 1)
{
gravity = 0.5;
}
else
{
gravity = 0;
}
}
{
if vspeed > 12
{
vspeed = 12;
}
}
}
//add this to you up key event
{
if place_free(x,y - 1) && not place_free(x,y + 1)
{
vspeed = -12;
}
}
Edited by Emthril, 07 March 2012 - 07:59 AM.
#6
Posted 07 March 2012 - 10:47 AM
#7
Posted 07 March 2012 - 03:33 PM
All you need to do is: Under create:
ImJumping = false;
Under pressing the up key:
if ImJumping = false{
// then you would just convert the d&d you're using into code (there is a whole thread of the d&d/code equivalents)
ImJumping = true;}Under collision with a floor object:
ImJumping = false;
There I have basically done all the work for you. Now what you should do is add in your coding from the d&d actions you need, and look over the coding to try to understand WHY it works
#8
Posted 07 March 2012 - 07:01 PM
the first part i has shown was D&D the next part was only if you were interestedhmm... i read both of what you guys said and im getting kind of confused :/ id prefer to use D&D if it helped, coding will just complicate it further for me at the moment
#9
Posted 08 March 2012 - 04:23 AM
hmm... i read both of what you guys said and im getting kind of confused :/ id prefer to use D&D if it helped, coding will just complicate it further for me at the moment
My one is d&d...
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users











