自己常用的方法记录
def count_dataevents(from, to, a, b, name)
num = 0
(from..to).each do |id|
data_test = load_data(sprintf("Data/Information%03d.rbdata", id))
c = {}
for i in data_test.events.keys
c[i] = Data_Event.new(id, data_test.events[i])
num += 1 if c[i].name[a,b] == name
end
end
print "#{name.to_s} * #{num.to_s}"
end
————————————————————————————
def test_find
$test1 = []
$test2 = []
for i in 0...$test1.size
for j in i...$test1.size
if $test2[i] > $test2[j]
temp = $test2[i]
temp2 = $test1[i]
$test2[i] = $test2[j]
$test1[i] = $test1[j]
$test2[j] = temp
$test1[j] = temp2
end
end
end
end
————————————————————————————
def range_judge
xx = (event.x - $data_player.x).abs
yy = (event.y - $data_player.y).abs
if (xx == 1 and yy < 1) or (xx < 1 and yy == 1)
end
end
————————————————————————————
def round(x,y)
x = (x*(10**y)).to_i
x = x/1.0
x = x/(10**y)
return x
end
—————————————
def ceiling(x)
if x == x.to_i
return x.to_i
else
return x.to_i+1
end
end