不用API就可以啊~
class << Graphics alias n_update update end module Graphics @rf = 0.0 @fps = Graphics.frame_rate @uptime = Time.now def self.update @rf = @rf + 1.0 tmp=Time.now if tmp-@uptime>=0.5 then @fps=@rf/(tmp-@uptime) @rf=0 @uptime=tmp end print "FPS:" print getFPS print "\n" n_update end def self.getFPS @fps end end
class << Graphics
alias n_update update
end
module Graphics
@rf = 0.0
@fps = Graphics.frame_rate
@uptime = Time.now
def self.update
@rf = @rf + 1.0
tmp=Time.now
if tmp-@uptime>=0.5 then
@fps=@rf/(tmp-@uptime)
@rf=0
@uptime=tmp
end
print "FPS:"
print getFPS
print "\n"
n_update
end
def self.getFPS
@fps
end
end
|