• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Legacy GM [RESOLVED] HUD glitch...text shifts upwards when I load saved game.

pixeltroid

Member
So I have a working HUD that displays my health and remaining ammo and keys.
Here's a screenshot of what it looks like:

hud good.jpg

This works fine and does what it's supposed to do.

HOWEVER, when I load a saved game from the main menu,,, the text shifts upwards by a few pixels, as seen in this screenshot:

hudbad.jpg

As you can see, the text and numbers have shifted up by a few pixels. Does anybody know what is causing this glitch?

Here are my codes. Can someone please look into this and tell me what I can do to resolve this problem?

for obj_hud (that controls the dispay of hud)

//draw healthbar

draw_sprite_ext(spr_health_fill, 1 ,view_xview[0] + 14, view_yview[0] + 15, obj_player.health/100,1,0, c_white, 1);
draw_sprite(spr_health_border, 1 , view_xview[0] + 14, view_yview[0] + 15)

///draw fps
draw_set_halign(fa_left);
draw_set_color(c_red);
draw_set_font(fnt_small);
draw_text(view_xview[0]+160, view_yview[0]+15,fps);

///draw bombs
draw_sprite(spr_HUDbomb, 1 , view_xview[0] + 15, view_yview[0] + 30)

draw_set_halign(fa_left);
draw_set_color(c_black);
draw_set_font(fnt_small);
draw_text(view_xview[0] + 31, view_yview[0] + 29, + string(global.bombs));

draw_set_halign(fa_left);
draw_set_color(c_white);
draw_set_font(fnt_small);
draw_text(view_xview[0] + 32, view_yview[0] + 30, + string(global.bombs));

///draw shot
draw_sprite(spr_HUDshot, 1 , view_xview[0] + 15, view_yview[0] + 42)

draw_set_halign(fa_left);
draw_set_color(c_black);
draw_set_font(fnt_small);
draw_text(view_xview[0] + 31, view_yview[0] + 41, + string(global.shot));

draw_set_halign(fa_left);
draw_set_color(c_white);
draw_set_font(fnt_small);
draw_text(view_xview[0] + 32, view_yview[0] + 42, + string(global.shot));

///draw flames
draw_sprite(spr_HUDflame, 1 , view_xview[0] + 15, view_yview[0] + 54)

draw_set_halign(fa_left);
draw_set_color(c_black);
draw_set_font(fnt_small);
draw_text(view_xview[0] + 31, view_yview[0] + 53, + string(global.flame));

draw_set_halign(fa_left);
draw_set_color(c_white);
draw_set_font(fnt_small);
draw_text(view_xview[0] + 32, view_yview[0] + 54, + string(global.flame));

///draw keys
draw_sprite(spr_HUDkey, 1 , view_xview[0] + 15, view_yview[0] + 66)

draw_set_halign(fa_left);
draw_set_color(c_black);
draw_set_font(fnt_small);
draw_text(view_xview[0] + 31, view_yview[0] + 65, + string(global.keys));

draw_set_halign(fa_left);
draw_set_color(c_red);
draw_set_font(fnt_small);
draw_text(view_xview[0] + 32, view_yview[0] + 66, + string(global.keys));
script "scr_savegame" that saves game

with (argument0){
ini_open("save.ini");
roomAlias = "1A" //default room
if (room=room1A) roomAlias = "1A"
if (room=room1B) roomAlias = "1B"
if (room=room2A) roomAlias = "2A" //and so on
//ini_write_real("SaveFile1", "LoadedRoom",roomAlias);
ini_write_string("SaveFile1", "LoadedRoom",roomAlias);//save it as ini file

ini_write_real("SaveFile1", "playerx",x);
ini_write_real("SaveFile1", "playery",y);

ini_write_real("SaveFile1", "lock_killed1",global.lock_killed[1]);


ini_write_real("SaveFile1", "keyboss_killed1",global.keyboss_killed[1]);


ini_write_real("SaveFile1", "door_opened0",global.door_opened[0]);


ini_write_real("SaveFile1", "keys",global.keys);
ini_close();
}
script "scr_loadgame" that loads game:

if file_exists("save.ini")
{
ini_open("save.ini");
LoadedRoom=room1A; //default room
roomAlias=ini_read_string("SaveFile1", "LoadedRoom", "1A");
if (roomAlias=="1A") LoadedRoom = room1A
if (roomAlias=="1B") LoadedRoom = room1B

playerx=ini_read_real("SaveFile1", "playerx", 10);
playery=ini_read_real("SaveFile1", "playery", 10);
global.lock_killed[1] = ini_read_real("SaveFile1", "lock_killed1", 0);

global.keyboss_killed[1] = ini_read_real("SaveFile1", "keyboss_killed1", 0);

global.door_opened[0] = ini_read_real("SaveFile1", "door_opened0", 0);

global.keys=ini_read_real("SaveFile1", "keys", 0);

ini_close();
instance_create(playerx, playery-200, obj_player);

room_goto(LoadedRoom);
}
else
{
//do nothing
}
I dont know what is causing this. Is it an issue with the code in the object that controls the HUD, or the script that loads the game?

Can someone please help me with this? Thanks!
 
M

maratae

Guest
So I have a working HUD that displays my health and remaining ammo and keys.
Here's a screenshot of what it looks like:

View attachment 15146

This works fine and does what it's supposed to do.

HOWEVER, when I load a saved game from the main menu,,, the text shifts upwards by a few pixels, as seen in this screenshot:

View attachment 15147

As you can see, the text and numbers have shifted up by a few pixels. Does anybody know what is causing this glitch?

Here are my codes. Can someone please look into this and tell me what I can do to resolve this problem?

for obj_hud (that controls the dispay of hud)



script "scr_savegame" that saves game



script "scr_loadgame" that loads game:



I dont know what is causing this. Is it an issue with the code in the object that controls the HUD, or the script that loads the game?

Can someone please help me with this? Thanks!
Because something's reseting your draw_set_valign(fa_middle)
By the way, you have a bit of redundancy going on in your code. You don't have to pick fonts and set alignments every draw_text
 

pixeltroid

Member
Because something's reseting your draw_set_valign(fa_middle)
By the way, you have a bit of redundancy going on in your code. You don't have to pick fonts and set alignments every draw_text
hey, "draw_set_valign(fa_middle)" was missing in my code. I just added it after "draw_set_halign(fa_left)"....and the glitch is gone!

thanks!
 
Top