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