查看: 3218|回复: 4

[胡扯] 【素材发布(不对】va的RTP转xp

[复制链接]
梦石
0
星屑
76
在线时间
1379 小时
注册时间
2012-7-5
回帖
1643

开拓者

发表于 2014-10-1 18:18:06 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 kuerlulu 于 2014-10-1 18:22 编辑

你问我为什么不发到素材分享区, 因为那里触手太多了麻麻怕我被粗掉>///<
再说了重点是代码嘛【啥
0.png
1.png
Tilesets from va 1.rar (2.99 MB, 下载次数: 132) Tilesets form va 2.rar (2.67 MB, 下载次数: 120)
别问我为什么少了一些图
CACAO 的 save_png (手抽把作者声明删了)
  1. class Bitmap
  2.   #--------------------------------------------------------------------------
  3.   # ● 保存成 png 格式
  4.   #     filename : 文件名
  5.   #     alpha    : 透明通道有效
  6.   #--------------------------------------------------------------------------
  7.   def save_png(filename, alpha = true)
  8.     sgnt = "\x89PNG\r\n\x1a\n"
  9.     ihdr = _chunk('IHDR', [width,height,8,(alpha ? 6 : 2),0,0,0].pack('N2C5'))
  10.     data = []
  11.     height.times do |y|
  12.       data << 0
  13.       width.times do |x|
  14.         color = self.get_pixel(x, y)
  15.         data << color.red << color.green << color.blue
  16.         data << color.alpha if alpha
  17.       end
  18.     end
  19.     idat = _chunk('IDAT', Zlib::Deflate.deflate(data.pack('C*')))
  20.     iend = _chunk('IEND', "")
  21.     File.open(filename, 'wb') do |file|
  22.       file.write(sgnt)
  23.       file.write(ihdr)
  24.       file.write(idat)
  25.       file.write(iend)
  26.     end
  27.   end
  28. private
  29.   #--------------------------------------------------------------------------
  30.   # ● チャンクの作成
  31.   #     name : チャンク名
  32.   #     data : チャンクデータ
  33.   #--------------------------------------------------------------------------
  34.   def _chunk(name, data)
  35.     return [data.size, name, data, Zlib.crc32(name + data)].pack('NA4A*N')
  36.   end
  37. end
复制代码

主代码
  1. def make_tileset(b)
  2.   ani = b.width == 64 ? false : true
  3.   if ani
  4.     as = Bitmap.new(b.width*3/2, 128) # nx4
  5.     for i in 0...(b.width / 64)
  6.       c = Bitmap.new 64, 96  # 2x3
  7.       a = Bitmap.new 96, 128 # 3x4
  8.       c.blt(0, 0, b, Rect.new(i * 64, 0, 64, 96))
  9.       a.blt(0, 0, c, Rect.new(0, 0, 32, 32))       # A
  10.       a.blt(64, 0, c, Rect.new(32, 0, 32, 32))     # C
  11.       a.blt(0, 32, c, Rect.new(0, 32, 16, 16))     # ↖
  12.       a.blt(80, 32, c, Rect.new(48, 32, 16, 16))   # ↗
  13.       a.blt(0, 112, c, Rect.new(0, 80, 16, 16))    # ↙
  14.       a.blt(80, 112, c, Rect.new(48, 80, 16, 16))  # ↘
  15.       a.blt(16, 32, c, Rect.new(16, 32, 32, 16))   # D^
  16.       a.blt(48, 32, c, Rect.new(16, 32, 32, 16))   # D ^
  17.       a.blt(0, 48, c, Rect.new(0, 48, 16, 32))     # D<
  18.       a.blt(0, 80, c, Rect.new(0, 48, 16, 32))     # D <
  19.       a.blt(80, 48, c, Rect.new(48, 48, 16, 32))   # D>
  20.       a.blt(80, 80, c, Rect.new(48, 48, 16, 32))   # D >
  21.       a.blt(16, 112, c, Rect.new(16, 80, 32, 16))  # D_
  22.       a.blt(48, 112, c, Rect.new(16, 80, 32, 16))  # D _
  23.       a.blt(16, 48, c, Rect.new(16, 48, 32, 32))   # D<^
  24.       a.blt(48, 48, c, Rect.new(16, 48, 32, 32))   # D^>
  25.       a.blt(48, 80, c, Rect.new(16, 48, 32, 32))   # D_>
  26.       a.blt(16, 80, c, Rect.new(16, 48, 32, 32))   # D<_
  27.       a.fill_rect(32, 0, 32, 32, c.get_pixel(0, 0))# B
  28.       as.blt(i * 96, 0, a, a.rect)
  29.     end
  30.     return as
  31.   else
  32.     c = b
  33.     a = Bitmap.new 96, 128 # 3x4
  34.     a.blt(0, 0, c, Rect.new(0, 0, 32, 32))       # A
  35.     a.blt(64, 0, c, Rect.new(32, 0, 32, 32))     # C
  36.     a.blt(0, 32, c, Rect.new(0, 32, 16, 16))     # ↖
  37.     a.blt(80, 32, c, Rect.new(48, 32, 16, 16))   # ↗
  38.     a.blt(0, 112, c, Rect.new(0, 80, 16, 16))    # ↙
  39.     a.blt(80, 112, c, Rect.new(48, 80, 16, 16))  # ↘
  40.     a.blt(16, 32, c, Rect.new(16, 32, 32, 16))   # D^
  41.     a.blt(48, 32, c, Rect.new(16, 32, 32, 16))   # D ^
  42.     a.blt(0, 48, c, Rect.new(0, 48, 16, 32))     # D<
  43.     a.blt(0, 80, c, Rect.new(0, 48, 16, 32))     # D <
  44.     a.blt(80, 48, c, Rect.new(48, 48, 16, 32))   # D>
  45.     a.blt(80, 80, c, Rect.new(48, 48, 16, 32))   # D >
  46.     a.blt(16, 112, c, Rect.new(16, 80, 32, 16))  # D_
  47.     a.blt(48, 112, c, Rect.new(16, 80, 32, 16))  # D _
  48.     a.blt(16, 48, c, Rect.new(16, 48, 32, 32))   # D<^
  49.     a.blt(48, 48, c, Rect.new(16, 48, 32, 32))   # D^>
  50.     a.blt(48, 80, c, Rect.new(16, 48, 32, 32))   # D_>
  51.     a.blt(16, 80, c, Rect.new(16, 48, 32, 32))   # D<_
  52.     a.fill_rect(32, 0, 32, 32, c.get_pixel(0, 0))# B
  53.     return a
  54.   end
  55. end
  56. def conv_a_tileset(path, ani = false)
  57.   filename = File.basename(path, ".*")
  58.   Dir.mkdir(filename) unless FileTest.directory?(filename)
  59.   b = Bitmap.new path
  60.   s = Sprite.new # 一听雪碧
  61.   if ani
  62.     for x in 0...2
  63.       for y in 0...4
  64.         c = Bitmap.new 192, 96  # 3x2x3
  65.         c.blt(0, 0, b, Rect.new(x * 256, y * 96, 192, 96))
  66.         a = make_tileset(c)
  67.         s.bitmap = a
  68.         s.update
  69.         Graphics.update
  70.         a.save_png("#{filename}/A#{x}#{y}.png")
  71.         c.clear
  72.         c = Bitmap.new 64, 96  # 2x3
  73.         c.blt(0, 0, b, Rect.new(x * 256 + 192, y * 96, 64, 96))
  74.         a = make_tileset(c)
  75.         s.bitmap = a
  76.         s.update
  77.         Graphics.update
  78.         a.save_png("#{filename}/#{x}#{y}.png")
  79.         c.clear
  80.       end
  81.     end
  82.   else
  83.     for x in 0...8
  84.       for y in 0...4
  85.         c = Bitmap.new 64, 96  # 2x3
  86.         c.blt(0, 0, b, Rect.new(x * 64, y * 96, 64, 96))
  87.         a = make_tileset(c)
  88.         s.bitmap = a
  89.         s.update
  90.         Graphics.update
  91.         a.save_png("#{filename}/#{x}#{y}.png")
  92.         c.clear
  93.       end
  94.     end
  95.   end
  96. end
  97. def conv_tileset(path)
  98.   filename = File.basename(path, ".*")
  99.   Dir.mkdir(filename) unless FileTest.directory?(filename)
  100.   b = Bitmap.new path
  101.   a = Bitmap.new 256, 1024
  102.   a.blt(0, 0, b, Rect.new(0, 0, 256, 512))
  103.   a.blt(0, 512, b, Rect.new(256, 0, 256, 512))
  104.   a.save_png("#{filename}/#{filename}.png")
  105. end

  106. Dir["./Tilesets/*.png"].each do |path|
  107.   next if path.include?('A5') || path.include?('A4') || path.include?('A3')
  108.   if path.include?('A')
  109.     conv_a_tileset(path, path.include?('A1'))
  110.   else
  111.     conv_tileset(path)
  112.   end
  113. end

  114. exit
复制代码

评分

参与人数 1星屑 +20 收起 理由
美丽晨露 + 20 塞糖

查看全部评分


  -fk: -azogi:

…あたしは天

梦石
0
星屑
2311
在线时间
4033 小时
注册时间
2010-10-4
回帖
10548

开拓者贵宾

发表于 2014-10-1 18:20:45 | 显示全部楼层
一听雪碧

评分

参与人数 1星屑 +30 收起 理由
kuerlulu + 30 喵喵喵

查看全部评分

回复

使用道具 举报

梦石
20
星屑
1840
在线时间
6925 小时
注册时间
2012-12-14
回帖
10960

短篇十战斗者组别冠军开拓者贵宾短篇九勇士组亚军

发表于 2014-10-1 19:28:18 | 显示全部楼层
撒花发布
不放到素材区没有大糖的说
大家好,这里是晨露的说。请多多指教。
刚入门RM软件制作,请大家多多帮助我哦。
落雪君的欢乐像素教程,欢迎查阅。

回复

使用道具 举报

梦石
0
星屑
9292
在线时间
2504 小时
注册时间
2011-5-20
回帖
14521

开拓者

发表于 2014-10-1 19:34:04 | 显示全部楼层
@怪蜀黍 交给你了···带走吧···

话说可以做一个反过来的吗?把XP的弄成VA的···

点评

↓好吧我忘记这个已经有人写过了···  发表于 2014-10-1 20:29
这么简单的代码chd菊苣自己写吧  发表于 2014-10-1 20:23
这么简单的代码chd菊苣自己写吧  发表于 2014-10-1 19:49
[img]http://service.t.sina.com.cn/widget/qmd/5339802982/c02e16bd/7.png
回复

使用道具 举报

精灵族の天使<

梦石
0
星屑
1712
在线时间
3039 小时
注册时间
2007-3-16
回帖
33092

开拓者贵宾

发表于 2014-10-2 08:23:23 | 显示全部楼层
这个会有版权问题。
你必须同时拥有RMVA和RMXP的正版权限方可混用【如果谁买了12美元的包的话或许可以】

点评

因此不敢发到素材分享区, 而且重点毕竟是代码啦【噗  发表于 2014-10-2 09:06
6R里大部分的人连VA的正版都没有  发表于 2014-10-2 08:31
回复

使用道具 举报

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

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部