P
Pedau666
Guest
I'm trying to scale the interface like in the code of score, where text is scaled when window changes its resolution. I have a example code where this works but I can't make this in the health system where are sprites.
Can you guys help?
Here is the good code of the draw event from the score:
And here is draw gui event from health object which causes health to move on the screen when player is moving and doesn't scale at all.
Can you guys help?
Here is the good code of the draw event from the score:
Code:
draw_set_color(c_white);
draw_set_font(fnt_start);
draw_set_halign(fa_center);
draw_text(camera_get_view_x(view_camera[0]) + (camera_get_view_width(view_camera[0]) * 0.91),
camera_get_view_y(view_camera[0]) + (camera_get_view_height(view_camera[0]) * 0.04), global.points);
draw_set_font(fnt_start2);
draw_set_color(c_silver);
draw_text(camera_get_view_x(view_camera[0]) + (camera_get_view_width(view_camera[0]) * 0.95),
camera_get_view_y(view_camera[0]) + (camera_get_view_height(view_camera[0]) * 0.11), global.coins);
draw_set_color(c_yellow);
draw_text(camera_get_view_x(view_camera[0]) + (camera_get_view_width(view_camera[0]) * 0.85),
camera_get_view_y(view_camera[0]) + (camera_get_view_height(view_camera[0]) * 0.11), global.gold);
draw_set_color(c_white);
Code:
var zwidth = camera_get_view_x(view_camera[0]) ;
var zxx = zwidth;
var zyy = 35;
var zxempty = 0
var zyempty = 0
var zxfull = 0
var zyfull = 0
var zxhalf = 0
var zyhalf = 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 zxempty == 65 * 10
{
zyempty = 65
zxempty = 0
}
draw_sprite(s_heart_empty, 0, zxx + zxempty, zyy + zyempty)
zxempty += 65;
}
//half
repeat(floor(o_player.hp/2) + frac(o_player.hp/2) * 2)
{
if zxhalf >= 65 * 10
{
zyhalf = 65
zxhalf = 0
}
draw_sprite(s_heart_half, 0, zxx + zxhalf, zyy + zyhalf)
zxhalf += 65;
}
//full
repeat(floor(o_player.hp/2))
{
if zxfull >= 65 * 10
{
zyfull = 65
zxfull = 0
}
draw_sprite(s_heart_full, 0, zxx + zxfull, zyy + zyfull)
zxfull += 65;
}
if o_player.hp = 0 instance_destroy();