老实说,学会这个并不会让你的游戏怎么样……
还是多花点心思做好游戏本体吧。
# 使用方法: # set_window(x, y) # 设置窗口位置到(x, y),从屏幕左上角开始计算 if !defined?(user32) def user32(function, arg_types, return_value_type) Win32API.new("user32.dll", function, arg_types, return_value_type) end end GetForegroundWindow = user32("GetForegroundWindow", "", "L") SetWindowPos = user32("SetWindowPos", ["L"] * 7, 'i') $hwnd = GetForegroundWindow.call def set_window(x, y) SetWindowPos.call($hwnd, 0, x, y, Graphics.width, Graphics.height, 0) end
# 使用方法:
# set_window(x, y)
# 设置窗口位置到(x, y),从屏幕左上角开始计算
if !defined?(user32)
def user32(function, arg_types, return_value_type)
Win32API.new("user32.dll", function, arg_types, return_value_type)
end
end
GetForegroundWindow = user32("GetForegroundWindow", "", "L")
SetWindowPos = user32("SetWindowPos", ["L"] * 7, 'i')
$hwnd = GetForegroundWindow.call
def set_window(x, y)
SetWindowPos.call($hwnd, 0, x, y, Graphics.width, Graphics.height, 0)
end
|