GML Help me please

T

Thiccypoo

Guest
I have movement fully coded except for jump, I fly when I hold the button down can someone tell me coding to stop that please
People are asking for code, it's in multiple parts.
I'll separate the sections with bullets

  • /// Initiate Variable

    if place_free(x,y+1) { gravity = 0.7 gravity_direction = 270 } else { gravity=0 gravity_direction = 270 };
    if place_free(x-4,y)and keyboard_check(vk_left){x-=4};
    if place_free(x+4,y)and keyboard_check(vk_right){x+=4} ;
    if place_free(x,y-1) and keyboard_check(vk_up){vspeed=-10};

  • /// Initialize Variable
    grav = 0.7;
    hsp = 0;
    vsp = 0;
    jumpspeed = 8;
    movespeed = 7;
  • /// Get Player's Input
    key_right = keyboard_check (vk_right);
    key_left = keyboard_check (vk_left);
    key_up = keyboard_check (vk_up);
All I really need is a way to prevent the character from flying, thank you
 

M. Idrees

Member
Check For The DOwn Place Not For The Up Place Collision.
like
Code:
if  ( !place_free(x,y+1) and keyboard_check(vk_up) ){
      vspeed=-10
};
 
Last edited:
T

Thiccypoo

Guest
Check For The DOwn Place Not For The Up Place Collision.
like
Code:
if place_free(x,y+1) and keyboard_check(vk_up){vspeed=-10};
It's already -1 were did the +1 in that come from? I don't understand it should already be checking down
 

M. Idrees

Member
Sorry Check Again My Comment.

+1 Means Checking The Collision With Solid Objects In Bottom Place.
-1 Means Checking The Collision With Solid Objects In Top Place.

If There Is Not Solid Object In The Top Place The Player Will Fly.
 
N

nicktheslayer95

Guest
It's already -1 were did the +1 in that come from? I don't understand it should already be checking down
It might be a bit counter-intuitive, but - is up, and + is down. See how your jump speed is a negative number, even though your jumping up? You have to use the +1 to check below the player.
 
T

Thiccypoo

Guest
Sorry Check Again My Comment.

+1 Means Checking The Collision With Solid Objects In Bottom Place.
-1 Means Checking The Collision With Solid Objects In Top Place.

If There Is Not Solid Object In The Top Place The Player Will Fly.
I tried it and it just stops it from jumping all together
 

Kyon

Member
Does your character has an sprite animation? If so, make sure to set a sprite mask.
But just to be clear, this doesn't work?:
Code:
if !place_free(x,y+1) //if the spot 1 pixel below the player isn't free
{
    if keyboard_check_pressed(vk_up) //if you press up once
    {
         vspeed=-10; //jumps
    }}
also I notice in your first post you put the ';' after the } mark.
I'm not sure that even works.
Should be:
Code:
if place_free(x,y+1) { gravity = 0.7; gravity_direction = 270; } else { gravity=0; gravity_direction = 270; }
instead of:
Code:
if place_free(x,y+1) { gravity = 0.7 gravity_direction = 270 } else { gravity=0 gravity_direction = 270 };
I might be wrong though haha.
 
T

Thiccypoo

Guest
Does your character has an sprite animation? If so, make sure to set a sprite mask.
But just to be clear, this doesn't work?:
Code:
if !place_free(x,y+1) //if the spot 1 pixel below the player isn't free
{
    if keyboard_check_pressed(vk_up) //if you press up once
    {
         vspeed=-10; //jumps
    }}
also I notice in your first post you put the ';' after the } mark.
I'm not sure that even works.
Should be:
Code:
if place_free(x,y+1) { gravity = 0.7; gravity_direction = 270; } else { gravity=0; gravity_direction = 270; }
instead of:


I might be wrong though haha.
Thanks for the help, it worked :D
 
Top