# @taroxd metadata 1.0
# @display 坐标类
# @id point
#
# 该类的作用是表示一个地图上的点的坐标
# 可以伪装成 Game_Character 的对象传给一些接受 character 参数的方法。
module Taroxd
Point = Struct.new(:x, :y) do
alias_method :real_x, :x
alias_method :real_y, :y
def moveto(x, y)
self.x = x
self.y = y
end
def pos?(x2, y2)
x == x2 && y == y2
end
def same_pos?(other)
x == other.x && y == other.y
end
def screen_x
$game_map.adjust_x(x) * 32 + 16
end
def screen_y
$game_map.adjust_y(y) * 32 + 32
end
end
end
坐标类
图片跟随地图移动
# @taroxd metadata 1.0
# @id picture_with_map
# @display 图片跟随地图移动
# @require taroxd_core
# @help 编号大于 50 的图片会跟随地图移动。
Taroxd::PictureWithMap = true
class Game_Picture
# 图片是否随地图移动
def move_with_map?
@number > 50
end
def_with :x do |old|
move_with_map? ? $game_map.adjust_x(old / 32.0) * 32 : old
end
def_with :y do |old|
move_with_map? ? $game_map.adjust_y(old / 32.0) * 32 : old
end
end
计步器
# @taroxd metadata 1.0
# @id pedometer
# @display 计步器
# @require taroxd_core
# 事件脚本
# start_pedometer(var_id[, count])
# 变量 var_id 开始计步。若 count 存在,将该变量设为 count。
#
# stop_pedometer([var_id])
# 变量 var_id 停止计步。若 var_id 不存在,则停止所有计步器。
Taroxd::Pedometer = true
class Game_Party < Game_Unit
def_after(:initialize) { @pedometer = [] }
def start_pedometer(var_id, count = nil)
@pedometer << var_id unless @pedometer.include?(var_id)
$game_variables[var_id] = count if count
end
def stop_pedometer(var_id = nil)
var_id ? @pedometer.delete(var_id) : @pedometer.clear
end
def_after :on_player_walk do
@pedometer.each { |var_id| $game_variables[var_id] += 1 }
end
end
class Game_Interpreter
def start_pedometer(var_id, count = nil)
$game_party.start_pedometer(var_id, count)
end
def stop_pedometer(var_id = nil)
$game_party.stop_pedometer(var_id)
end
end