Author Topic: [Resolved] Simple HUD Request  (Read 1874 times)

Offline SwiftDeathSK

  • Awakened Visionist
  • **
  • Posts: 53
  • LV: 3
  • Gender: Male
  • Stuffs cotton into asprin bottles in spare time.
    • View Profile
[Resolved] Simple HUD Request
« on: February 27, 2010, 03:41:47 PM »
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.


« Last Edit: February 28, 2010, 04:16:31 AM by Bug Catcher Swift »

Offline Tazero

  • Blows jobs for custom titles
  • Chaos User
  • ******
  • Posts: 1180
  • LV: -45
  • Gender: Male
  • Asleep but flying high
    • View Profile
Re: Simple HUD Request
« Reply #1 on: February 28, 2010, 01:25:15 AM »
Look at tons -- it's a skeleton I guess =D


If you were a fish...

Offline winkio

  • Epiq
  • Administrator
  • Guardian of Chaos
  • *****
  • Posts: 4505
  • LV: 199
  • Gender: Male
  • I am lying.
    • View Profile
Re: Simple HUD Request
« Reply #2 on: February 28, 2010, 02:17:02 AM »
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.

Offline SwiftDeathSK

  • Awakened Visionist
  • **
  • Posts: 53
  • LV: 3
  • Gender: Male
  • Stuffs cotton into asprin bottles in spare time.
    • View Profile
Re: Simple HUD Request
« Reply #3 on: February 28, 2010, 02:57:21 AM »
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.

Offline winkio

  • Epiq
  • Administrator
  • Guardian of Chaos
  • *****
  • Posts: 4505
  • LV: 199
  • Gender: Male
  • I am lying.
    • View Profile
Re: Simple HUD Request
« Reply #4 on: February 28, 2010, 03:27:54 AM »
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.

Offline SwiftDeathSK

  • Awakened Visionist
  • **
  • Posts: 53
  • LV: 3
  • Gender: Male
  • Stuffs cotton into asprin bottles in spare time.
    • View Profile
Re: Simple HUD Request
« Reply #5 on: February 28, 2010, 04:16:20 AM »
okay, thanks :) i'm changing this to resolved, hopefully I won't need to ask any further questions over this :)