本帖最后由 zhangbanxian 于 2012-11-24 14:58 编辑
- -b好绕的脚本,然后原来字符串可以写成这样吗,call什么的原来可以省略吗(我竟然被蒙在鼓里这么久)orz...
然后,貌似是漏写了一个.to_s,method_missing用多了,bug果然不好找...
class API def initialize(dll) @dll = dll.to_s end def method_missing sym, *a Win32API.new(@dll, sym.to_s, a.map{|x|x.is_a?(Integer) ? ?i: ?p}, ?i).(*a) end end def method_missing(sym) x = API.new(sym) define_singleton_method sym, lambda{x} x end $plane = Sprite.new $plane.bitmap = Bitmap.new Graphics.width, Graphics.height def readkey user32.GetKeyboardState $buf="\0"*256 end module Game def self.update a = $buf readkey p $buf.unpack("c*") if a != $buf end end loop do Graphics.update Game.update end
class API
def initialize(dll)
@dll = dll.to_s
end
def method_missing sym, *a
Win32API.new(@dll, sym.to_s, a.map{|x|x.is_a?(Integer) ? ?i: ?p}, ?i).(*a)
end
end
def method_missing(sym)
x = API.new(sym)
define_singleton_method sym, lambda{x}
x
end
$plane = Sprite.new
$plane.bitmap = Bitmap.new Graphics.width, Graphics.height
def readkey
user32.GetKeyboardState $buf="\0"*256
end
module Game
def self.update
a = $buf
readkey
p $buf.unpack("c*") if a != $buf
end
end
loop do
Graphics.update
Game.update
end
|