///player script
// player output.................................................
if !stop
KyR = keyboard_check_direct(vk_right);
KyL = -keyboard_check_direct(vk_left);
KyJ = keyboard_check_pressed(vk_up);
KyU = keyboard_check_direct(vk_up);
KyD = keyboard_check_direct(vk_down);
// react inputs..................................................
if !stop
move = KyL + KyR;
if !stop
hsp = move * msp;
if !stop
if (vsp < 10) vsp += grav;
if !stop
if (checkCollision(x,y+1))
{
vsp = KyJ * -jsp
}
//push animation................................................
if !stop
if (checkCollision(x+hsp,y,obj_box))
{
sprite_index = any_push;
}
// push............................................................ooo__________________________________________-
if !stop + !ladder
with (instance_place(x+image_xscale, y, obj_box))
{
// x += other.hsp; or image_xscale = move;
x +=other.hsp;
}
// horizontal...................................................
if !stop
if (checkCollision(x+hsp,y))
{
while(!checkCollision(x+sign(hsp),y))
{
x += sign(hsp);
}
hsp = 0;
}
x += hsp;
// vertical...................................................
if !stop
if (checkCollision(x,y+vsp))
{
while(!checkCollision(x,y+sign(vsp)))
{
y += sign(vsp);
}
vsp = 0;
}
y += vsp;
//.....................................................................
// animate......................................................
if !(ladder)
{
if !stop
if (move!=0) image_xscale = move;
image_speed = 0.5;
if (checkCollision(x,y+1))
{
if (move!=0) sprite_index = any_run; else sprite_index = any_stand;
}
else
{
if (vsp < 0) sprite_index = any_jump; else sprite_index = any_fall;
}
}
//push animation...................................................................................
// bounce spring................................................
var inst = instance_place(x, y, obj_spring);
if (inst != noone)
{
if (inst.y > y+16)
{
vsp = -jps;
}
}
//exit...........................................................
if stop = true
{
sprite_index = any_stand
vsp = 0
hsp = 0
}
//death..........................................................
if !deathless
if (place_meeting(x,y,obj_death_par))
{
deathless = true;
alarm[0] = 80;
lives-=3;
audio_play_sound(sou_hurt,1,0);
}
//deathless........................................................
if deathless = true
{
image_alpha = 0.5;
}
else
{
image_alpha = 1;
}
//hit by or bounce on enemy.................................................................
if !deathless
if instance_place(x,y,obj_enemy_par)
{
if (obj_enemy_par.y > y+16)
{
obj_enemy_par.HP-=1;
vsp = -jsp;
audio_play_sound(sou_enemyhit,1,0);
}
else
{
hsp = -image_xscale*1;
vsp = -3;
deathless = true
alarm[0] = 80;
lives-=1;
audio_play_sound(sou_hurt,1,0);
}
}
//hit by invincenemy.................................................................
if !deathless
if instance_place(x,y,obj_bullet_par)
{
hsp = -image_xscale*1;
vsp = -3;
deathless = true
alarm[0] = 80;
lives-=1;
audio_play_sound(sou_hurt,1,0);
}
// convayor.......................................................
if !stop
if (place_meeting(x,y+1,obj_convayor_platform))
{
if (other.image_blend == c_red)
{x-=1.5}
else
{x+=1.5}
}
//Ladder.....................................................................................
if (KyU || KyD)
{
if place_meeting(x,y,par_ladder) ladder = true;
}
if (ladder)
{
vsp = 0;
grav = 0;
if (KyU) vsp = -2 ;
if (KyD) vsp = 2 ;
if !place_meeting(x,y,par_ladder)
ladder = false;
}
if !(ladder)
grav = 0.3;
//ladder animation............................................................
if (ladder)
{
sprite_index = any_climb;
image_speed = 0;
if (KyU) image_speed = 0.2;
if (KyD) image_speed = 0.2;
}
//stuck death............................................................
if place_meeting(x,y, obj_platform_red)
{
deathless = true;
alarm[0] = 80;
lives-=3;
audio_play_sound(sou_hurt,1,0);
}
if place_meeting(x,y, obj_platform_cyan)
{
deathless = true;
alarm[0] = 80;
lives-=3;
audio_play_sound(sou_hurt,1,0);
}
//.........................................................................................