• Hey! Guest! The 37th GMC Jam will take place between May 28th, 12:00 UTC and June 1st, 12:00 UTC. Why not join in! Click here to find out more!

Legacy GM [solved]loosing too many lives

woods

Member
so i have an issue with loosing too many lives when my player gets shot down

on the third hit from an enemy i have my player shot down

in player create i have hits = 3
and each hit from an enemy adds some effect.. things like bullet holes on the side for the first hit, a wind spiral that follows the player on the second hit, and smoke following player and forced landing on the third...



obj_player step event dealing with damage on third hit
Code:
if place_meeting(x,y+32,obj_ground)
    {
    crashing = true;
    instance_create(obj_player.x,obj_player.y,obj_player_hit);
    speed = 0;
    }
}
animation end event of obj_player_hit

Code:
/// move player to start

with obj_player
{
x = 160;
y = 624;
hits = 0;
_1ups -= 1;
crashing = false;
speed = 8;
direction = 0;
gravity = 0.05;
}

the issue i am having is the player looses all of the _1ups and goes to game end on the first crash.


here is the full player take damage script if that helps...
Code:
/// take damage



if place_meeting(x,y,obj_bullet_enemy)
{
hits ++;
with other
    {
    instance_destroy(obj_bullet_enemy);
    }
}

// if shot 1st time change sprite to player_shot
if hits = 1
{
sprite_index = spr_player_shot;
}

// if shot 2nd time add obj_spiral
if hits = 2
{
    if !instance_exists(obj_spiral)
    {
    instance_create(x,y,obj_spiral);
    }
}

// if shot 3rd time reset player
if hits = 3
{
    if !instance_exists(obj_smoke)
    {
    instance_create(x,y,obj_smoke);
    }
instance_destroy(obj_spiral);

direction = 340;
image_angle = 340;
speed = 2;
if place_meeting(x,y+32,obj_ground)
    {
    crashing = true;
    instance_create(obj_player.x,obj_player.y,obj_player_hit);
    speed = 0;
    }
}

if hits >= 3
{
hits = 3;
}


edit:

i fixed the issue with using image_index in the splat step event instead of the animation end..

tho for some reason using image 10 doesnt work... i hoockyfied it into working with 8th image instead.. no idea why.. maybe it takes time to complete teh code and image overruns or something.. regardless the situation is basically resolved. ;o)

step event of obj_player_hit

Code:
/// move player to start
if image_index >= 8
{
instance_destroy();

with obj_player
    {
    hits = 0;
    spr_index = spr_player;
    direction = 0;
    image_angle = 0;
    speed = 6;
    gravity = 0.05;
    x = 160;
    y = 624;
    crashing = false;
    _1ups -= 1;
    }
}
 
Last edited:
Top