Code:
# Picture Add-On Option
# by Angelix
# สำหรับ RMXP
#
# วางไว้เหนือ Main
# วิธีใช้ : Call Script ก่อนใช้งานรูปภาพ โดยใช้ pic(เลขภาพ).คำสั่ง = ค่า
#
# คำสั่ง: fix_position ค่า: true/false ผล: ตรึงภาพไว้บนแม็ป ไม่ให้เลื่อนตามแม็ป
# คำสั่ง: flip ค่า: true/false ผล: พลิกภาพ(หรือไม่พลิก)
#=================================================================
class Game_Picture
attr_accessor :fix_position
attr_accessor :flip
alias ang_ori_pic_fix initialize
def initialize(number)
ang_ori_pic_fix(number)
@fix_position = false
@current_dx = 0
@current_dy = 0
@flip = false
end
alias ang_ori_pic_fix_show show
def show(name, origin, x, y, zoom_x, zoom_y, opacity, blend_type)
ang_ori_pic_fix_show(name, origin, x, y, zoom_x, zoom_y, opacity, blend_type)
if $game_map.nil? == false
@x = @x.to_f - $game_map.display_x.to_f
@y = @y.to_f - $game_map.display_y.to_f
end
end
alias ang_ori_pic_fix_move move
def move(duration, origin, x, y, zoom_x, zoom_y, opacity, blend_type)
ang_ori_pic_fix_move(duration, origin, x, y, zoom_x, zoom_y, opacity, blend_type)
if $game_map.nil? == false
@target_x = @target_x.to_f - $game_map.display_x.to_f
@target_y = @target_y.to_f - $game_map.display_y.to_f
@current_dx = $game_map.display_x.to_f
@current_dy = $game_map.display_y.to_f
end
end
alias ang_ori_pic_fix_upd update
def update
if @fix_position == false
ang_ori_pic_fix_upd
return
end
dx = $game_map.display_x.to_f - @current_dx
dy = $game_map.display_y.to_f - @current_dy
@current_dx = $game_map.display_x.to_f
@current_dy = $game_map.display_y.to_f
if @duration >= 1
d = @duration
@x = (@x * (d - 1) + @target_x) / d - dx
@y = (@y * (d - 1) + @target_y) / d - dy
@zoom_x = (@zoom_x * (d - 1) + @target_zoom_x) / d
@zoom_y = (@zoom_y * (d - 1) + @target_zoom_y) / d
@opacity = (@opacity * (d - 1) + @target_opacity) / d
@duration -= 1
end
if @tone_duration >= 1
d = @tone_duration
@tone.red = (@tone.red * (d - 1) + @tone_target.red) / d
@tone.green = (@tone.green * (d - 1) + @tone_target.green) / d
@tone.blue = (@tone.blue * (d - 1) + @tone_target.blue) / d
@tone.gray = (@tone.gray * (d - 1) + @tone_target.gray) / d
@tone_duration -= 1
end
if @rotate_speed != 0
@angle += @rotate_speed / 2.0
while @angle < 0
@angle += 360
end
@angle %= 360
end
end
end
class Sprite_Picture < Sprite
alias ang_flippic_sprpic_upd update
def update
ang_flippic_sprpic_upd
self.mirror = @picture.flip
end
end
class Interpreter
def pic(number)
return $game_screen.pictures[number]
end
end