[Resolved] Simple HUD Request

Started by SwiftDeathSK, February 27, 2010, 08:41:47 am

Previous topic - Next topic

SwiftDeathSK

February 27, 2010, 08:41:47 am Last Edit: February 27, 2010, 09:16:31 pm by Bug Catcher Swift
Alright, I know enough Ruby to be able to understand a script, to a certain degree, but not quite yet enough to develop my own script. I'm planning on using a simple HUD in my current project, nothing fancy, but I don't know where to begin. So, if someone could write a tutorial on how to make a simple HUD for your game, preferably with RGSS (RMXP), it would be greatly appreciated. As mentioned, nothing too complicated.



Tazero

Look at tons -- it's a skeleton I guess =D


If you were a fish...

winkio

I don't know if this is too advanced or not, but here goes:

Your HUD can be contained within a single class, and it is usually best to do so, unless you want an HUD with different components that can be toggled in game.  The class should inherit from Sprite in order to be able to display graphics objects.

In this HUD class, you will obviously need a constructor, to set its position on screen and set the positions to draw each item on the HUD (like health bars, etc.).  You will also need to make fields to hold the current state of the information to be displayed, such as player health, etc. 

Then, the main thing that the HUD will need is the update method.  In this method, you need to see if the information on any of the displays has changed (using those fields from the constructor).  For each field that has changed, you will need to update and redraw that specific display, as well as storing this new state in the fields to keep track of it.  It is advisable to have a separate redraw method for each display.

At this point, you have an HUD class that is able to update once a frame and display information as it changes.  The only step left is to create an instance of the HUD in the Scene_Map class, and update it continuously from Scene_Map's update. 

If you want to toggle it on and off, you could create a boolean flag in Game_System which would be accessible at any time.

SwiftDeathSK

Quote from: Arceus on February 27, 2010, 07:17:02 pm
I don't know if this is too advanced or not, but here goes:

Your HUD can be contained within a single class, and it is usually best to do so, unless you want an HUD with different components that can be toggled in game.  The class should inherit from Sprite in order to be able to display graphics objects.

In this HUD class, you will obviously need a constructor, to set its position on screen and set the positions to draw each item on the HUD (like health bars, etc.).  You will also need to make fields to hold the current state of the information to be displayed, such as player health, etc. 

Then, the main thing that the HUD will need is the update method.  In this method, you need to see if the information on any of the displays has changed (using those fields from the constructor).  For each field that has changed, you will need to update and redraw that specific display, as well as storing this new state in the fields to keep track of it.  It is advisable to have a separate redraw method for each display.

At this point, you have an HUD class that is able to update once a frame and display information as it changes.  The only step left is to create an instance of the HUD in the Scene_Map class, and update it continuously from Scene_Map's update. 

If you want to toggle it on and off, you could create a boolean flag in Game_System which would be accessible at any time.


thanks, i understand that for the most part. I used to do some simple scripting before, editing other's scripts to fit my own needs and stuff, so I think with that explaination, I should be able to get some of it figured out.


just one thing: I've heard of the term constructor, but I cannot think of what it means off the top of my head. Mind giving an example? Of course, I guess I could always google it :)

everything else I should be able to figure out, with some simple backwards engineering of other huds and what you've mentioned above.

winkio

the constructor is the method that gets called when you make a new object.  In RGSS, if I remember right, it is called initialize.  it's basically supposed to setup the object and give default values to all its variables.

SwiftDeathSK

okay, thanks :) i'm changing this to resolved, hopefully I won't need to ask any further questions over this :)