[HUD]Survivor
SurvivorAutor: Enter
Thank: Masked, Raizen, miguel8884, Fábio Pichler, Sixth. For your topics and support that give to beginners in RGSS .
Click to expand...
Introduction
This is my first RGSS3 script. And it will be updated as necessary.
- You can give suggestions on this hud that topic.
If you are a programmer or scripter and want to make your code suggestion use the github :
https://github.com/leolucass/ruby.git
Click to expand...
Click to expand...
Features
08/02/2015
*It becomes visible when the SHIFT key is held down
*It is a customizable hud that has HP bars , MP , Stamina and Hunger.
14/04/2015
* An amount of stamina is subtracted each time you press the SHIFT key (to run)
note: while stamina is zero, the race is locked system with shift.
* Added the seat bar (water)
* When headquarters reaches less than or equal to 1 is given Game Over.
30/052015
version 2.0
# 30/05/2015: Set comments and variables to English (V)
# To facilitate handling call with creating a class method in the game Interpreter (V)
#Colocar Gameover when you get zero on all status (V)
Click to expand...
Videos
Videos
1º Download the graphics [ HUD ] Survivor the following link:
http://www.4shared.c...a/Pictures.html
2º Each image must go in the Pictures folder rpg maker
To handle the Stamina attribute or famine , use the call event:
Example : Subtracting 10 points hunger bar on the call event:
@actorId=0
@value=-10
@change=Game_Interpreter.new
@change.change_hunger(@actorId,@value)
Click to expand...
Script
Code:
#Authors: leolucas(=Enter)#About this script: #This MOD is a script that contain a #HUD (HP,MP, thirsty, Stamina and Hunger bar);#if you press the "S" key then these bars become visible.#and#If the player have stamina enough then he can run pressing the SHIFT key else he not can run#If thirst or hunger or hp <= 1 then Game Over#RGSS3#Script version 2.0# SETUPmodule EnterConfigHUDHUNGER= 199#hungerMHUNGER = 200 Stamina = 199 Mstamina = 200 THIRST = 199 MTHIRST = 200end#------------------------------------------------ #Creating new attributes class Game_BattlerBase attr_accessor :HUNGER, :mHUNGER, :stamina, :mstamina, :THIRST, :mTHIRSTalias modificando initializedef initialize(*args) modificando(*args) @HUNGER = EnterConfigHUD::HUNGER @mHUNGER = EnterConfigHUD::MHUNGER @stamina = EnterConfigHUD::Stamina @mstamina = EnterConfigHUD::Mstamina @THIRST = EnterConfigHUD::THIRST @mTHIRST = EnterConfigHUD::MTHIRST enddef HUNGER=(x) #Is something like setHUNGER and getHUNGER but to act like exception treatment @HUNGER = x @HUNGER = @mHUNGER if @HUNGER > @mHUNGER #Here is defined the limit of the value @HUNGER = 0 if @HUNGER < 0 enddef stamina=(x) @stamina = x @stamina = @mstamina if @stamina > @mstamina @stamina = 0 if @stamina < 0 end def THIRST=(x) @THIRST = x @THIRST = @mTHIRST if @THIRST > @mTHIRST @THIRST = 0 if @THIRST < 0end end#Game_BattlerBase#-------------------------------------------------# H U Dclass SurvivorHUDattr_accessor :actordef initialize(actor) @actor = actor @bg = Sprite.new @bg.bitmap = Bitmap.new(Graphics.width, Graphics.height) @fg = Sprite.new @fg.bitmap = Bitmap.new(Graphics.width, Graphics.height) #@sbox = Sprite.new#soon #@sbox.bitmap = Bitmap.new(Graphics.width, Graphics.height)#soon @THIRSTBox = Sprite.new @THIRSTBox.bitmap = Bitmap.new(Graphics.width, Graphics.height) @fTHIRSTBox = Sprite.new @fTHIRSTBox.bitmap = Bitmap.new(Graphics.width, Graphics.height)##foreground update_variables draw_background draw_foregroundenddef update refresh if need_update?enddef refresh update_variables draw_foregroundenddef draw_background @bg.bitmap.clear #@sbox.bitmap.clear#soon @THIRSTBox.bitmap.clear create_background_bitmaps create_background @bg.bitmap.blt(190, 350, @background, @background.rect) #@sbox.bitmap.blt(30,3,@scorebox, @scorebox.rect) #To the first numbers are defined the coordinates @THIRSTBox.bitmap.blt(525,150, @bTHIRST, @bTHIRST.rect) end def draw_foreground @fg.bitmap.clear @fTHIRSTBox.bitmap.clear create_foreground_bitmaps create_foreground @fg.bitmap.blt(190, 350, @foreground, @foreground.rect) @fTHIRSTBox.bitmap.blt(525,150, @foreTHIRST, @foreTHIRST.rect)end def create_background_bitmaps @bhp = Cache.picture('barraenergiaCompleta') @bmp = Cache.picture('barraenergiaCompleta') @bHUNGER = Cache.picture('barraenergiaCompleta') @bstamina = Cache.picture('barraenergiaCompleta') @background = Cache.picture('backgroundHUD') @bTHIRST = Cache.picture('SedeBar')# #@scorebox = Cache.picture('scorebox')#enddef create_background @background.blt(16, 12, @bstamina, @bstamina.rect) #Here is drawn the background of bars @background.blt(16, 2, @bHUNGER, @bHUNGER.rect) @background.blt(16, 28, @bhp, @bhp.rect) @background.blt(16, 54, @bmp, @bmp.rect) @bTHIRST.blt(55,14, @bTHIRST, @bTHIRST.rect)enddef create_foreground_bitmaps @fhp = Cache.picture "hp_bar" @fmp = Cache.picture "mp_bar" @fHUNGER = Cache.picture "Fome_bar" @fstamina = Cache.picture "stamina_bar" @fTHIRST = Cache.picture "sede_bar" @foreTHIRST = Bitmap.new(@bTHIRST.width, @bTHIRST.height)# @foreground = Bitmap.new(@background.width, @background.height) #drawing a space that have measures of image backgroundHUD. And it'll use the blt and rect to put the images of bars. enddef create_foreground w = @fstamina.width * @actor.stamina/@actor.mstamina.to_f #Define the width of bar h = @fstamina.height rect = Rect.new(0,0,w.to_i,h) @foreground.blt(16, 12, @fstamina, rect) w = @fHUNGER.width * @actor.HUNGER/@actor.mHUNGER.to_f #Define the width of bar h = @fHUNGER.height rect = Rect.new(0,0,w.to_i,h) @foreground.blt(16, 2, @fHUNGER, rect) w = @fhp.width * @actor.hp/@actor.mhp.to_f #Define the width of bar h = @fhp.height rect = Rect.new(0,0,w.to_i,h) @foreground.blt(16, 29, @fhp, rect) w = @fmp.width * @actor.mp/@actor.mmp.to_f #Define the width of bar h = @fmp.height rect = Rect.new(0,0,w.to_i,h) @foreground.blt(16, 53, @fmp, rect) w = @fTHIRST.width h = @fTHIRST.height * @actor.THIRST/@actor.mTHIRST.to_f #Define the width of bar rect = Rect.new(0,0,h.to_i,h) @foreTHIRST.blt(0, 0, @fTHIRST, rect)enddef update_variables @actor_hp = @actor.hp @actor_mhp = @actor.mhp @actor_mp = @actor.mp @actor_mmp = @actor.mmp @actor_HUNGER = @actor.HUNGER @actor_mHUNGER = @actor.mHUNGER @actor_stamina = @actor.stamina @actor_mstamina = @actor.mstamina @actor_THIRST = @actor.THIRST @actor_mTHIRST = @actor.mTHIRSTenddef need_update? hp_need_update? || mp_need_update? || stamina_need_update? || HUNGER_need_update? || THIRST_need_update?end def hp_need_update? @actor_hp != @actor.hp || @actor_mhp != @actor.mhpenddef mp_need_update? @actor_mp != @actor.mp || @actor_mmp != @actor.mmpend def HUNGER_need_update? @actor_HUNGER != @actor.HUNGER || @actor_mHUNGER != @actor.mHUNGERenddef stamina_need_update? @actor_stamina != @actor.stamina || @actor_mstamina != @actor.mstaminaend def THIRST_need_update? @actor_THIRST != @actor.THIRST || @actor_mTHIRST != @actor.mTHIRST enddef visible=(tf) #true or false will be the value returned = tf. Here will be linked with the "Input.press?" condition @bg.visible=@fg.visible=tf @THIRSTBox.visible = @fTHIRSTBox.visible = tfend#def scoreVisible=(tf)##@sbox.visible = tf#enddef dispose @bg.dispose @fg.dispose @fTHIRSTBox.dispose @fTHIRSTBox.disposeendend#---------------------------- C O R R E R --------------------class Game_Player < Game_Characteralias enter_initialize initializedef initialize $Ncorre = false enter_initializeenddef dash? return false if @move_route_forcingreturn false if $game_map.disable_dash?return false if vehiclereturn false if $Ncorre == true #return Input.press?(:A) if $Ncorre == falsereturn $Ncorreendend #----------------------- using survivor -------------------------- class Scene_Map < Scene_Basealias enter_hud_start startalias enter_hud_update updatealias enter_hud_terminate terminatedef start enter_hud_start #alias @hud = SurvivorHUD.new($game_party.members)end def update #------------------------ @groupp = $game_party.members if @groupp.stamina <= 1 $Ncorre = true else $Ncorre = false end if Input.trigger?(:A) @decrease = 10 @groupp.stamina = @groupp.stamina - @decrease end if @groupp.THIRST <= 1 || @groupp.HUNGER<= 1 || @groupp.hp <= 1 SceneManager.goto(Scene_Gameover) end #------------------------- enter_hud_update #alias @hud.visible = Input.press?(:Y) #S key #@hud.scoreVisible = Input.press?(:A) # shift key #------------------- #-------------------------- #@hud.THIRSTVisible = true @hud.update end def terminate enter_hud_terminate @hud.disposeendendclass Game_Interpreter #thanks Sixth def change_hunger(actor_id,value) old_val = $game_party.members.HUNGER new_val = old_val + value $game_party.members.HUNGER = new_valend def change_stamina(actor_id,value) old_val = $game_party.members.stamina new_val = old_val + value $game_party.members.stamina = new_valend def change_hp(actor_id,value) old_val = $game_party.members.hp new_val = old_val + value $game_party.members.hp = new_valend def change_sp(actor_id,value) old_val = $game_party.members.sp new_val = old_val + value $game_party.members.sp = new_valend end
本贴来自国际rpgmaker官方论坛作者:Enter处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/hud-survivor.36744/
页:
[1]