Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
(Stupid) HUD
#1
(Stupid) HUD
by Jarelk
Jun 2 2008

This is a locked, single-post thread from Creation Asylum. Archived here to prevent its loss.
No support is given. If you are the owner of the thread, please contact administration.


So... Yeah, I'm trying to learn how to script. I've made a small HUD using the information from DubeAlex Scripting Tutorials 1 and 2. It works fine and stuff, but because the tutorials don't really learn you anything out of the boundaries, I've decided to try to learn as much as I can by listening to the pros.

So, here is my HUD:
Code:
class My_Window < Window_Base

  def initialize
   super(0, 0, 130, 100)
    self.contents = Bitmap.new(width-32, height-32)
    self.contents.font.name = "Tahoma"  
    self.contents.font.size = 16
    refresh
  end

  def refresh
    self.contents.clear
    @total_sec = Graphics.frame_count / Graphics.frame_rate
    actor=$game_party.actors[0]
    self.contents.font.color = text_color(6)
    self.contents.draw_text(0, 0, 100, 16, actor.name)
    self.contents.font.color = text_color(4)
    self.contents.draw_text(contents.text_size(actor.name).width+10, 0, 50, 32, "Lv: " + actor.level.to_s)
    self.contents.font.color = text_color(2)
    self.contents.draw_text(0, 19, 200, 18, "HP: " + actor.hp.to_s + "/" + actor.maxhp.to_s)
    self.contents.font.color = text_color(1)
    self.contents.draw_text(0, 35, 200, 18, "SP: " + actor.sp.to_s + "/" + actor.maxsp.to_s)
  end

    def update
    if Graphics.frame_count / Graphics.frame_rate != @total_sec
      refresh
    end
  end
  
end

class Scene_Map
  alias old_main main
     alias old_update update
   def init_hud
     @Window = My_Window.new
     @HP = $game_party.actors[0].hp
   end
   def main
     init_hud
     old_main
   end
   def dispose
      old_dispose
      @Window.dispose
   end
   def update
     @Window.update if @HP != $game_party.actors[0].hp
     old_update
   end
   end


(I took the Scene_Map class from a HUD tutorial so that the HUD operates in the active scene.)

So I'd really like it if you could give me some pointers on this. It doesn't really function much (For example, it's still visible in a standard RMXP battle, and in the menu. Also, after battle, it prints the HP twice), so I'll try to pick up as much as I can to make it better.

Thanks in advance! You're helping a noble (Well... more or less) cause!
}




Users browsing this thread: