Dano com efeito de gravidade.
2 participantes
Página 1 de 1
Dano com efeito de gravidade.
Esse script faz com que o mostrador de dano tenha um efeito gravitacional durante a batalha. É um ótimo script, recomendo que usem.
fica bem legal no jogo!
fica bem legal no jogo!
- Código:
################################################################################
################################### XMS ########################################
################################################################################
=begin
Gravity Effect
--------------------------------------------------------------------------------
Script criado pelo site XMS.
Created by XMS site.
--------------------------------------------------------------------------------
FUNÇÃO
Permite que a apresentação do dano tenha o efeito de gravidade.
CUSTOMIZAÇÃO
=end
#-------------------------------------------------------------------------------
module XRXS_DAMAGE
def damage_x_init_velocity
#Quantidade de direçíµes que o dano poderá pular.
return 1.2 * (rand(5) - 2)
end
def damage_y_init_velocity
#Velocidade do dano.
return 10
end
#Força da gravidade.
GRAVITY = 0.98
end
#-------------------------------------------------------------------------------
module XRXS_DAMAGE
def update
super
@damage_sprites = [] if @damage_sprites.nil?
@damage_durations = [] if @damage_durations.nil?
if @_damage_sprite != nil and @_damage_sprite.visible
x = damage_x_init_velocity
y = damage_y_init_velocity
d = @_damage_duration
@damage_sprites.push(Sprite_Damage.new(@_damage_sprite, x, y, d))
@_damage_sprite.visible = false
end
for damage_sprite in @damage_sprites
damage_sprite.update
end
for i in 0...@damage_sprites.size
@damage_sprites[i] = nil if @damage_sprites[i].disposed?
end
@damage_sprites.compact!
end
def dispose
super
if @damage_sprites != nil
for damage_sprite in @damage_sprites
damage_sprite.dispose
end
end
end
end
class RPG::Sprite < Sprite
include XRXS_DAMAGE
end
class Sprite_Damage < Sprite
def initialize(sprite, init_x_speed, init_y_speed, duration)
super(nil)
self.bitmap = sprite.bitmap.dup unless sprite.bitmap.nil?
self.opacity = sprite.opacity
self.x = sprite.x
self.y = sprite.y
self.z = sprite.z
self.ox = sprite.ox
self.oy = sprite.oy
@now_x_speed = init_x_speed
@now_y_speed = init_y_speed
@potential_x_energy = 0.0
@potential_y_energy = 0.0
@duration = duration
end
def update
super
n = self.oy + @now_y_speed
if n <= 0
@now_y_speed *= -1
@now_y_speed /= 2
@now_x_speed /= 2
end
self.oy = [n, 0].max
@potential_y_energy += XRXS_DAMAGE::GRAVITY
speed = @potential_y_energy.floor
@now_y_speed -= speed
@potential_y_energy -= speed
@potential_x_energy += @now_x_speed
speed = @potential_x_energy.floor
self.ox += speed
@potential_x_energy -= speed
@duration -= 1
if @duration == 0
self.dispose
end
end
end
natan- Estudante
- Mensagens : 26
Página 1 de 1
Permissões neste sub-fórum
Não podes responder a tópicos