N
NizarPlayz
Guest
Hey guy sorry to bother again so today i watched Shaun Spalding's video of how to make your player jump and walk so i did all the code in the object so the problem is my player always climb the walls i want it not to climb how can i do that here is my code
Object: obj_blueball
Event:Create
code:
//Initialize Variables
grav = 0.3;
hsp = 0;
vsp = 0;
jumpspeed = 7;
movespeed = 4;
Event:Step
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))
{
y += sign(vsp);
}
vsp =0;
}
x += vsp;
y += vsp;
And i had to repost this because no one was replying to my old thread and my other problem is how can i make my player roll around my player looks like a blue ball i want my player to roll like this
Object: obj_blueball
Event:Create
code:
//Initialize Variables
grav = 0.3;
hsp = 0;
vsp = 0;
jumpspeed = 7;
movespeed = 4;
Event:Step
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))
{
y += sign(vsp);
}
vsp =0;
}
x += vsp;
y += vsp;
And i had to repost this because no one was replying to my old thread and my other problem is how can i make my player roll around my player looks like a blue ball i want my player to roll like this