Axl Trauts
Member
Hi,
I want to alter speed of my player when entering difficult terrain, and return to normal (zero) when getting out of it. I am trying a collision check like instance_place but only works if I the player collides but not when gets out of the collision.
Below if the code that works. I've tried on the script a check if the collision give noone: "if i=noone" or just "else" then " global.var_player_spdmod=0 " and works, but overrides the condition "if i !=noone"
OBJ_PLAYER STEP EVENT (Requires a bit of improvement)
spdmod is a local variable that stores the global speed modifier value
OBJ MUD STEP EVENT
SCRIPT scr_CheckSpeedMod
I want to alter speed of my player when entering difficult terrain, and return to normal (zero) when getting out of it. I am trying a collision check like instance_place but only works if I the player collides but not when gets out of the collision.
Below if the code that works. I've tried on the script a check if the collision give noone: "if i=noone" or just "else" then " global.var_player_spdmod=0 " and works, but overrides the condition "if i !=noone"
OBJ_PLAYER STEP EVENT (Requires a bit of improvement)
spdmod is a local variable that stores the global speed modifier value
Code:
spdmod = global.var_player_spdmod;
var hspd = 0; var vspd = 0;
if y > __view_get( e__VW.YView, 0 )+40
{ vspd = -2; } // autonomous vertical scroll movement
if __view_get( e__VW.YView, 0 ) == 0
{ vspd = 0; }
if keyboard_check(vk_left) and dead=0 { if x>40 then hspd -= (6+spdmod); }
if keyboard_check(vk_right) and dead=0 { if x<room_width -40 then hspd += (6+spdmod); }
if keyboard_check(vk_up) and dead=0 { if y> __view_get( e__VW.YView, 0 )+40 then vspd -= (6+spdmod); }
if keyboard_check(vk_down) and dead=0 { if y<__view_get( e__VW.YView, 0 )+640 then vspd += (6+spdmod); }
x += hspd; y += vspd;
Code:
scr_CheckSpeedMod(-4); // To be used on other terrain with movement alteration
Code:
modifier = argument0;
//global.var_player_spdmod=0;
i=instance_place(x,y,obj_player_p1)
if i != noone
{ global.var_player_spdmod=modifier; }
[/CODE[