P
Pedau666
Guest
I made a health system like in Zelda, where player have hearts that have two parts. After implementing this code I constantly get a crash after player gets to 0 health. Here is the code, can you guys help?
PLAYER BEGIN STEP EVENT
HEALTH DRAW GUI EVENT
PLAYER BEGIN STEP EVENT
if (o_player.hp <= 0)
{
instance_destroy();
}
HEALTH DRAW GUI EVENT
///draw heaarth
var width = (display_get_gui_width()) - (display_get_gui_width()/1.65)
var xx = width - 70 * 10
var yy = 35
var xempty = 0
var yempty = 0
var xfull = 0
var yfull = 0
var xhalf = 0
var yhalf = 0
o_player.maxhp = clamp(o_player.maxhp, 6, 40)
o_player.hp = clamp(o_player.hp, 0, o_player.maxhp)
//empty
repeat(o_player.maxhp/2)
{
if xempty == 65 * 10
{
yempty = 65
xempty = 0
}
draw_sprite(s_heart_empty, 0, xx + xempty, yy + yempty)
xempty += 65;
}
//half
repeat(floor(o_player.hp/2) + frac(o_player.hp/2) * 2)
{
if xhalf >= 65 * 10
{
yhalf = 65
xhalf = 0
}
draw_sprite(s_heart_half, 0, xx + xhalf, yy + yhalf)
xhalf += 65;
}
//full
repeat(floor(o_player.hp/2))
{
if xfull >= 65 * 10
{
yfull = 65
xfull = 0
}
draw_sprite(s_heart_full, 0, xx + xfull, yy + yfull)
xfull += 65;
}