设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 5469|回复: 16
打印 上一主题 下一主题

[RMVX发布] RPGVX -> RGE 兼容层【用RGE来运行VX工程】(2011-6-18更新)

[复制链接]

Lv2.观梦者 (管理员)

八云紫的式神

梦石
0
星屑
549
在线时间
1243 小时
注册时间
2008-1-1
帖子
4282

烫烫烫

跳转到指定楼层
1
发表于 2011-6-6 08:35:26 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有帐号?注册会员

x
#==============================================================================
# ★ RGE -> RPGVX 兼容层
#------------------------------------------------------------------------------
# 提供RGSS2内置库在RGE上的实现,使可以用RGE引擎运行RPGVX脚本
#   by zh99998 2011-6-18
#   special thanks 八云紫, IamI, 灼眼的夏娜, kissye, David07, 一箭烂YiJL
#------------------------------------------------------------------------------
# Game.ini 参数说明
#
# [Setting]
# Library=RGE\RGE.dll       RGE.dll所在位置
# Scripts=RGE\main.rges     main.rges所在位置
# Width=544                 窗口宽度
# Height=416                窗口高度
# FPS=60                    默认帧率
# F2=1                      是否允许F2显示帧率 0: 禁止, 1:允许
# F12=2                     是否允许F12重启    0: 禁止, 1:使用重新执行脚本的方式重启, 2: 使用重开Game.exe的方式重启
#
#------------------------------------------------------------------------------
# 已知以下功能尚未实现
#  Bitmap#blur                什么都不做
#  Sprite#wave_***            仅储存
#  Sprite#viewport=           仅储存
#  Window#viewport            什么都不做
#  Window#openness            用透明度近似实现
#  Graphics.resize_screen     什么都不做
#  不支持VX-windowskin的栅格遮挡效果
#  声音、画面淡出时 没有渐变效果
#  Input按键码常量与VX不相同,在外部使用而不作为Input.trigger/repeat/press?的参数可能会出错
#  Input.repeat?间隔是常量而不是读取系统设置
#  不支持更换Game.exe及Game.ini的名字
#------------------------------------------------------------------------------
# 更新日志
#  2011-6-18 v1.0 兼容层脚本全部搬进RGE里,保持原本的VX工程
#                 加入F2显示帧数和F12重启功能
#                 分辨率、标题、是否允许F2和F12、默认帧率通过Game.ini来设置
#                 加入Input按键码修正
#                 Input.repeat?间隔修正,在默认系统配置和帧率情况下与VX保持一致
#                 字体阴影换用D7的,跟VX的阴影更像
#                 默认帧率调整至60
#                 Bitmap#clear_rect支持x, y, width, height方式的参数
#
#  2011-6-6  v0.2 加入夏娜RGE - RMXP 运行补丁并修改适用于VX
#                 Window#openness仍然使用透明度,但是做了转接,可以正常使用透明度了
#                 Window#windowskin转接完成,可以使用XP或VX的windowskin
#                 去除在RGSS类定义后进行的修正,全都放在最开始执行,避免冲突
#                 分辨率可以在RM脚本内进行定义
#
#  2011-6-4  v0.1 雏形
#
#==============================================================================


下载: VX-RGE.zip (979.47 KB, 下载次数: 443)

截图:


可以直接基于这个用RPGVX写新工程,也可以把这个整合到自己的工程中
整合方法:
使用前请做好原工程的备份,以防数据损失

解压附件,把解压出的RGE文件夹,Game.exe,Game.ini,复制到自己的工程下 覆盖文件
(如果您的工程有在Game.ini里添加内容,请打开附件内Game.ini 最后三行复制到自己的ini里也可以)
(如果是用的ini替换,请手动改回原来的游戏标题)


有bug或建议请跟帖回复
在脚本说明里已经提到的已知bug就不用说了

点评

Bitmap#blur、Bitmap#gradient_fill_rect............这些呢= =  发表于 2011-6-10 17:50
rm for linux(wine)制作中,期待夏娜SAMA能实现到webrm上

Lv2.观梦者

傻♂逼

梦石
0
星屑
369
在线时间
1605 小时
注册时间
2007-3-13
帖子
6562

烫烫烫开拓者

2
发表于 2011-6-6 08:50:20 | 只看该作者
没用用的……RGE的Plane和Viewport有BUG 就是有BUG……
哎呀,蛋疼什么的最有爱了
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
33 小时
注册时间
2009-12-22
帖子
82
3
发表于 2011-6-6 09:06:21 | 只看该作者
zh喵好厉害~~vx提出脚本编辑器有一个优势在于ogg标记循环~我一直想要的~~现在我也能改脚本了~~谢谢啦~~~ >v<

点评

貌似没用啊....虽然脚本是VX的,但是引擎是RGE....  发表于 2011-6-6 09:34
おれは女の子の夢と幸せのために存在するのだ!
回复 支持 反对

使用道具 举报

Lv4.逐梦者

梦石
0
星屑
6645
在线时间
1666 小时
注册时间
2008-10-29
帖子
6710

贵宾

4
发表于 2011-6-6 11:30:25 | 只看该作者
tilemap 怎么做的?

那个画面的淡入淡出RGE本来就没有= =

点评

Kissye的  发表于 2011-6-6 12:11











你知道得太多了

回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
1249
在线时间
669 小时
注册时间
2009-11-11
帖子
2787
5
发表于 2011-6-6 17:22:09 | 只看该作者
那是不是能用reg开发VX游戏了,功能很强大的样子

嘿。嘿。嘿
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
462 小时
注册时间
2007-7-30
帖子
643
6
发表于 2011-6-6 18:03:12 | 只看该作者
把ZH抓来做RGE兼容层 XD
RGE这万年大坑 啥时填起来@@

回复 支持 反对

使用道具 举报

Lv1.梦旅人

炎发灼眼的讨伐者

梦石
0
星屑
50
在线时间
1707 小时
注册时间
2007-8-4
帖子
904
7
发表于 2011-6-7 12:39:26 | 只看该作者
萌娘辛苦了....><(大雾
RMXP&amp;RMVX通用Web化完成- -|||
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
341 小时
注册时间
2008-3-16
帖子
372

贵宾第6届短篇游戏比赛冠军

8
发表于 2011-6-7 13:21:34 | 只看该作者
已经解决了吗 好神奇的ZH  ·····  bitmap Plane 等一些BUG最好还是给大家列个使用说明啊 ······  还有中文文件名不支持那些··········

新浪微博求粉丝    http://weibo.com/foxzu
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
23 小时
注册时间
2010-6-17
帖子
58
9
发表于 2011-6-7 15:36:55 | 只看该作者
路过,支持大萌娘- -
回复 支持 反对

使用道具 举报

Lv3.寻梦者

弓箭手?剑兰

梦石
0
星屑
4854
在线时间
833 小时
注册时间
2010-11-17
帖子
1140
10
发表于 2011-6-11 13:56:32 | 只看该作者
最初我是常驻VX,于是我放出几个我写的出来:
1. zh,我电脑那个 dll 无效...= =RGE 的 Bitmap 结构特殊,不能用<高速Marshal Bitmap>,所以我改:
  1. #==============================================================================
  2. # ■ Graphics
  3. #------------------------------------------------------------------------------
  4. #  进行有关全体图像处理的模块。
  5. #   RGE 的 Graphics.snap_to_bitmap。(和 XP 版有分别)
  6. #==============================================================================
  7. module Graphics
  8.   #--------------------------------------------------------------------------
  9.   # ● API 函数
  10.   #--------------------------------------------------------------------------
  11.   CreateDC = Win32API.new("gdi32", "CreateDC", "pppl", "l")
  12.   CreateCompatibleBitmap = Win32API.new("gdi32", "CreateCompatibleBitmap", "lll", "l")
  13.   CreateCompatibleDC = Win32API.new("gdi32", "CreateCompatibleDC", "l", "l")
  14.   SelectObject = Win32API.new("gdi32", "SelectObject", "ll", "l")
  15.   BitBlt = Win32API.new("gdi32", "BitBlt", "lllllllll", "l")
  16.   GetBitmapBits = Win32API.new("gdi32", "GetBitmapBits", "llp", "l")
  17.   ScreenToClient = Win32API.new("user32", "ScreenToClient", "ip", "i")
  18.   DeleteDC = Win32API.new("gdi32", "DeleteDC", "l", "l")
  19.   DeleteObject = Win32API.new("gdi32", "DeleteObject", "l", "l")
  20.   SRCCOPY = 0xCC0020
  21.   RtlMoveMemory = Win32API.new("kernel32", "RtlMoveMemory", "ipi", "i")
  22.   RtlMoveMemory_pi = Win32API.new("kernel32", "RtlMoveMemory", "pii", "i")
  23.   HWnd = Win32API.new("user32", "GetActiveWindow", nil, 'l').call
  24.   DwCount = (Frame.width * Frame.height * 4)# * 2
  25.   @@lpBits = "\000" * DwCount
  26.   #--------------------------------------------------------------------------
  27.   # ● snap_to_bitmap (RGE版)
  28.   #--------------------------------------------------------------------------
  29.   def self.snap_to_bitmap
  30.     hScrDC = CreateDC.call("DISPLAY", "", "", 0)
  31.     hMemDC = CreateCompatibleDC.call(hScrDC)
  32.     hBitmap = CreateCompatibleBitmap.call(hScrDC, width, height)
  33.     hOldBitmap = SelectObject.call(hMemDC, hBitmap)
  34.     win_pos = "\0\0\0\0\0\0\0\0"
  35.     ScreenToClient.call(HWnd, win_pos)
  36.     win_pos = win_pos.unpack("LL")
  37.     BitBlt.call(hMemDC, win_pos[0], win_pos[1], width*2, height*2, hScrDC, 0, 0, SRCCOPY)
  38.     hBitmap2 = SelectObject.call(hMemDC, hOldBitmap)
  39.     GetBitmapBits.call(hBitmap2, DwCount, @@lpBits)
  40.     # 释放所有东西
  41.     DeleteDC.call(hScrDC)
  42.     DeleteDC.call(hMemDC)
  43.     DeleteObject.call(hBitmap)
  44.     DeleteObject.call(hOldBitmap)
  45.     DeleteObject.call(hBitmap2)
  46.     rgbs = @@lpBits
  47.     len = width * 4
  48.     for y in 0...height
  49.       break if 2 * y >= height - 1
  50.       nth1 = y * len
  51.       nth2 = (height - 1 - y) * len
  52.       tStr = rgbs[nth1,len]
  53.       rgbs[nth1, len] = rgbs[nth2, len]
  54.       rgbs[nth2, len] = tStr
  55.     end
  56.     # 写 bmp 档案
  57.     length = Frame.width * Frame.height
  58.     file = File.open("cache.bmp", "wb")
  59.     size = 54 + Frame.width * Frame.height * 4
  60.     chunk1 = "BM" + [size].pack("L") + "\0\0\0\0\x36\0\0\0"
  61.     chunk2 = "\x28\0\0\0" + [Frame.width, Frame.height].pack("L2") +
  62.     "\1\0\x20\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
  63.     file.write(chunk1 + chunk2 + rgbs)
  64.     file.close
  65.     # 读取以及删掉档案
  66.     bitmap = Bitmap.new("cache.bmp")
  67.     File.delete("cache.bmp")
  68.     return bitmap
  69.   end
  70. end
复制代码
Font 的阴影还没下手,绘画阴影方面主要交给Bitmap了。Font:
  1. #==============================================================================
  2. # ■ Font
  3. #------------------------------------------------------------------------------
  4. #  兼容 RGE 而修改的 Font
  5. #==============================================================================
  6. class Font
  7.   #--------------------------------------------------------------------------
  8.   # ● 类变量
  9.   #--------------------------------------------------------------------------
  10.   @@default_shadow = true
  11.   #--------------------------------------------------------------------------
  12.   # ● 对象初始化
  13.   #--------------------------------------------------------------------------
  14.   alias font_init initialize
  15.   def initialize
  16.     font_init
  17.     @shadow = @@default_shadow
  18.   end
  19.   #--------------------------------------------------------------------------
  20.   # ● default_shadow
  21.   #--------------------------------------------------------------------------
  22.   def self.default_shadow
  23.     return @@default_shadow
  24.   end
  25.   #--------------------------------------------------------------------------
  26.   # ● default_shadow=
  27.   #--------------------------------------------------------------------------
  28.   def self.default_shadow=(bool)
  29.     return if bool != true or bool != false
  30.     @@default_shadow = bool
  31.   end
  32.   #--------------------------------------------------------------------------
  33.   # ● shadow
  34.   #--------------------------------------------------------------------------
  35.   def shadow
  36.     return @shadow
  37.   end
  38.   #--------------------------------------------------------------------------
  39.   # ● shadow=
  40.   #--------------------------------------------------------------------------
  41.   def shadow=(bool)
  42.     return if bool != true or bool != false
  43.     @shadow = bool
  44.   end
  45. end
复制代码
3.你那个clear_rect没有照顾clear_rect(x, y, width, height) 这种参数形式,还有字体阴影交给Bitmap:
  1. #==============================================================================
  2. # ■ Bitmap
  3. #------------------------------------------------------------------------------
  4. #   兼容 RGE 而修改的 Bitmap
  5. #==============================================================================
  6. class Bitmap
  7.   #--------------------------------------------------------------------------
  8.   # ● 填满渐变色彩 (RGSS2)
  9.   #--------------------------------------------------------------------------
  10.   def gradient_fill_rect(*arg)
  11.     arg = *arg
  12.     case arg[0]
  13.     when Rect
  14.       x = arg[0].x
  15.       y = arg[0].y
  16.       width = arg[0].width
  17.       height = arg[0].height
  18.       color1 = arg[1]
  19.       color2 = arg[2]
  20.       vertical = arg[3]
  21.     else
  22.       x = arg[0]
  23.       y = arg[1]
  24.       width = arg[2]
  25.       height = arg[3]
  26.       color1 = arg[4]
  27.       color2 = arg[5]
  28.       vertical = arg[6]
  29.     end
  30.     vertical = false if vertical.nil?
  31.     vertical == false ? step = width : step = height
  32.     color = color1;step += 0.0
  33.     key_re = (color2.red - color1.red) / step
  34.     key_gr = (color2.green - color1.green) / step
  35.     key_bl = (color2.blue - color1.blue) / step
  36.     red = color.red;green = color.green;blue = color.blue
  37.     x -= 1 unless vertical
  38.     y -= 1 if vertical
  39.     if vertical
  40.       for i in 0...height
  41.         y += 1
  42.         red += key_re;green += key_gr;blue += key_bl
  43.         color.red = red.to_i;color.green = green.to_i;color.blue = blue.to_i
  44.         self.fill_rect(x, y, width, 1, color)
  45.       end
  46.     else
  47.       for i in 0...width
  48.         x += 1
  49.         red += key_re;green += key_gr;blue += key_bl
  50.         color.red = red.to_i;color.green = green.to_i;color.blue = blue.to_i
  51.         self.fill_rect(x, y, 1, height, color)
  52.       end
  53.     end
  54.   end
  55.   #--------------------------------------------------------------------------
  56.   # ● clear_rect (RGSS2)
  57.   #--------------------------------------------------------------------------
  58.   def clear_rect(*arg)
  59.     arg = *arg
  60.     case arg
  61.     when Rect
  62.       x = arg.x
  63.       y = arg.y
  64.       width = arg.width
  65.       height = arg.height
  66.     else
  67.       x = arg[0]
  68.       y = arg[1]
  69.       width = arg[2]
  70.       height = arg[3]
  71.     end
  72.     self.fill_rect(x, y, width, height, Color.new(0, 0, 0, 0))
  73.   end
  74.   #--------------------------------------------------------------------------
  75.   # ● draw_text (RGSS2)
  76.   #--------------------------------------------------------------------------
  77.   alias shadow_draw_text draw_text
  78.   def draw_text(*arg)
  79.     arg = *arg
  80.     case arg[0]
  81.     when Rect
  82.       x = arg[0].x
  83.       y = arg[0].y
  84.       width = arg[0].width
  85.       height = arg[0].height
  86.       str = arg[1]
  87.       align = arg[2]
  88.     else
  89.       x = arg[0]
  90.       y = arg[1]
  91.       width = arg[2]
  92.       height = arg[3]
  93.       str = arg[4]
  94.       align = arg[5]
  95.     end
  96.     align = 0 if align.nil?
  97.     ocolor = self.font.color.clone
  98.     self.font.color = Color.new(0, 0, 0, 128)
  99.     if self.font.shadow
  100.       shadow_draw_text(x + 0.5, y + 0.5, width, height, str, align)
  101.     end
  102.     self.font.color = ocolor
  103.     shadow_draw_text(x, y, width, height, str, align)
  104.   end
  105. end
复制代码
4.发现 Input 的按键和 VX 的有错,于是重写了:
  1. #==============================================================================
  2. # ■ Input
  3. #------------------------------------------------------------------------------
  4. #   RGE 本身的 Input 按键表和 VX 的按键有重复的严重问题。
  5. #   以后设定键盘就来这里了
  6. #==============================================================================
  7. module Input
  8.   #--------------------------------------------------------------------------
  9.   # ● KEY 可以自己设定 (根据键盘虚拟词表)
  10.   #--------------------------------------------------------------------------
  11.   LEFT  = [0x25, 0x64]
  12.   RIGHT = [0x27, 0x66]
  13.   UP    = [0x26, 0x68]
  14.   DOWN  = [0x28, 0x62]
  15.   
  16.   C = [0x5A, 0x0D, 0x20]
  17.   B = [0x58, 0x60, 0x1B]
  18.   A = [0x10]
  19.   X = [0x41]
  20.   Y = [0x53]
  21.   Z = [0x44]
  22.   L = [0x51]
  23.   R = [0x57]
  24.   
  25.   Ctrl = [0x11]
  26.   Alt  = [0x12]
  27.   
  28.   F5 = [0x74]
  29.   F6 = [0x75]
  30.   F7 = [0x76]
  31.   F8 = [0x77]
  32.   F9 = [0x78]
  33.   #--------------------------------------------------------------------------
  34.   # ● 实例变量
  35.   #--------------------------------------------------------------------------
  36.   @Key_Repeat = {}
  37.   @Key_Trigger = {}
  38.   module_function
  39.   #--------------------------------------------------------------------------
  40.   # ● 按住?
  41.   #--------------------------------------------------------------------------
  42.   def press?(keys)
  43.     return_list = []
  44.     keys = [keys] if keys.is_a?(Numeric)
  45.     for key in keys
  46.       return_list.push KBoard::GetKeyState.call(key) & 0x8000 > 0
  47.     end
  48.     return true if return_list.include?(true)
  49.     return false
  50.   end
  51.   #--------------------------------------------------------------------------
  52.   # ● 持续被按住?
  53.   #--------------------------------------------------------------------------
  54.   def repeat?(keys)
  55.     return_list = []
  56.     keys = [keys] if keys.is_a?(Numeric)
  57.     for key in keys
  58.       if @Key_Repeat[key] != nil
  59.         return_list.push @Key_Repeat[key]
  60.         next
  61.       end
  62.       @Key_Repeat[key] = KBoard.repeat?(key)
  63.       return_list.push @Key_Repeat[key]
  64.     end
  65.     return true if return_list.include?(true)
  66.     return false
  67.   end
  68.   #--------------------------------------------------------------------------
  69.   # ● 按下?
  70.   #--------------------------------------------------------------------------
  71.   def trigger?(keys)
  72.     return_list = []
  73.     keys = [keys] if keys.is_a?(Numeric)
  74.     for key in keys
  75.       if @Key_Trigger[key] != nil
  76.         return_list.push @Key_Trigger[key]
  77.         next
  78.       end
  79.       @Key_Trigger[key] = KBoard.trigger?(key)
  80.       return_list.push @Key_Trigger[key]
  81.     end
  82.     return true if return_list.include?(true)
  83.     return false
  84.   end
  85.   #==============================================================================
  86.   # ■ KBoard
  87.   #==============================================================================
  88.   module KBoard
  89.     #--------------------------------------------------------------------------
  90.     # ● 实例变量
  91.     #--------------------------------------------------------------------------
  92.     @Key_Hash = {}
  93.     @Key_Repeat = {}
  94.    
  95.     GetKeyState = Win32API.new("user32","GetAsyncKeyState","i","i")
  96.     #--------------------------------------------------------------------------
  97.     # ● 持续被按住?
  98.     #--------------------------------------------------------------------------
  99.     def self.repeat?(key)
  100.       result = GetKeyState.call(key) & 0x8000
  101.       if result > 0
  102.         if @Key_Repeat[key].nil?
  103.           @Key_Repeat[key] = 0
  104.           return true
  105.         end
  106.         @Key_Repeat[key] += 1
  107.       else
  108.         @Key_Repeat[key] = nil
  109.         @Key_Hash[key] = 0
  110.       end
  111.       if !@Key_Repeat[key].nil? and @Key_Repeat[key] > 4 # 4乃准确数字
  112.         @Key_Repeat[key] = 0
  113.         return true
  114.       else
  115.         return false
  116.       end
  117.     end
  118.     #--------------------------------------------------------------------------
  119.     # ● 按下?
  120.     #--------------------------------------------------------------------------
  121.     def self.trigger?(rkey)
  122.       result = GetKeyState.call(rkey) & 0x8000
  123.       return false if @Key_Hash[rkey] and result > 0
  124.       @Key_Hash[rkey] = (result > 0 ? true : false)
  125.       return @Key_Hash[rkey]
  126.     end
  127.   end
  128. end
  129. #==============================================================================
  130. # ■ Input
  131. #------------------------------------------------------------------------------
  132. #   目的是为了加快 update 的速度
  133. #==============================================================================
  134. class << Input
  135.   #--------------------------------------------------------------------------
  136.   # ● 更新?
  137.   #--------------------------------------------------------------------------
  138.   alias old_update update
  139.   def update
  140.     old_update
  141.     @Key_Repeat.clear
  142.     @Key_Trigger.clear
  143.   end
  144. end
复制代码

评分

参与人数 2星屑 +264 收起 理由
david50407 + 132 我最多也寫了Shadow而已
zh99998 + 132 感谢

查看全部评分

回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-5-6 15:42

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表