Multistage Boss fight platformer

clothears

Member
Hi,

how would i make a boss fight have multiple stages? I want to make it so when it reaches half hp it changes its sprite but so far i have had no luck.

The code i have is

obj_bossattack

x = owner.x;
y = owner.y+30;
//location of gun when assigned to sprite



if (instance_exists(obj_player))
{
if (obj_player.x <x) image_yscale = - image_yscale;
if (point_distance(obj_player.x,obj_player.y,x,y) <600)
{

image_angle = point_direction(x,y,obj_player.x,obj_player.y);
countdown --;

if (countdown <=0)
{
countdown = countdownrate;
with (instance_create_layer(x,y,"bullet",obj_bossattack))
speed = 10; //speed bullet travels
audio_play_sound(snd_boss_attack,5,false);
obj_bossattack.direction = image_angle + random_range(-3,3)
if (global.bosshp <=15)
{
image_index = 0;
}
else
{
image_index = 1;
}

}
}
}



I'm not very experienced in coding and this is my first time trying to do this so any help would be great :)
 

samspade

Member
Two basic ways. The first would be to use state machines and have different states, or groups of states. The second would be to change objects. So at half health it would destroy itself and create the next phase. And you could either store the health variable outside of the boss or pass the health into the next boss object just as you're doing with obj_bossattack.

Where is this code located?
 

clothears

Member
Two basic ways. The first would be to use state machines and have different states, or groups of states. The second would be to change objects. So at half health it would destroy itself and create the next phase. And you could either store the health variable outside of the boss or pass the health into the next boss object just as you're doing with obj_bossattack.

Where is this code located?
in the obj_bossattack
 

samspade

Member
in the obj_bossattack
Maybe a better question would have been what is obj_bossattack? What is its owner? This line of code makes it seems like its a bullet: with (instance_create_layer(x,y,"bullet",obj_bossattack))

Where is the bosses health in this object?
 

clothears

Member
Maybe a better question would have been what is obj_bossattack? What is its owner? This line of code makes it seems like its a bullet: with (instance_create_layer(x,y,"bullet",obj_bossattack))

Where is the bosses health in this object?
The boss's health is in obj_boss the obj_bossattack is the bullet
 

samspade

Member
Is there a specific thing you are looking for help for in the bullet? Otherwise, it would be more helpful to see the boss's code.
 
Top