Code:
#==============================================================================
# ** Scene_Menu
#------------------------------------------------------------------------------
# This class performs menu screen processing.
#==============================================================================
class Scene_Menu
#--------------------------------------------------------------------------
# * Object Initialization
# menu_index : command cursor's initial position
#--------------------------------------------------------------------------
def initialize(menu_index = 0)
@menu_index = menu_index
end
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
# Make command window
s1 = $data_system.words.item
s2 = $data_system.words.skill
s3 = $data_system.words.equip
s4 = "Status"
s5 = "Save"
s6 = "End Game"
@command_window = Scrolling_Command.new("horz", 80, [s1, s2, s3, s4, s5, s6], 1, @menu_index)
@command_window.index = @menu_index
# If number of party members is 0
if $game_party.actors.size == 0
# Disable items, skills, equipment, and status
@command_window.disable_item(0)
@command_window.disable_item(1)
@command_window.disable_item(2)
@command_window.disable_item(3)
end
# If save is forbidden
if $game_system.save_disabled
# Disable save
@command_window.disable_item(4)
end
# Make play time window
@playtime_window = Window_PlayTime.new
@playtime_window.x = 320
@playtime_window.y = 380
# Make steps window
@steps_window = Window_Location.new
@steps_window.x = 0
@steps_window.y = 380
# Make gold window
@gold_window = Window_Gold.new
@gold_window.x = 360
@gold_window.y = 0
# Make status window
@status_window = Window_MenuStatus.new
@status_window.x = 0
@status_window.y = 80
# Execute transition
Graphics.transition
# Main loop
loop do
# Update game screen
Graphics.update
# Update input information
Input.update
# Frame update
update
# Abort loop if screen is changed
if $scene != self
break
end
end
# Prepare for transition
Graphics.freeze
# Dispose of windows
@command_window.dispose
@playtime_window.dispose
@steps_window.dispose
@gold_window.dispose
@status_window.dispose
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Update windows
@command_window.update
@playtime_window.update
@steps_window.update
@gold_window.update
@status_window.update
# If command window is active: call update_command
if @command_window.active
update_command
return
end
# If status window is active: call update_status
if @status_window.active
update_status
return
end
end
#--------------------------------------------------------------------------
# * Frame Update (when command window is active)
#--------------------------------------------------------------------------
def update_command
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Switch to map screen
$scene = Scene_Map.new
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# If command other than save or end game, and party members = 0
if $game_party.actors.size == 0 and @command_window.index < 4
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Branch by command window cursor position
case @command_window.index
when 0 # item
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to item screen
$scene = Scene_Item.new
when 1 # skill
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Make status window active
@command_window.active = false
@status_window.active = true
@status_window.index = 0
when 2 # equipment
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Make status window active
@command_window.active = false
@status_window.active = true
@status_window.index = 0
when 3 # status
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Make status window active
@command_window.active = false
@status_window.active = true
@status_window.index = 0
when 4 # save
# If saving is forbidden
if $game_system.save_disabled
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to save screen
$scene = Scene_Save.new
when 5 # end game
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to end game screen
$scene = Scene_End.new
end
return
end
end
#--------------------------------------------------------------------------
# * Frame Update (when status window is active)
#--------------------------------------------------------------------------
def update_status
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Make command window active
@command_window.active = true
@status_window.active = false
@status_window.index = -1
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# Branch by command window cursor position
case @command_window.index
when 1 # skill
# If this actor's action limit is 2 or more
if $game_party.actors[@status_window.index].restriction >= 2
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to skill screen
$scene = Scene_Skill.new(@status_window.index)
when 2 # equipment
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to equipment screen
$scene = Scene_Equip.new(@status_window.index)
when 3 # status
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to status screen
$scene = Scene_Status.new(@status_window.index)
end
return
end
end
end
#==============================================================================
# ** Window_MenuStatus
#------------------------------------------------------------------------------
# This window displays party member status on the menu screen.
#==============================================================================
class Window_MenuStatus < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(0, 0, 640, 300)
self.contents = Bitmap.new(width - 32, height - 32)
refresh
self.active = false
self.index = -1
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
@item_max = $game_party.actors.size
x = 114
y = 0
x2 = 10
self.contents.font.color = system_color
self.contents.draw_text(x2, 0, 96, 32, $data_system.words.weapon)
self.contents.draw_text(x2, 40, 96, 32, $data_system.words.armor1)
self.contents.draw_text(x2, 80, 96, 32, $data_system.words.armor2)
self.contents.draw_text(x2, 120, 96, 32, $data_system.words.armor3)
self.contents.draw_text(x2, 160, 96, 32, $data_system.words.armor4)
draw_item_name($data_weapons[$game_actors[1].weapon_id], x2 + 24, 20)
draw_item_name($data_armors[$game_actors[1].armor1_id], x2 + 24, 60)
draw_item_name($data_armors[$game_actors[1].armor2_id], x2 + 24, 100)
draw_item_name($data_armors[$game_actors[1].armor3_id], x2 + 24, 140)
draw_item_name($data_armors[$game_actors[1].armor4_id], x2 + 24, 180)
draw_actor_graphic2($game_actors[1], x + 250, y + 175)
draw_actor_name($game_actors[1], x + 75, y + 170)
draw_actor_class($game_actors[1], x + 219, y + 170)
draw_actor_level($game_actors[1], x + 75, y + 202)
draw_actor_state($game_actors[1], x + 165, y + 202)
draw_actor_exp($game_actors[1], x + 75, y + 236)
draw_actor_hp($game_actors[1], x + 311, y + 202)
draw_actor_sp($game_actors[1], x + 311, y + 236)
end
#--------------------------------------------------------------------------
# * Cursor Rectangle Update
#--------------------------------------------------------------------------
def update_cursor_rect
if @index < 0
self.cursor_rect.empty
else
self.cursor_rect.set(0, @index * 116, self.width - 32, 268)
end
end
end
#==============================================================================
# ** Window_Gold
#------------------------------------------------------------------------------
# This window displays amount of gold.
#==============================================================================
class Window_Gold < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(0, 0, 280, 80)
self.contents = Bitmap.new(width - 32, height - 32)
refresh
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
cx = contents.text_size($data_system.words.gold).width
self.contents.font.color = normal_color
self.contents.draw_text(20, 10, 100, 32, "You Have", 2)
self.contents.draw_text(80, 10, 120-cx-2, 32, $game_party.gold.to_s, 2)
self.contents.font.color = system_color
self.contents.draw_text(200-cx, 10, cx, 32, $data_system.words.gold, 2)
end
end
#==============================================================================
# ** Window_PlayTime
#------------------------------------------------------------------------------
# This window displays play time on the menu screen.
#==============================================================================
class Window_PlayTime < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(0, 0, 320, 100)
self.contents = Bitmap.new(width - 32, height - 32)
refresh
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
self.contents.font.color = system_color
self.contents.draw_text(4, 0, 120, 32, "Play Time")
@total_sec = Graphics.frame_count / Graphics.frame_rate
hour = @total_sec / 60 / 60
min = @total_sec / 60 % 60
sec = @total_sec % 60
text = sprintf("%02d:%02d:%02d", hour, min, sec)
self.contents.font.color = normal_color
self.contents.draw_text(4, 32, 120, 32, text, 2)
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
super
if Graphics.frame_count / Graphics.frame_rate != @total_sec
refresh
end
end
end
#==============================================================================
# ** Window_Steps
#------------------------------------------------------------------------------
# This window displays step count on the menu screen.
#==============================================================================
class Window_Location < Window_Base
def initialize
super(0, 0, 320, 100)
self.contents = Bitmap.new (width - 32, height - 32)
refresh
end
def refresh
self.contents.clear
self.contents.font.color = system_color
self.contents.font.color = normal_color
$maps = load_data("Data/MapInfos.rxdata")
@map_id = $game_map.map_id
@currmap = $maps[@map_id].name
self.contents.draw_text(2, 30, 120, 32, @currmap)
#In the parenthesis put what you want
self.contents.draw_text(4, 0, 300, 32, "Your Current Location Is: ")
end
end
class Window_Base < Window
def draw_actor_graphic2(actor, x, y)
bitmap = RPG::Cache.battler(actor.battler_name, actor.battler_hue)
cw = bitmap.width / 1
ch = bitmap.height / 1
src_rect = Rect.new(0, 0, cw, ch)
self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect)
end
end
class Scrolling_Command < Window_Base
attr_reader :index
attr_reader :help_window
SPEED = 2
HORZ_SPACING = 10
def initialize(align, side, commands, focus, startindex, disabled = [])
startup(align, side, commands, focus, disabled)
super(0, 0, @width, @height)
self.contents = Bitmap.new(@width_2, @height_2)
self.contents.font.name = $defaultfonttype
self.contents.font.size = $defaultfontsize
self.index = startindex
refresh
end
def startup(align, side, commands, focus, disabled)
@focus = (focus - 1) #to solve a graphical error this was done.
@commands = commands
@align = align
check_align # verify and convert the value of @align
set_spacing (side) #set the window sizes based on what type of menu we're using
@disabled = disabled
@com = @commands.size
@com -= 1#a graphical bug prevention step
return
end
def refresh
self.contents.clear
if @align == 0 #if using a verticle menu use the appropriate method
for i in -1...@com# again a step to prevent a graphical bug
draw_item_vert(i, normal_color)
end
elsif @align == 1 #and use the appropriate method if using a horizontal menu
for i in -1...@com #graphical bug prevention
draw_item_horz(i, normal_color)
end
end
end
def set_spacing(side)
# if verticle, make the heigth determined by the # of options, and the width by the spare side variable
if @align == 0
@height = @commands.size*32 - 32
@width = side
@height_2 = @commands.size*32 - 64
@width_2 = side - 32
#and vica versa for the horizontal menu.
elsif @align == 1
old_size = @commands[1].size # just to make it not nil
for i in @commands
if i.size >= old_size
old_size = i.size
end
end
@size = old_size * HORZ_SPACING
@height = side
@width = @commands.size*(@size) - ((@size*(3.0/2.0)).abs)
@height_2 = side - 32
@width_2 = @width - 32
horz_offset_temp=[((@size)*0.25), ((@size)*0.50), ((@size)*0.75)]
@horz_offset = horz_offset_temp.each { |x| x.abs }
end
end
#--------------------------------------------------------------------------
#-This method converts the strings to either 1 or 0 depending on the menu.
# 0 = Vertical menu
# 1 = Horizontal menu
#--------------------------------------------------------------------------
def check_align
if @align == "vert"
@align = 0
elsif @align == "horz"
@align = 1
end
#debug script
if @align == 0
# print "vert"
elsif @align == 1
# print "horz"
else #if invalid input was found in @align, set to vertical menu.
# print "error"
@align = 0
end
end
#--------------------------------------------------------------------------
#-Animation routine for the verticle menu.
#--------------------------------------------------------------------------
def anim_vert(direction)
for a in [8, 16, 24] #1/4, 1/2, and 3/4 of the destination value
click = Graphics.frame_count
self.contents.clear# clear window to keep from streaking.
for i in -1...@com #again graphic bug prevention
offset_draw_item_vert(i, normal_color, direction * a) #Draw the animation.
end
Graphics.update until Graphics.frame_count >= click + SPEED
end
refresh # draw new placement of commands
end
#--------------------------------------------------------------------------
#-Animation routine for the Horizontal menu
#-Since the routine is different for the Vert & Horz menus, Anim is not merged;
#-But will be merged in future
#--------------------------------------------------------------------------
def anim_horz(direction)
for a in @horz_offset #<<1/4, 1/2, and 3/4 of the destination value
click = Graphics.frame_count
self.contents.clear
for i in -1...@com
offset_draw_item_horz(i, normal_color, direction * a) #Draw the animation
end
Graphics.update until Graphics.frame_count >= click + SPEED
end
refresh
end
#--------------------------------------------------------------------------
#-This method draws the menu items for the Horizontal menu.
#--------------------------------------------------------------------------
def draw_item_horz(index, color)
nindex = (index - @focus + [@index, 0].max) % @commands.size
self.contents.font.color = @disabled.include?(nindex) ? disabled_color : normal_color
rect = Rect.new((@size)* index, 4, (@size), self.contents.height - 8)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
self.contents.draw_text(rect, @commands[nindex])
end
#--------------------------------------------------------------------------
#-This method draws the menu items for the Vertical menu
#--------------------------------------------------------------------------
def draw_item_vert(index, color)# no need to explain this method yet, willdo that later. happy.gif *is tired*
nindex = (index - @focus + [@index, 0].max) % @commands.size
self.contents.font.color = @disabled.include?(nindex) ? disabled_color : normal_color
rect = Rect.new(4, 32 * index, self.contents.width - 8, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
self.contents.draw_text(rect, @commands[nindex])
end
#--------------------------------------------------------------------------
#This method draws the Verticle menu for the animation routine
#--------------------------------------------------------------------------
def offset_draw_item_vert(index, color, offset)
trip = offset == offset.abs ? 1 : -1
nindex = ((index + trip) - @focus + [@index, 0].max) % @commands.size
self.contents.font.color = @disabled.include?(nindex) ? disabled_color : normal_color
rect = Rect.new(4, (32 * index) + offset, self.contents.width - 8, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
self.contents.draw_text(rect, @commands[nindex])
end
#--------------------------------------------------------------------------
#-This method draws the Horizontal menu for the animation routine
#--------------------------------------------------------------------------
def offset_draw_item_horz(index, color, offset)
trip = offset == offset.abs ? 1 : -1
nindex = ((index + trip) - @focus + [@index, 0].max) % @commands.size
self.contents.font.color = @disabled.include?(nindex) ? disabled_color : normal_color
rect = Rect.new(((@size)* index) + offset, 4, (@size), self.contents.height - 8)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
self.contents.draw_text(rect, @commands[nindex])
end
#--------------------------------------------------------------------------
#-Simple disable option.
#--------------------------------------------------------------------------
def disable_item(index)
@disabled.push(index)
refresh
end
#--------------------------------------------------------------------------
#-Simple enable option.
#--------------------------------------------------------------------------
def enable_item(index)
@disabled.delete(index)
refresh
end
#--------------------------------------------------------------------------
#-The index method
#--------------------------------------------------------------------------
def index=(index)
@index = index
if @index >= @commands.size
@index = 0
end
if @index < 0
@index = @commands.size - 1
end
if self.active and @help_window != nil
update_help
end
update_cursor_rect
end
#--------------------------------------------------------------------------
#-The help_window method. Used the same way as the one in Window_Selectable
#--------------------------------------------------------------------------
def help_window=(help_window)
@help_window = help_window
if self.active and @help_window != nil
update_help
end
end
#--------------------------------------------------------------------------
#-Draws the cursor in proportion to the size of the window
#--------------------------------------------------------------------------
def update_cursor_rect
if @focus < 0
self.cursor_rect.empty
return
end
if @align == 0
cursor_width = self.width - 32
y = @focus * 32 - self.oy
self.cursor_rect.set(0, y, cursor_width, 32)
elsif @align == 1
cursor_height = self.height - 32
x = (@focus * (@size) - self.ox - 6)
self.cursor_rect.set(x, 0, (@size), cursor_height)
end
end
#--------------------------------------------------------------------------
#-The update routine for the menus
#--------------------------------------------------------------------------
def update
super
if self.active and @commands.size > 0 and @index >= 0
if @align == 0
if Input.repeat?(Input::DOWN)
$game_system.se_play($data_system.cursor_se)
self.index += 1
anim_vert(-1)
end
if Input.repeat?(Input::UP)
$game_system.se_play($data_system.cursor_se)
self.index -= 1
anim_vert(1)
end
elsif @align == 1
if Input.repeat?(Input::RIGHT)
$game_system.se_play($data_system.cursor_se)
self.index += 1
anim_horz(-1)
end
if Input.repeat?(Input::LEFT)
$game_system.se_play($data_system.cursor_se)
self.index -= 1
anim_horz(1)
end
end
end
if self.active and @help_window != nil
update_help
end
update_cursor_rect
refresh
end
#end update-------------------------------------------------------
end
#end class
class Game_Actor < Game_Battler
def now_exp
return @exp - @exp_list[@level]
end
def next_exp
return @exp_list[@level+1] > 0 ? @exp_list[@level+1] - @exp_list[@level] : 0
end
end
class Window_Base < Window
alias :draw_actor_hp_original :draw_actor_hp
def draw_actor_hp(actor, x, y, width = 144)
if actor.maxhp != 0
rate = actor.hp.to_f / actor.maxhp
else
rate = 0
end
plus_x = 0
rate_x = 0
plus_y = 25
plus_width = 0
rate_width = 100
height = 10
align1 = 1
align2 = 2
align3 = 0
grade1 = 1
grade2 = 0
color1 = Color.new(0, 0, 0, 50)
color2 = Color.new(255, 255, 192, 192)
color3 = Color.new(0, 0, 0, 50)
color4 = Color.new(64, 0, 0, 50)
color5 = Color.new(216 - 24 * rate, 0 * rate, 0 * rate, 192)
color6 = Color.new(255 * rate, 215 * rate, 0 * rate, 192)
if actor.maxhp != 0
hp = (width + plus_width) * actor.hp * rate_width / 100 / actor.maxhp
else
hp = 0
end
gauge_rect(x + plus_x + width * rate_x / 100, y + plus_y,
width, plus_width + width * rate_width / 100,
height, hp, align1, align2, align3,
color1, color2, color3, color4, color5, color6, grade1, grade2)
draw_actor_hp_original(actor, x, y, width)
end
alias :draw_actor_sp_original :draw_actor_sp
def draw_actor_sp(actor, x, y, width = 144)
# ��?�rate�� ��?݂�SP/MSP����
if actor.maxsp != 0
rate = actor.sp.to_f / actor.maxsp
else
rate = 1
end
plus_x = 0
rate_x = 0
plus_y = 25
plus_width = 0
rate_width = 100
height = 10
align1 = 1
align2 = 2
align3 = 0
grade1 = 1
grade2 = 0
color1 = Color.new(0, 0, 0, 192)
color2 = Color.new(255, 255, 192, 192)
color3 = Color.new(0, 0, 0, 192)
color4 = Color.new(0, 64, 0, 192)
color5 = Color.new(14 * rate, 80 - 24 * rate, 80 * rate, 192)
color6 = Color.new(62 * rate, 240 - 72 * rate, 240 * rate, 192)
if actor.maxsp != 0
sp = (width + plus_width) * actor.sp * rate_width / 100 / actor.maxsp
else
sp = (width + plus_width) * rate_width / 100
end
gauge_rect(x + plus_x + width * rate_x / 100, y + plus_y,
width, plus_width + width * rate_width / 100,
height, sp, align1, align2, align3,
color1, color2, color3, color4, color5, color6, grade1, grade2)
draw_actor_sp_original(actor, x, y, width)
end
alias :draw_actor_exp_original :draw_actor_exp
def draw_actor_exp(actor, x, y, width = 204)
if actor.next_exp != 0
rate = actor.now_exp.to_f / actor.next_exp
else
rate = 1
end
plus_x = 0
rate_x = 0
plus_y = 25
plus_width = 0
rate_width = 100
height = 10
align1 = 1
align2 = 2
align3 = 0
# �O���f?[�V����?ݒ� grade1:��Q?[�W grade2:��Q?[�W
# (0:���ɃO���f?[�V���� 1:?c�ɃO���f?[�V���� 2:�߂ɃO���f?[�V����(��?d)?j
grade1 = 1
grade2 = 0
# ?F?ݒ�?Bcolor1:�O�g?Ccolor2:���g
# color3:��Q?[�W�_?[�N�J��?[?Ccolor4:��Q?[�W���C�g�J��?[
# color5:��Q?[�W�_?[�N�J��?[?Ccolor6:��Q?[�W���C�g�J��?[
color1 = Color.new(0, 0, 0, 192)
color2 = Color.new(255, 255, 192, 192)
color3 = Color.new(0, 0, 0, 192)
color4 = Color.new(64, 0, 0, 192)
color5 = Color.new(80 - 24 * rate, 80 * rate, 14 * rate, 192)
color6 = Color.new(240 - 72 * rate, 240 * rate, 62 * rate, 192)
# ��?�exp�ɕ`�悷��Q?[�W�̕?����
if actor.next_exp != 0
exp = (width + plus_width) * actor.now_exp * rate_width /
100 / actor.next_exp
else
exp = (width + plus_width) * rate_width / 100
end
# �Q?[�W�̕`��
gauge_rect(x + plus_x + width * rate_x / 100, y + plus_y,
width, plus_width + width * rate_width / 100,
height, exp, align1, align2, align3,
color1, color2, color3, color4, color5, color6, grade1, grade2)
# �I���W�i����EXP�`��?��?���?o��
draw_actor_exp_original(actor, x, y)
end
#--------------------------------------------------------------------------
# ?� �Q?[�W�̕`��
#--------------------------------------------------------------------------
def gauge_rect(x, y, rect_width, width, height, gauge, align1, align2, align3,
color1, color2, color3, color4, color5, color6, grade1, grade2)
case align1
when 1
x += (rect_width - width) / 2
when 2
x += rect_width - width
end
case align2
when 1
y -= height / 2
when 2
y -= height
end
# �g�`��
self.contents.fill_rect(x, y, width, height, color1)
self.contents.fill_rect(x + 1, y + 1, width - 2, height - 2, color2)
if align3 == 0
if grade1 == 2
grade1 = 3
end
if grade2 == 2
grade2 = 3
end
end
if (align3 == 1 and grade1 == 0) or grade1 > 0
color = color3
color3 = color4
color4 = color
end
if (align3 == 1 and grade2 == 0) or grade2 > 0
color = color5
color5 = color6
color6 = color
end
# ��Q?[�W�̕`��
self.contents.gradation_rect(x + 2, y + 2, width - 4, height - 4,
color3, color4, grade1)
if align3 == 1
x += width - gauge
end
# ��Q?[�W�̕`��
self.contents.gradation_rect(x + 2, y + 2, gauge - 4, height - 4,
color5, color6, grade2)
end
end
#------------------------------------------------------------------------------
# ?@Bitmap�N���X��?V���ȋ@�\��lj���܂�?B
#==============================================================================
class Bitmap
#--------------------------------------------------------------------------
# ?� ��`��O���f?[�V�����\��
# color1 : �X�^?[�g�J��?[
# color2 : �G���h�J��?[
# align : 0:���ɃO���f?[�V����
# 1:?c�ɃO���f?[�V����
# 2:�߂ɃO���f?[�V����?i��?d�ɂ��?��?j
#--------------------------------------------------------------------------
def gradation_rect(x, y, width, height, color1, color2, align = 0)
if align == 0
for i in x...x + width
red = color1.red + (color2.red - color1.red) * (i - x) / (width - 1)
green = color1.green +
(color2.green - color1.green) * (i - x) / (width - 1)
blue = color1.blue +
(color2.blue - color1.blue) * (i - x) / (width - 1)
alpha = color1.alpha +
(color2.alpha - color1.alpha) * (i - x) / (width - 1)
color = Color.new(red, green, blue, alpha)
fill_rect(i, y, 1, height, color)
end
elsif align == 1
for i in y...y + height
red = color1.red +
(color2.red - color1.red) * (i - y) / (height - 1)
green = color1.green +
(color2.green - color1.green) * (i - y) / (height - 1)
blue = color1.blue +
(color2.blue - color1.blue) * (i - y) / (height - 1)
alpha = color1.alpha +
(color2.alpha - color1.alpha) * (i - y) / (height - 1)
color = Color.new(red, green, blue, alpha)
fill_rect(x, i, width, 1, color)
end
elsif align == 2
for i in x...x + width
for j in y...y + height
red = color1.red + (color2.red - color1.red) *
((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
green = color1.green + (color2.green - color1.green) *
((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
blue = color1.blue + (color2.blue - color1.blue) *
((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
alpha = color1.alpha + (color2.alpha - color1.alpha) *
((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
color = Color.new(red, green, blue, alpha)
set_pixel(i, j, color)
end
end
elsif align == 3
for i in x...x + width
for j in y...y + height
red = color1.red + (color2.red - color1.red) *
((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
green = color1.green + (color2.green - color1.green) *
((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
blue = color1.blue + (color2.blue - color1.blue) *
((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
alpha = color1.alpha + (color2.alpha - color1.alpha) *
((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
color = Color.new(red, green, blue, alpha)
set_pixel(i, j, color)
end
end
end
end
end
#==============================================================================
# ?� Sprite���W��?[��
#------------------------------------------------------------------------------
# ?@�A�j�??[�V�����̊Ǘ?��?s�����W��?[���ł�?B
#==============================================================================
module RPG
class Sprite < ::Sprite
def damage(value, critical)
dispose_damage
if value.is_a?(Numeric)
damage_string = value.abs.to_s
else
damage_string = value.to_s
end
bitmap = Bitmap.new(160, 48)
bitmap.font.name = "Arial Black"
bitmap.font.size = 32
bitmap.font.color.set(0, 0, 0)
bitmap.draw_text(-1, 12-1, 160, 36, damage_string, 1)
bitmap.draw_text(+1, 12-1, 160, 36, damage_string, 1)
bitmap.draw_text(-1, 12+1, 160, 36, damage_string, 1)
bitmap.draw_text(+1, 12+1, 160, 36, damage_string, 1)
if value.is_a?(Numeric) and value < 0
bitmap.font.color.set(176, 255, 144)
else
bitmap.font.color.set(255, 255, 255)
end
bitmap.draw_text(0, 12, 160, 36, damage_string, 1)
if critical
bitmap.font.size = 20
bitmap.font.color.set(0, 0, 0)
bitmap.draw_text(-1, -1, 160, 20, "CRITICAL", 1)
bitmap.draw_text(+1, -1, 160, 20, "CRITICAL", 1)
bitmap.draw_text(-1, +1, 160, 20, "CRITICAL", 1)
bitmap.draw_text(+1, +1, 160, 20, "CRITICAL", 1)
bitmap.font.color.set(255, 255, 255)
bitmap.draw_text(0, 0, 160, 20, "CRITICAL", 1)
end
@_damage_sprite = ::Sprite.new
@_damage_sprite.bitmap = bitmap
@_damage_sprite.ox = 80 + self.viewport.ox
@_damage_sprite.oy = 20 + self.viewport.oy
@_damage_sprite.x = self.x + self.viewport.rect.x
@_damage_sprite.y = self.y - self.oy / 2 + self.viewport.rect.y
@_damage_sprite.z = 3000
@_damage_duration = 40
end
def animation(animation, hit)
dispose_animation
@_animation = animation
return if @_animation == nil
@_animation_hit = hit
@_animation_duration = @_animation.frame_max
animation_name = @_animation.animation_name
animation_hue = @_animation.animation_hue
bitmap = RPG::Cache.animation(animation_name, animation_hue)
if @@_reference_count.include?(bitmap)
@@_reference_count[bitmap] += 1
else
@@_reference_count[bitmap] = 1
end
@_animation_sprites = []
if @_animation.position != 3 or not @@_animations.include?(animation)
for i in 0..15
sprite = ::Sprite.new
sprite.bitmap = bitmap
sprite.visible = false
@_animation_sprites.push(sprite)
end
unless @@_animations.include?(animation)
@@_animations.push(animation)
end
end
update_animation
end
def loop_animation(animation)
return if animation == @_loop_animation
dispose_loop_animation
@_loop_animation = animation
return if @_loop_animation == nil
@_loop_animation_index = 0
animation_name = @_loop_animation.animation_name
animation_hue = @_loop_animation.animation_hue
bitmap = RPG::Cache.animation(animation_name, animation_hue)
if @@_reference_count.include?(bitmap)
@@_reference_count[bitmap] += 1
else
@@_reference_count[bitmap] = 1
end
@_loop_animation_sprites = []
for i in 0..15
sprite = ::Sprite.new
sprite.bitmap = bitmap
sprite.visible = false
@_loop_animation_sprites.push(sprite)
end
update_loop_animation
end
def animation_set_sprites(sprites, cell_data, position)
for i in 0..15
sprite = sprites[i]
pattern = cell_data[i, 0]
if sprite == nil or pattern == nil or pattern == -1
sprite.visible = false if sprite != nil
next
end
sprite.visible = true
sprite.src_rect.set(pattern % 5 * 192, pattern / 5 * 192, 192, 192)
if position == 3
if self.viewport != nil
sprite.x = self.viewport.rect.width / 2
sprite.y = self.viewport.rect.height - 160
else
sprite.x = 320
sprite.y = 240
end
else
sprite.x = self.x + self.viewport.rect.x -
self.ox + self.src_rect.width / 2
sprite.y = self.y + self.viewport.rect.y -
self.oy + self.src_rect.height / 2
sprite.y -= self.src_rect.height / 4 if position == 0
sprite.y += self.src_rect.height / 4 if position == 2
end
sprite.x += cell_data[i, 1]
sprite.y += cell_data[i, 2]
sprite.z = 2000
sprite.ox = 96
sprite.oy = 96
sprite.zoom_x = cell_data[i, 3] / 100.0
sprite.zoom_y = cell_data[i, 3] / 100.0
sprite.angle = cell_data[i, 4]
sprite.mirror = (cell_data[i, 5] == 1)
sprite.opacity = cell_data[i, 6] * self.opacity / 255.0
sprite.blend_type = cell_data[i, 7]
end
end
end
end