Advertisement
Demonicskyers

HUD HP SP

Sep 17th, 2013
479
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 10.27 KB | None | 0 0
  1. #==============================================================================
  2. # PaS HUD v.1.1                                                   by DarkCloud
  3. #
  4. # ~~>Historia
  5. #  ~>Wersja 1.1
  6. #  -Zmienione grafiki barów
  7. #  -Dodany Exp bar
  8. #  -Informacja o obecnym lvl'u
  9. #  -Pozycjonowanie HUD'a
  10. #  *215:"@hudx = left/right" - Tu wybieramy pozycję poziomą HUD'a, lewy/prawy
  11. #  *219:"@hudy = up/down" - Tu wybieramy pozycję pionową HUD'a, góra/dół
  12. #
  13. #==============================================================================
  14.  
  15. #==============================================================================
  16. # ** Window_Base
  17. #------------------------------------------------------------------------------
  18. #  This class is for all in-game windows.
  19. #==============================================================================
  20.  
  21. class Window_Base < Window
  22.  
  23.   #=====================================
  24.   # HUD Pic
  25.   #=====================================  
  26.   def draw_hud(x, y)
  27.     bitmap = RPG::Cache.picture("Hud")
  28.     hw = bitmap.width
  29.     hh = bitmap.height
  30.     self.contents.blt(x , y  , bitmap, Rect.new(0, 0, 204, 92))
  31.   end
  32.   #=====================================
  33.   # Actor Avatar
  34.   #=====================================  
  35.   def draw_actor_avatar(actor, x, y)
  36.     bitmap = RPG::Cache.character("Avatars/" + actor.name, actor.character_hue)
  37.     aw = bitmap.width
  38.     ah = bitmap.height
  39.     self.contents.blt(x , y  , bitmap, Rect.new(0, 0, aw, ah))
  40.   end
  41.   #=====================================
  42.   # Actor Name
  43.   #=====================================  
  44.   def draw_actor_hud_name(actor, x, y)
  45.     self.contents.font.name = "Calligula"
  46.     self.contents.font.color = normal_color
  47.     self.contents.font.size = 14
  48.     self.contents.draw_text(x, y, 120, 32, actor.name)
  49.   end
  50.   #=====================================
  51.   # Actor level
  52.   #=====================================  
  53.   def draw_actor_lv(actor, x, y)
  54.     self.contents.font.name = "Calligula"
  55.     self.contents.font.color = Color.new(0, 180, 0)
  56.     self.contents.font.size = 12
  57.     self.contents.draw_text(x, y, 32, 32, "Lv")
  58.     self.contents.font.name = "Arial"
  59.     self.contents.font.color = Color.new(200, 200, 0)
  60.     self.contents.font.size = 15
  61.     self.contents.draw_text(x + 10, y - 1, 24, 32, actor.level.to_s, 2)
  62.   end
  63.   #=====================================
  64.   # Actor HP bar
  65.   #=====================================  
  66.   def draw_actor_hp_bar(actor, x, y)
  67.     @actor = $game_party.actors[0]
  68.     whp = 160 * @actor.hp / @actor.maxhp
  69.     self.contents.font.name = "Calligula"
  70.     self.contents.font.color = Color.new(0, 180, 0)
  71.     self.contents.font.size = 12
  72.     self.contents.draw_text(x - 20, y - 12, 32, 32, "")
  73.     self.contents.fill_rect(x, y, 160, 0, Color.new(0, 0, 0, 255))
  74.     self.contents.fill_rect(x, y + 1, whp, 1, Color.new(255, 0, 0))
  75.     self.contents.fill_rect(x, y + 2, whp, 1, Color.new(235, 0, 0))
  76.     self.contents.fill_rect(x, y + 3, whp, 1, Color.new(215, 0, 0))
  77.     self.contents.fill_rect(x, y + 4, whp, 1, Color.new(195, 0, 0))
  78.     self.contents.fill_rect(x, y + 5, whp, 1, Color.new(175, 0, 0))
  79.     self.contents.fill_rect(x, y + 6, whp, 1, Color.new(155, 0, 0))
  80.     self.contents.fill_rect(x, y + 7, whp, 1, Color.new(135, 0, 0))
  81.     self.contents.fill_rect(x, y + 8, whp, 1, Color.new(115, 0, 0))
  82.     self.contents.fill_rect(x, y + 9, whp, 1, Color.new(95, 0, 0))
  83.     self.contents.fill_rect(x, y + 10, whp, 1, Color.new(85, 0, 0))
  84.     self.contents.fill_rect(x, y + 11, whp, 1, Color.new(75, 0, 0))
  85.     self.contents.fill_rect(x, y + 12, whp, 1, Color.new(65, 0, 0))
  86.     self.contents.fill_rect(x, y + 13, whp, 1, Color.new(55, 0, 0))
  87.     self.contents.fill_rect(x, y + 14, whp, 1, Color.new(45, 0, 0))
  88.     self.contents.fill_rect(x, y + 15, whp, 1, Color.new(35, 0, 0))
  89.     self.contents.fill_rect(x, y + 16, whp, 1, Color.new(25, 0, 0))
  90.     self.contents.fill_rect(x, y + 17, whp, 1, Color.new(15, 0, 0))
  91.     self.contents.fill_rect(x, y + 18, whp, 1, Color.new(5, 0, 0))
  92.     self.contents.fill_rect(x, y + 19, whp, 1, Color.new(0, 0, 0))
  93.     bitmap = RPG::Cache.picture("HP_SP_bar")
  94.     hbw = bitmap.width
  95.     hbh = bitmap.height
  96.     self.contents.blt(x , y  , bitmap, Rect.new(0, 0, hbw, hbh))
  97.   end
  98.   #=====================================
  99.   # Actor SP bar
  100.   #=====================================  
  101.   def draw_actor_sp_bar(actor, x, y)
  102.     @actor = $game_party.actors[0]
  103.     wsp = 160 * @actor.sp / @actor.maxsp
  104.     self.contents.font.name = "Calligula"
  105.     self.contents.font.color = Color.new(0, 180, 0)
  106.     self.contents.font.size = 12
  107.     self.contents.draw_text(x - 18, y - 12, 32, 32, "")
  108.     self.contents.fill_rect(x, y, 160, 0, Color.new(0, 0, 0, 255))
  109.     self.contents.fill_rect(x, y + 1, wsp, 1, Color.new(0, 0, 255))
  110.     self.contents.fill_rect(x, y + 2, wsp, 1, Color.new(0, 0, 235))
  111.     self.contents.fill_rect(x, y + 3, wsp, 1, Color.new(0, 0, 215))
  112.     self.contents.fill_rect(x, y + 4, wsp, 1, Color.new(0, 0, 195))
  113.     self.contents.fill_rect(x, y + 5, wsp, 1, Color.new(0, 0, 175))
  114.     self.contents.fill_rect(x, y + 6, wsp, 1, Color.new(0, 0, 155))
  115.     self.contents.fill_rect(x, y + 7, wsp, 1, Color.new(0, 0, 135))
  116.     self.contents.fill_rect(x, y + 8, wsp, 1, Color.new(0, 0, 115))
  117.     self.contents.fill_rect(x, y + 9, wsp, 1, Color.new(0, 0, 95))
  118.     self.contents.fill_rect(x, y + 10, wsp, 1, Color.new(0, 0, 85))
  119.     self.contents.fill_rect(x, y + 11, wsp, 1, Color.new(0, 0, 75))
  120.     self.contents.fill_rect(x, y + 12, wsp, 1, Color.new(0, 0, 65))
  121.     self.contents.fill_rect(x, y + 13, wsp, 1, Color.new(0, 0, 55))
  122.     self.contents.fill_rect(x, y + 14, wsp, 1, Color.new(0, 0, 45))
  123.     self.contents.fill_rect(x, y + 15, wsp, 1, Color.new(0, 0, 35))
  124.     self.contents.fill_rect(x, y + 16, wsp, 1, Color.new(0, 0, 25))
  125.     self.contents.fill_rect(x, y + 17, wsp, 1, Color.new(0, 0, 15))
  126.     self.contents.fill_rect(x, y + 18, wsp, 1, Color.new(0, 0, 5))
  127.     self.contents.fill_rect(x, y + 19, wsp, 1, Color.new(0, 0, 0))
  128.     bitmap = RPG::Cache.picture("HP_SP_bar")
  129.     sbw = bitmap.width
  130.     sbh = bitmap.height
  131.     self.contents.blt(x , y  , bitmap, Rect.new(0, 0, sbw, sbh))
  132.   end
  133.   #=====================================
  134.   # Actor Exp bar
  135.   #=====================================  
  136.   def draw_actor_exp_bar(actor, x, y)
  137.     @actor = $game_party.actors[0]
  138.     exp1 = actor.now_exp
  139.     exp2 = actor.next_exp
  140.     if actor.next_exp == 0
  141.       exp1 = 1
  142.       exp2 = 1
  143.     end
  144.     wexp = 150 * exp1 / exp2
  145.     self.contents.fill_rect(x, y, 159, 19, Color.new(230, 230, 230, 150))
  146.     self.contents.fill_rect(x, y + 1, wexp, 1, Color.new(255, 128, 0))
  147.     self.contents.fill_rect(x, y + 2, wexp, 1, Color.new(235, 118, 0))
  148.     self.contents.fill_rect(x, y + 3, wexp, 1, Color.new(215, 108, 0))
  149.     self.contents.fill_rect(x, y + 4, wexp, 1, Color.new(195, 98, 0))
  150.     bitmap = RPG::Cache.picture("Exp_bar")
  151.     ebw = bitmap.width
  152.     ebh = bitmap.height
  153.     self.contents.blt(x , y  , bitmap, Rect.new(0, 0, ebw, ebh))
  154.   end
  155. end
  156.  
  157.  
  158. #==============================================================================
  159. # ** Game_Actor
  160. #------------------------------------------------------------------------------
  161. #  This class handles the actor. It's used within the Game_Actors class
  162. #  ($game_actors) and refers to the Game_Party class ($game_party).
  163. #==============================================================================
  164.  
  165. class Game_Actor < Game_Battler
  166.   #--------------------------------------------------------------------------
  167.   # * Get the current EXP
  168.   #--------------------------------------------------------------------------
  169.   def now_exp
  170.     return @exp - @exp_list[@level]
  171.   end
  172.   #--------------------------------------------------------------------------
  173.   # * Get the next level's EXP
  174.   #--------------------------------------------------------------------------
  175.   def next_exp
  176.     return @exp_list[@level+1] > 0 ? @exp_list[@level+1] - @exp_list[@level] : 0
  177.   end
  178. end
  179.  
  180. #==============================================================================
  181. # ** Scene_Map
  182. #------------------------------------------------------------------------------
  183. #  This class performs map screen processing.
  184. #==============================================================================
  185.  
  186. class Scene_Map
  187.   #--------------------------------------------------------------------------
  188.   # * Main Processing
  189.   #--------------------------------------------------------------------------
  190.   alias hud_main main
  191.   def main
  192.     @Hud = Window_Hud.new
  193.     hud_main
  194.     @Hud.dispose if @Hud != nil
  195.   end
  196.   #--------------------------------------------------------------------------
  197.   # * Frame Update
  198.   #--------------------------------------------------------------------------
  199.   alias hud_update update
  200.   def update
  201.     @Hud.update
  202.     hud_update
  203.   end
  204. end
  205.  
  206. #==============================================================================
  207. # ** Window_Hud
  208. #------------------------------------------------------------------------------
  209. #  This window displays HUD.
  210. #==============================================================================
  211.  
  212. class Window_Hud < Window_Base
  213.  
  214.   #--------------------------------------------------------------------------
  215.   # * Object Initialization
  216.   #--------------------------------------------------------------------------
  217.   def initialize
  218.     super(-16, -16, 300, 150)
  219.     self.contents = Bitmap.new(width - 32, height - 32)
  220.     self.opacity = 0
  221.     if $game_switches[1] == false
  222.       self.x = -400
  223.     end
  224.   end
  225.   #--------------------------------------------------------------------------
  226.   # * Frame Update
  227.   #--------------------------------------------------------------------------
  228.   def update
  229.     self.contents.clear
  230.     actor = $game_party.actors[0]
  231.     draw_hud(0, 0)
  232.     draw_actor_hp_bar(actor, 17, 18)
  233.     draw_actor_sp_bar(actor, 17, 48)
  234.     #------------------------------------------------------------------------
  235.     # * Hud position
  236.     #------------------------------------------------------------------------
  237.     left = - 16
  238.     right = 436
  239.     @hudx = left
  240.     up = - 16
  241.     down = 351
  242.     @hudy = up
  243.     if $game_switches[1] == true
  244.         self.x = @hudx
  245.         self.y = @hudy
  246.     end
  247.     if $game_switches[1] == false
  248.         self.x = -400
  249.     end
  250.   end
  251. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement