• 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!

Custom HUD Help

NovaOzuka

Member
Right, so I need help coding my HUD for the game I'm working on, which needs to contain 5 things:
Health
Energy/Magic/Ammo
Lives
Currency
Time

FIrstly, I have no idea of what I'm doing, but I do know what I have in mind for each. For Health, I want upgradable Zelda style health. I'm using cupcakes to measure the player's health where each cupcake is equal to 2 points of health, and I want the starting max health to be 4. I already have the sprites made for full, half, and empty cupcakes. The custom meter that I would put below it can just be something generic. Lives can probably be done with the Draw Event. Currency is pretty obvious and can be generic. The timer would be to time the player's run of the level.

If someone can walk me through making this major portion of my game's engine, that would be a big help, as I could get to coding other portions of the game like special actions, enemies, and shops.
 

2Dcube

Member
If someone can walk me through making this major portion of my game's engine
Do you have a specific question or problem, or do you just want someone to make part of your game?

For drawing a HUD I recommend looking up the Draw GUI event. It allows you to draw your HUD regardless of the view zoom, so you can always later allow the player to zoom in/out.
Drawing in the Draw GUI event also starts at 0,0 (top-left of the screen) which is easier so you don't have to take the view's position into account.
 

NovaOzuka

Member
Do you have a specific question or problem, or do you just want someone to make part of your game?
Like I said, I have no idea what I'm doing. I specifically said that problem right after listing what I need my HUD to contain. If I wanted someone to just make it for me, I would've just said so, and if I had any idea what I was doing, I'd probably already have a code that just isn't working the way I want. For now I need to get some idea of how to do what I'm wanting to do. Then when I have issues like I did with my wall jump code, where I already had an idea what I was doing, I can actually say something instead of staring at the screen for hours, taking a break, and coming back later only to still get nowhere. For example, I know how to make a timer in code. I just need to know how to display one in the HUD, but it isn't as relevant as the Zelda style health bar and the custom meter as I need them to code the enemies and finish coding the player, and finding out how many steps are in a second is something I can probably do on my own.
 

Neptune

Member
So you understand storing data in variables.
I think you just need to mess around with "drawing" functions, such as draw_text(x,y,string);

Do your drawing code in a 'draw event'
Code:
draw_text(camera_x+20,camera_y+20,string(health));
Your room_speed is how many steps are in a second.

You can also draw sprites in the draw event, using other drawing functions like 'draw_sprite(sprite_index,image_index,x,y)'
 

NovaOzuka

Member
So you understand storing data in variables.
I think you just need to mess around with "drawing" functions, such as draw_text(x,y,string);

Do your drawing code in a 'draw event'
Code:
draw_text(camera_x+20,camera_y+20,string(health));
Your room_speed is how many steps are in a second.

You can also draw sprites in the draw event, using other drawing functions like 'draw_sprite(sprite_index,image_index,x,y)'
Okay, with these, I can finally draw lives, time, $, and health, but I really need a way to code the custom meter without having to add like 200 lines for it. Like maybe have a bar as a sprite and it scales horizontally to the variable it represents.
 

Neptune

Member
There are built in functions for "healthbars", such as draw_healthbar, and you can draw some border around it with a sprite.
But if you want an actual custom / fancy bar, I'd suggest 'surfaces'.

Draw_sprite_part_ext would probably also be useful, but as I said, I've always used surfaces for bars and such.
 

NovaOzuka

Member
Using the built in Health Bar as a secondary meter seems to work after playing with it a little. My Zelda style health seems to work too. Even looked at the types of variables and ended up making the variable maxhealth global and put it somewhere else so the HUD event wouldn't keep overwriting it.
 
Top