Raven BellamyVie Feb 08, 2013 10:57 pm
Usuario Nv9
Hola vengo a dejarles un script que deja tu vida en corazones
Y esta es la demo
http://www.mediafire.com/?2lmtyzmwmum
Si quieres cambiar los corazones en la carpeta system estan las imagens
cambialas por las que quieras y poneles el mismo nombre
Yo edite el script y la demo porque estaba en ingles
saludos
- Código:
# ================================================= ============================
#Zelda OmegaX Sistema de Salud.
# Autor: Omegas7
#Editor: TigreX
#Versión #: 0,1.
# ================================================= ============================
#Descripción
# Simula un sistema de Zelda Corazones: Un HUD que representará a su HP con
# Gráficos corazón. Cada corazón es un valor de 4 HP (4 fragmentos).
# ================================================= ============================
# Notas:
# Sólo asegúrese de que la vida del jugador es un múltiplo de 4 de tener esta
# Funciona correctamente!
# =============================================================================
module OmegaX
module ZeldaHealth
HeartsPerRow = 10
HeartGraphic = 'Heart'
HeartBack = 'HeartBack'
SWITCH = 1
end
end
class ZeldaHealth
include OmegaX::ZeldaHealth
def initialize
@member = $game_party.members[0]
@id = 0
if @member != nil
@id = @member.id
@hp = $game_party.members[0].hp
@maxhp = $game_party.members[0].maxhp
end
@backs = []
@hearts = []
@switch = $game_switches[SWITCH]
draw_sprites if @id != 0
refresh if @id != 0
end
def clear
for i in 0...@hearts.size
@hearts[i].finish
@hearts[i] = nil
@backs[i].finish
@backs[i] = nil
end
@hearts.compact!
@backs.compact!
end
def draw_sprites
row = 0
requirement_for_row = HeartsPerRow
x = 0
for i in 0...((@maxhp/4.0).ceil)
if i < requirement_for_row
@backs.push(ZeldaHeartBack.new(x,row))
@hearts.push(ZeldaHeart.new(x,row))
x += 1
else
row += 1
x = 0
requirement_for_row += (HeartsPerRow)
@backs.push(ZeldaHeartBack.new(x,row))
@hearts.push(ZeldaHeart.new(x,row))
x = 1
end
@hearts[@hearts.size - 1].visible(@switch)
@backs[@hearts.size - 1].visible(@switch)
end
end
def refresh
hp = @hp
done = false
if hp > 0
for heart in 0...@hearts.size
for switch in 0...@hearts[heart].switches.size
if @hearts[heart].switches[switch] == false && hp > 0
@hearts[heart].switches[switch] = true
hp -= 1
done = true if hp <= 0
end
end
end
end
for i in 0...@hearts.size
@hearts[i].update
end
end
def update
if $game_party.members[0] == nil
if @id != 0
@id = 0
finish
end
else
if @id != $game_party.members[0].id
@id = -1
end
end
if @id != 0
if @hp != $game_party.members[0].hp ||
@maxhp != $game_party.members[0].maxhp ||
@switch != $game_switches[SWITCH] ||
@id != $game_party.members[0].id
@id = $game_party.members[0].id
@switch = $game_switches[SWITCH]
@hp = $game_party.members[0].hp
@maxhp = $game_party.members[0].maxhp
clear
draw_sprites
refresh
end
end
end
def finish
for i in 0...@hearts.size
@hearts[i].finish
@backs[i].finish
end
end
end
class ZeldaHeartBack
include OmegaX::ZeldaHealth
def initialize(index,row)
@sprite = Sprite_Base.new
@sprite.bitmap = Cache.system(HeartBack)
@sprite.x = index * @sprite.width
@sprite.y = row * @sprite.height
@sprite.z = 100
end
def visible(value)
@sprite.visible = value
end
def finish
@sprite.dispose
end
end
class ZeldaHeart
include OmegaX::ZeldaHealth
attr_accessor :switches
def initialize(index,row)
bitmap = Cache.system(HeartGraphic)
@switches = [false,false,false,false]
@current = [false,false,false,false]
@parts = []
@sprite = Sprite_Base.new
@sprite.bitmap = Bitmap.new(bitmap.width,bitmap.height)
@sprite.x = index * bitmap.width
@sprite.y = row * bitmap.height
@sprite.z = 101
for i in 0...4
@parts.push(Bitmap.new(bitmap.width/2,bitmap.height/2))
case i
when 0
@parts[i].blt(0,0,bitmap,Rect.new(0,0,bitmap.width/2,bitmap.height/2))
when 1
@parts[i].blt(0,0,bitmap,Rect.new(bitmap.width/2,0,bitmap.width/2,bitmap.height/2))
when 2
@parts[i].blt(0,0,bitmap,Rect.new(0,bitmap.height/2,bitmap.width/2,bitmap.height/2))
when 3
@parts[i].blt(0,0,bitmap,Rect.new(bitmap.width/2,bitmap.height/2,bitmap.width/2,bitmap.height/2))
end
end
end
def update
if @current != @switches
refresh
end
end
def refresh
@sprite.bitmap.clear
@current = @switches
for i in 0...@current.size
if @current[i]
case i
when 0
@sprite.bitmap.blt(0,0,@parts[i],Rect.new(0,0,@parts[i].width,@parts[i].height))
when 1
@sprite.bitmap.blt(@parts[i].width,0,@parts[i],Rect.new(0,0,@parts[i].width,@parts[i].height))
when 2
@sprite.bitmap.blt(0,@parts[i].height,@parts[i],Rect.new(0,0,@parts[i].width,@parts[i].height))
when 3
@sprite.bitmap.blt(@parts[i].width,@parts[i].height,@parts[i],Rect.new(0,0,@parts[i].width,@parts[i].height))
end
end
end
end
def visible(value)
@sprite.visible = value
end
def finish
@sprite.dispose
end
end
class Scene_Map
alias omegax_zelda_health_initialize initialize
alias omegax_zelda_health_update update
alias omegax_zelda_health_terminate terminate
def initialize
omegax_zelda_health_initialize
@zeldahealth = ZeldaHealth.new
end
def update
omegax_zelda_health_update
@zeldahealth.update
end
def terminate
omegax_zelda_health_terminate
@zeldahealth.finish
end
end
Y esta es la demo
http://www.mediafire.com/?2lmtyzmwmum
Si quieres cambiar los corazones en la carpeta system estan las imagens
cambialas por las que quieras y poneles el mismo nombre
Yo edite el script y la demo porque estaba en ingles
saludos