Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #===============================================================================
- # G I _ H U D & G I _ A c t o r
- #===============================================================================
- # Usage Terms
- #-------------------------------------------------------------------------------
- # The following script was developed exclusively to Wonderland Project and
- # anyone else should match the conditions below by under penalty of having longs
- # and strange conversations about rules, and of being overspammed with game
- # envites at its facebook profile.
- #
- # * To use tihs script you must first contact the original creator Guill by one
- # of the contact ways at the end of this register.
- #
- # * You you are not allowed to post this script in any forum or internet page
- # without a previous authorization given by the original creator Guill.
- #-------------------------------------------------------------------------------
- # How to Use
- #-------------------------------------------------------------------------------
- # 1: Paste the attached pictures at "Project/Graphics/Pictures" folder.
- # 2: Go to Configuration section at line 34 and set your preferences.
- # 3: Go to Commands section at line 24 and learn the basic functions.
- # 4: Type the functions at Event's Call Script command.
- #-------------------------------------------------------------------------------
- # Commands
- #-------------------------------------------------------------------------------
- # $gi_actor.heal(n) -> Heals the player in <n> health points.
- # $gi_actor.hurt(n) -> Hurts the player in <n> health points.
- # $gi_actor.grow_life(n) -> Enhance player's life by <n> hearts.
- # $gi_actor.get_key(x) -> Add <x> key.
- # Where <x> must be in ["cup","sword","club","gold"]
- # $gi_actor.drop_key -> Drop player's atual key.
- # $char_hud.change_face(x) -> Change HUD face to "<x>.png".
- #-------------------------------------------------------------------------------
- # Configuration
- #-------------------------------------------------------------------------------
- module GI_HUD_Config
- # Change the values after "=" by your preferences
- X = 0 # HUD screen X position in pixels
- Y = 0 # HUD screen Y position in pixels
- BG = "HUDBG.png" # File name at HUD background's image
- Heart = "Heart.png" # File name at empty heart image
- P1 = "P1.png" # File name at default player image
- Z = 90 # HUD screen Z position
- HUD_Switch = 1 # Visibility yelding switch
- # Put true if you want to regerate life when growing a new heart
- # Put false to otherwise
- Renew_Life = false
- end
- #-------------------------------------------------------------------------------
- # DO NOT CHANGE EVEN A DOT BELOW
- #-------------------------------------------------------------------------------
- class Spriteset_Map
- alias gi_ini initialize
- alias gi_upd update
- alias gi_dis dispose
- def initialize
- gi_ini
- $gi_actor = GI_Actor.new
- $char_hud = GI_HUD.new
- end
- def update
- $char_hud.update if not $char_hud == nil
- gi_upd
- end
- def dispose
- if not $char_hud == nil
- if not $char_hud.disposed?
- $char_hud.dispose
- end
- end
- gi_dis
- end
- end
- class GI_Actor
- attr_accessor :max_life
- attr_accessor :life
- attr_accessor :key
- def initialize
- self.life = 12
- self.max_life = 12
- self.key = ""
- end
- def grow_life(n)
- $char_hud.grow_heart(n)
- end
- def hurt(n)
- $char_hud.drop_life(n)
- SceneManager.goto(Scene_Gameover) if self.life == 0
- end
- def heal(n)
- $char_hud.add_life(n)
- end
- def get_key(x)
- if self.key == ""
- $char_hud.add_key(x)
- self.key = x
- end
- end
- def drop_key
- if not self.key == ""
- $char_hud.drop_key
- self.key = ""
- end
- end
- end
- class GI_HUD
- include GI_HUD_Config
- def initialize
- @vp = Viewport.new(0,0,544,416)
- @vp.z = Z
- @bg = Sprite.new(@vp)
- @bg.x = X
- @bg.y = Y
- @bg.bitmap = Cache.picture(BG)
- @bg.z = 1
- @hearts = []
- i = 0
- while i < 3 do
- @hearts[i] = Sprite.new(@vp)
- @hearts[i].x = X + 50 + (18 * i)
- @hearts[i].y = Y + 8
- @hearts[i].bitmap = Cache.picture(Heart)
- @hearts[i].z = 4 + i
- i += 1
- end
- @player = Sprite.new(@vp)
- @player.x = X + 3
- @player.y = Y
- @player.bitmap = Cache.picture(P1)
- @player.z = 2
- @key = Sprite.new(@vp)
- @key.x = X + 160
- @key.y = Y + 8
- @key.z = 3
- @life = $gi_actor.life
- @max_life = $gi_actor.max_life
- @lifes = []
- i = 0
- @liner = 8
- @h_liner = 8
- while i < 3 do
- draw_heart(i,4,i)
- i += 1
- end
- end
- def update
- @bg.update
- @player.update
- @key.update
- @hearts.each do |i|
- i.update if not i.disposed?
- end
- @lifes.each do |i|
- i.update if not i.disposed?
- end
- $gi_actor.life = @life
- $gi_actor.max_life = @max_life
- if $game_switches[HUD_Switch]
- @vp.visible = true
- else
- @vp.visible = false
- end
- end
- def dispose
- @bg.dispose
- @player.dispose
- @key.dispose
- @hearts.each do |i|
- i.dispose if not i == nil
- end
- @lifes.each do |i|
- i.dispose if not i == nil
- end
- end
- def change_face(x)
- if File.exists("graphics/pictures/" + x + ".png")
- @player = Sprite.new(@vp)
- @player.x = X + 3
- @player.y = Y
- @player.bitmap = Cache.picture(x + ".png")
- @player.z = 2
- end
- end
- def drop_life(n)
- aux = @life - n
- @life = 0
- @lifes.each do |i|
- i.dispose if not i == nil
- end
- add_life(aux)
- end
- def grow_heart(n)
- aux = @max_life + n * 4
- while aux > 48 do
- aux -= 4
- n -= 1
- end
- if n == 0
- return
- end
- n -= 1
- heart_n = (@max_life / 4).to_i
- i = heart_n
- while n >= 0 do
- i = 0 if heart_n == 6
- i = 1 if heart_n == 7
- i = 2 if heart_n == 8
- i = 3 if heart_n == 9
- i = 4 if heart_n == 10
- i = 5 if heart_n == 11
- if @max_life < 24
- @h_liner = 8
- else
- @h_liner = 22
- end
- @hearts[heart_n] = Sprite.new(@vp)
- @hearts[heart_n].x = X + 50 + (18 * i)
- @hearts[heart_n].y = Y + @h_liner
- @hearts[heart_n].bitmap = Cache.picture(Heart)
- @hearts[heart_n].z = 4 + heart_n
- @max_life += 4
- i += 1
- heart_n += 1
- n -= 1
- end
- if Renew_Life
- n = @max_life - @life
- add_life(n)
- end
- end
- def add_life(n)
- aux = @life + n
- while aux > @max_life do
- aux -= 1
- n -= 1
- end
- if n == 0 then return; end
- life = @life % 4
- heart_n = (@life / 4).to_i
- @life -= life
- if not @lifes[heart_n] == nil
- @lifes[heart_n].dispose
- @lifes[heart_n] = nil
- end
- n += life
- while n > 3 do
- draw_heart(heart_n,4,heart_n)
- @life += 4
- heart_n += 1
- n -= 4
- end
- if n > 0
- draw_heart(heart_n,n,heart_n)
- @life += n
- end
- end
- def draw_heart(s,k,i)
- if i == 6 then i = 0 end; if i == 7 then i = 1 end
- if i == 8 then i = 2 end; if i == 9 then i = 3 end
- if i == 10 then i = 4 end; if i == 11 then i = 5 end
- if @life < 24
- @liner = 8
- else
- @liner = 22
- end
- @lifes[s.to_i] = Sprite.new(@vp)
- @lifes[s.to_i].x = X + 50 + 18 * i
- @lifes[s.to_i].y = Y + @liner
- @lifes[s.to_i].z = 16 + s.to_i
- @lifes[s.to_i].bitmap = Cache.picture(k.to_s + ".png")
- end
- def add_key(x)
- @key.bitmap = Cache.picture(x + "_k.png")
- end
- def drop_key
- @key.bitmap.dispose
- @key.bitmap = nil
- @key = Sprite.new(@vp)
- @key.x = X + 160
- @key.y = Y + 8
- @key.z = 3
- end
- end
- #===============================================================================
- # Contacts
- #-------------------------------------------------------------------------------
- # E-Mail: [email protected]
- # Forum Mundo RPG Maker: http://forums.mundorpgmaker.com.br/index.php?action=profile;u=57956
- # Facebook Page: https://www.facebook.com/souza.psg
- #===============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement