| 赞 | 2 |
| VIP | |
| 好人卡 | |
| 积分 | 1 |
| 经验 | |
| 最后登录 | 2019-5-30 |
| 在线时间 | 270 小时 |
- 梦石
- 0
- 星屑
- 50
- 在线时间
- 270 小时
- 注册时间
- 2010-2-4
- 回帖
- 1296
|
发表于 2012-11-24 14:45:39
|
显示全部楼层
本帖最后由 zhangbanxian 于 2012-11-24 14:58 编辑
- -b好绕的脚本,然后原来字符串可以写成这样吗,call什么的原来可以省略吗(我竟然被蒙在鼓里这么久)orz...
然后,貌似是漏写了一个.to_s,method_missing用多了,bug果然不好找...
[pre lang="ruby" line="1"]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[/pre] |
评分
-
查看全部评分
|