Jump to content


Photo

continuous jumping problem


  • Please log in to reply
8 replies to this topic

#1 _256539

_256539

    GMC Member

  • New Member
  • 7 posts

Posted 07 March 2012 - 05:30 AM

Yes before you ask i've used the search feature and i've found topics based around this but I tried those methods, and I don't know if what i've done is wrong or not but i need some help because my mario object continuously jumps if the player keeps pressing the up directional button. can someone please look at my game and help me with this
http://www.mediafire...yzuhhndz3wj7l78
maybe suggest some codes, I tried the InAir variable but i think ive done it wrong
  • 0

#2 shledder

shledder

    GMC Member

  • GMC Member
  • 76 posts
  • Version:GM8

Posted 07 March 2012 - 05:35 AM

Didn't dl your game, but try creating a variable with your mario object. Call it InAir. In the create, set this variable to false. Under keyboard up key, your first line of code should be and if statement. Say if InAir = false{ [then you would put your coding in here such as vspeed = -3 and gravity = .04]. Then you include InAir = true. Under you collision with floor object, add in InAir = false.

This is one of the most basic of problems so if you do it just like that, it should work no trouble.
  • 0

#3 _256539

_256539

    GMC Member

  • New Member
  • 7 posts

Posted 07 March 2012 - 06:02 AM

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
  • 0

#4 lukew23

lukew23

    GMC Member

  • GMC Member
  • 276 posts
  • Version:Unknown

Posted 07 March 2012 - 07:02 AM

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

Looked at the game, in the up event:

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.
  • 0

#5 Emthril

Emthril

    GMC Member

  • New Member
  • 82 posts
  • Version:GM8

Posted 07 March 2012 - 07:11 AM

ok couple things one (this will all be in your up event) in your current check empty change it so NOT is selected (this checks to see if you are on the ground) then add

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.

  • 0

#6 _256539

_256539

    GMC Member

  • New Member
  • 7 posts

Posted 07 March 2012 - 10:47 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 :P
  • 0

#7 shledder

shledder

    GMC Member

  • GMC Member
  • 76 posts
  • Version:GM8

Posted 07 March 2012 - 03:33 PM

Sometimes coding will actually be easier than d&d, especially when you'll need more actions to drag n drop than lines of code. If you think about it critically, most coding (the stuff you are trying to do) is very easy.
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
  • 0

#8 Emthril

Emthril

    GMC Member

  • New Member
  • 82 posts
  • Version:GM8

Posted 07 March 2012 - 07:01 PM

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 :P

the first part i has shown was D&D the next part was only if you were interested
  • 0

#9 lukew23

lukew23

    GMC Member

  • GMC Member
  • 276 posts
  • Version:Unknown

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 :P


My one is d&d...
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users