• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Legacy GM parents

F

filipe

Guest
I have just finished following this plat-former tutorial the code works great but i more than one wall
i have try to use the parents thing but the other walls will fall down because of the player code.
here is the tutorial
and the all the code related to that tutorial
Code:
///Initialize Variable
grav = 0.2;
hsp = 0;
vsp = 0;
jumpspeed = 7;
movespeed = 4;
Code:
///Get the player's input
key_right = keyboard_check(vk_right);
key_left = -keyboard_check(vk_left);
key_jump = keyboard_check_pressed(vk_space);

//React to inputs
move = key_left + key_right;
hsp = move * movespeed;
if (vsp < 10)  vsp += grav;

if (place_meeting(x,y+1,obj_ground))
{
    vsp = key_jump * -jumpspeed
}

//Horizontal Collision
if (place_meeting(x+hsp,y,obj_ground))
{
    while(!place_meeting(x+sign(hsp),y,obj_ground))
     {
     x += sign(hsp);
     }
     hsp = 0;


}
x += hsp;
//Vertical Collision
if (place_meeting(x,y+vsp,obj_ground))
{
    while(!place_meeting(x,y+sign(vsp),obj_ground))
     {
     x += sign(vsp);
     }
     vsp = 0;


}
y += vsp;
 
G

Gillen82

Guest
Don't use the player object as the parent of the walls. In your code, you are using obj_ground as the object that the player collides with...so use obj_ground as the parent object for walls as well
 
F

filipe

Guest
I just founded a problem with the plat former tutorial code
i'm going to try another tutorial
thanks anyway for ya help.
 

TheouAegis

Member
Dont follow a tutorial. Figure out what the code's intent was and adjust it to retain the intent with appropriate code changes.
 
Top