Apexpredator
Member
i followed Shuan spalding tutorial for platform collision and my character object keeps getting stuck on the corners of 2 meeting walls. i am also having trouble with animations, for some reason my run animation always shows instead of walking and go off for a split second while in air. i pretty sure i have written the codes to check for that. sorry for the bad explanation i'm still new to coding with out drag and drop. thanks in advance
create event:
Step event
create event:
Code:
global.GP = gamepad_is_supported();
///variables
global.levelcomplete=0
rsp=room_speed
global.Health=100
lives=3
global.points=0
//powerups
wreker=false
crusher=false
elctro=false
pyro=false
springtail=false
//movment vars
vsp=0;
hsp=0;
grav=0.5;
jumpspeed=7;
movespeed=2;
run=false;
hurt=false;
djump=false;
longjump=false;
//aimation vars
facing=image_xscale;
face=1
inair=false;
idle=false;
walk=true;
run=false;
ground=false;
highfall=false;
nearedge=false;
Step event
Code:
/// Movment
//inputs
key_right = keyboard_check(vk_right) or gamepad_button_check(0, gp_padr);
key_left = keyboard_check(vk_left) or gamepad_button_check(0, gp_padl);
key_up = keyboard_check(vk_up) or gamepad_button_check(0, gp_padu);
key_down = -keyboard_check(vk_down) or gamepad_button_check(0, gp_padd);
key_jump = keyboard_check_pressed(ord("Z"))or gamepad_button_check_pressed(0, gp_face1);
key_run = keyboard_check(ord("X"))or gamepad_button_check(0, gp_face2) {run=true}
// react to inputs
var move = key_right - key_left;
if hsp && vsp=move {idle=true};
if hsp && vsp=!move {idle=false};
// Horizontal movment
hsp = move * movespeed;
if key_run &&inair= false
{
hsp = move * movespeed *1.5;
walk=false;
}
else
{
hsp=move * movespeed;
walk=true;
}
// gravity
if (vsp < 10) vsp += grav;
// jumping
if (key_jump && place_meeting(x, y+1, obj_wall))
{
vsp = -jumpspeed;
;
}
if key_jump
{
if (vsp>-jumpspeed)&&djump =true
{
vsp = -jumpspeed;
djump=false;
}
}
//vertical motion
if ground=true
{
inair=false;
highfall=false;
}
// horizontal collision
if (place_meeting(x + hsp, y, obj_wall))
{
while (!place_meeting(x + sign(hsp), y, obj_wall))
{
x += sign(hsp);
}
hsp = 0;
}
x+=hsp;
// vertical collision
if (place_meeting(x, y + vsp, obj_wall))
{
while (!place_meeting(x, y + sign(vsp), obj_wall))
{
y += sign(vsp);
}
vsp = 0;
ground = true;
djump=true;
}
y+=vsp;
// animation inputs
if key_left
{
image_xscale=-1;
}
if key_right
{
image_xscale =1;
}
if inair= true
{
walk=false;
ground=false;
run=false;
}
// animation
if ground=true&&idle=true
{
sprite_index=sp_tal_stand;
image_speed=.5;
}
///jump up animation
if
vsp < 0
{
inair=true;
sprite_index=sp_tal_jump;
image_speed=1;
}
///falling animation
if
vsp > 0
{
inair=true;
sprite_index=sp_tal_fall;
image_speed=1;
{
alarm[2]=rsp*2;}
}
// WALL/RUN ANIMATIONS
if
(key_right)&& (inair=false)
{
if run =true
{
sprite_index=sp_taleep_run;
image_speed=1;
}
else
if walk =true
{
sprite_index=sp_taleep_walk;
image_speed=1;
}
}
if
(key_left)&&(inair=false)
{
if run =true
{
sprite_index=sp_taleep_run;
image_speed=1;
}
else
{
if walk =true
sprite_index=sp_taleep_walk;
image_speed=1;
}
}