W
Wafi Hussain
Guest
Hello! I am using the code from a skeleton hack n slash game on YouTube as a source and I am trying to figure out how to make the character go up.
Here is the code given:
switch(state)
{
case "move":
#region Move State
if input.up
{
move_and_collide(run_speed, 0);
image_xscale = 2;
sprite_index = s_noir_run;
image_speed = 0.6;
}
if input.down
{
move_and_collide(-run_speed, 0);
image_xscale = -2;
sprite_index = s_noir_run;
image_speed = 0.6;
}
if input.right
{
move_and_collide(run_speed, 0);
image_xscale = 2;
sprite_index = s_noir_run;
image_speed = 0.6;
}
if input.left
{
move_and_collide(-run_speed, 0);
image_xscale = -2;
sprite_index = s_noir_run;
image_speed = 0.6;
}
if !input.left and !input.right and !input.up and !input.down
{
sprite_index = s_noir_idle;
image_speed = 0.6;
}
if input.roll
{
state = "roll";
}
if input.attack
{
state = "attack one";
}
#endregion
break;
case "roll":
#region Rolling
state_set_sprite(s_noir_roll, 0.7, 0);
if image_xscale == 2
{
move_and_collide(roll_speed, 0);
}
if image_xscale == -2
{
move_and_collide(-roll_speed, 0);
}
if animation_end()
{
state = "move";
}
#endregion
break;
case "attack one":
#region Attack One
state_set_sprite(s_noir_attack_one, 0.7, 0);
/*if animation_hit_frame(0)
{
create_hitbox(x, y, self, s_noir_attack_one_damage, 3, 4, 5, image_xscale);
}*/
if input.attack and animation_hit_frame_range(2, 4)
{
state = "attack two";
}
if animation_end()
{
state = "move";
}
#endregion
break;
Once I hit up and down, the character still moves right and left. What to do?
Thanks!
Here is the code given:
switch(state)
{
case "move":
#region Move State
if input.up
{
move_and_collide(run_speed, 0);
image_xscale = 2;
sprite_index = s_noir_run;
image_speed = 0.6;
}
if input.down
{
move_and_collide(-run_speed, 0);
image_xscale = -2;
sprite_index = s_noir_run;
image_speed = 0.6;
}
if input.right
{
move_and_collide(run_speed, 0);
image_xscale = 2;
sprite_index = s_noir_run;
image_speed = 0.6;
}
if input.left
{
move_and_collide(-run_speed, 0);
image_xscale = -2;
sprite_index = s_noir_run;
image_speed = 0.6;
}
if !input.left and !input.right and !input.up and !input.down
{
sprite_index = s_noir_idle;
image_speed = 0.6;
}
if input.roll
{
state = "roll";
}
if input.attack
{
state = "attack one";
}
#endregion
break;
case "roll":
#region Rolling
state_set_sprite(s_noir_roll, 0.7, 0);
if image_xscale == 2
{
move_and_collide(roll_speed, 0);
}
if image_xscale == -2
{
move_and_collide(-roll_speed, 0);
}
if animation_end()
{
state = "move";
}
#endregion
break;
case "attack one":
#region Attack One
state_set_sprite(s_noir_attack_one, 0.7, 0);
/*if animation_hit_frame(0)
{
create_hitbox(x, y, self, s_noir_attack_one_damage, 3, 4, 5, image_xscale);
}*/
if input.attack and animation_hit_frame_range(2, 4)
{
state = "attack two";
}
if animation_end()
{
state = "move";
}
#endregion
break;
Once I hit up and down, the character still moves right and left. What to do?
Thanks!