Legacy GM "Box" HP problem

B

biscoitoMaizena

Guest
hey there. I've make a little project just to learn what I can do by myself, but I'm now with a problem: I've a box that's supposed to destroy after 6 attacks (box hp = 6), but just one actually is destroying this box. I can't explain exactly what did I do, I think that's something related to my player hitbox, so I going to share the .gmz:
here

and the controls in game: arrows and "z"
 
B

biscoitoMaizena

Guest
on z is pressed, the player attack
Code:
/// hero controller

if(keyboard_check(vk_down)){
    moving=true;
    y += hspd;
    dir = 0;
}

if(keyboard_check(vk_up)){
    moving=true;
    y -= hspd;
    dir = 2;
}

if(keyboard_check(vk_right)){
    moving=true;
    x += hspd;
    dir = 3;
}
if(keyboard_check(vk_left)){
    moving=true;
    x -= hspd;
    dir = 1;
}

if(!keyboard_check_pressed(vk_up) && !keyboard_check(vk_down) && !keyboard_check(vk_left) && !keyboard_check(vk_right)){
    moving=false;
}

if(keyboard_check(ord('Z'))){
    attacking=true;
}

// sprites

if(dir==0) && !moving && !attacking{
    sprite_index=spr_hero_idle_down
} else if(dir==0 && moving && !attacking){
    sprite_index=spr_hero_walking_down
}

if(dir==2) && !moving && !attacking{
    sprite_index=spr_hero_idle_up
} else if(dir==2 && moving && !attacking){
    sprite_index=spr_hero_walking_up
}

if(dir==3) && !moving && !attacking{
    sprite_index=spr_hero_idle_right
} else if(dir==3 && moving && !attacking){
    sprite_index=spr_hero_walking_right
}
if(dir==1) && !moving && !attacking{
    sprite_index=spr_hero_idle_left
} else if(dir==1 && moving && !attacking){
    sprite_index=spr_hero_walking_left
}

if(attacking){
    if(dir==0){
    sprite_index=spr_hero_attacking_down
    image_speed=0.5
    } else if(dir==1)
    {
    sprite_index=spr_hero_attacking_left
    image_speed=0.5
   
    } else if(dir==2)
    {
    sprite_index=spr_hero_attacking_up
    image_speed=0.5
   
    } else if(dir==3)
    {
    sprite_index=spr_hero_attacking_right
    image_speed=0.5
   
    }
}

at the attack animation end, makes the Hitbox (obj_attack_UD or obj_attack_LR)
Code:
if(sprite_index=spr_hero_attacking_down){
    attacking=false;
    image_speed=0.2
    instance_create(x,y+15,obj_attack_UD);
}
if(sprite_index=spr_hero_attacking_right){
    attacking=false;
    image_speed=0.2
    instance_create(x+15,y,obj_attack_LR);
}
if(sprite_index=spr_hero_attacking_left){
    attacking=false;
    image_speed=0.2
    instance_create(x-15,y,obj_attack_LR);
}
if(sprite_index=spr_hero_attacking_up){
    attacking=false;
    image_speed=0.2
    instance_create(x,y-15,obj_attack_UD);
}

and the hitbox destroy after been created
Code:
instance_destroy();
 
B

biscoitoMaizena

Guest
on the post_draw.
I realized that this problem only exists when I put the hitbox obj as invisible. So I've changed the sprite to "none" with the dimensions of the hitbox and that fixed the problem for now
 
Top