Project1
标题: 论RM Web的升级版实现方式…… [打印本页]
作者: zhangchi5 时间: 2014-7-22 17:11
标题: 论RM Web的升级版实现方式……
鉴于前一个帖子反响不好……我就再来一个……
---
首先我们需要用某种语言重写RPG Maker自带的脚本和RGSS的基础类……
比如RPG Maker自带脚本用C#写,RGSS的一些图形类用MDX或者XNA或者Monogame或者Cocos-2d for XNA
总之要能够读取RM的数据……
然后用SliverLight包装,把数据渲染到RenderTarget……
同时为了减少服务器负担,必须设立缓存……
我们都知道RPG Maker的脚本里有一个Cache Module,放到C#里以后:
[box=PaleTurquois] 读取一个png
如果png已经缓存
返回png
否则
返回特定的未知贴图
把下载png加入缓存队列
结束[/box]
当然以上过程如果可以吧缓存的内容加密当然更加安全
那么这个SliverLight程序就是公用的脚本……对于一般的RPG游戏应该是应付的过来的
---
关于实现……
如果使用的是XNA的话,渲染到RenderTarget2D中,然后获取贴图,转换成SliverLight的贴图(其实就是拷贝……)
对于VA、VX、XP的小界面640x480,这个过程可以达到60fps……
640(Width)*480(Height)*4(Color,RGBA)*1(Byte Size)*60(Expect FPS)=73728000
可以看做复杂度O(73728000),基本可以……
---
论拷贝
protected Texture2D FillTexture(ref System.Drawing.Bitmap bitmap)
{
Texture2D tmpTex = new Texture2D(DGE.Graphics.Device, (int)bitmap.Width, (int)bitmap.Height);
System.Drawing.Imaging.BitmapData colorMapTex = bitmap.LockBits(new System.Drawing.Rectangle(0, 0, bitmap.Width, bitmap.Height), System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
Byte[] colorMap = new Byte[tmpTex.Width * tmpTex.Height * 4];
int bound = Math.Abs(colorMapTex.Stride) * colorMapTex.Height;
IntPtr ptr = colorMapTex.Scan0;
System.Runtime.InteropServices.Marshal.Copy(ptr, colorMap, 0, bound);
tmpTex.SetData<Byte>(colorMap);
return tmpTex;
}
protected Texture2D FillTexture(ref System.Drawing.Bitmap bitmap)
{
Texture2D tmpTex = new Texture2D(DGE.Graphics.Device, (int)bitmap.Width, (int)bitmap.Height);
System.Drawing.Imaging.BitmapData colorMapTex = bitmap.LockBits(new System.Drawing.Rectangle(0, 0, bitmap.Width, bitmap.Height), System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
Byte[] colorMap = new Byte[tmpTex.Width * tmpTex.Height * 4];
int bound = Math.Abs(colorMapTex.Stride) * colorMapTex.Height;
IntPtr ptr = colorMapTex.Scan0;
System.Runtime.InteropServices.Marshal.Copy(ptr, colorMap, 0, bound);
tmpTex.SetData<Byte>(colorMap);
return tmpTex;
}
---
论转换
GraphicsDevice graphicsDevice = GraphicsDevice;
RenderTarget2D rt = new RenderTarget2D(graphicsDevice,640,480);
RenderTargetBinding[] old = graphicsDevice.GetRenderTargets();
graphicsDevice.SetRenderTarget(rt);
graphicsDevice.Clear(ClearOptions.Target, Color.Transparent, 0, 0);
SpriteBatch spriteBatch = new SpriteBatch(graphicsDevice);
spriteBatch.Begin();
//Do Sth...
spriteBatch.End();
spriteBatch.Dispose();
graphicsDevice.SetRenderTargets(old);
graphicsDevice.Clear(Color.Transparent);
RenderTargetBinding binding = new RenderTargetBinding(rt);
return binding.RenderTarget as Texture2D;
GraphicsDevice graphicsDevice = GraphicsDevice;
RenderTarget2D rt = new RenderTarget2D(graphicsDevice,640,480);
RenderTargetBinding[] old = graphicsDevice.GetRenderTargets();
graphicsDevice.SetRenderTarget(rt);
graphicsDevice.Clear(ClearOptions.Target, Color.Transparent, 0, 0);
SpriteBatch spriteBatch = new SpriteBatch(graphicsDevice);
spriteBatch.Begin();
//Do Sth...
spriteBatch.End();
spriteBatch.Dispose();
graphicsDevice.SetRenderTargets(old);
graphicsDevice.Clear(Color.Transparent);
RenderTargetBinding binding = new RenderTargetBinding(rt);
return binding.RenderTarget as Texture2D;
---
额呵呵……
作者: zhangchi5 时间: 2014-7-22 17:12
表示代码功能不能用……大家凑合着看
作者: satgo1546 时间: 2014-7-22 20:03
如果脚本功能被你剪了,再怎么样什么都没用了。
作者: MeowSnow 时间: 2014-7-22 20:46
(ΦωΦ)可以试试用更自由的RM脚本库当基础,比如默认就跳过标题大家都用事件制作,屏蔽了菜单大家都用事件制作……(ΦωΦ)总之事件是万能的,把那些定义死的功能都屏蔽掉。
作者: zhangchi5 时间: 2014-7-23 18:40
satgo1546 发表于 2014-7-22 20:03 
如果脚本功能被你剪了,再怎么样什么都没用了。
脚本用C#写啊……再说,Ruby的编译器用C#更好实现,照样可以用Ruby写= =
作者: IamI 时间: 2014-7-23 21:57
zhangchi5 发表于 2014-7-23 18:40 
脚本用C#写啊……再说,Ruby的编译器用C#更好实现,照样可以用Ruby写= =
IronRuby:呵呵。
如果不打算用IronRuby,你需要花几天时间看CodeDOM那些让人足以发疯的文档。
Speak is cheap, show me the code --- Linus
欢迎光临 Project1 (https://rpg.blue/) |
Powered by Discuz! X3.1 |