查看: 3158|回复: 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)
别问我为什么少了一些图
[fold=CACAO 的 save_png (手抽把作者声明删了)][pre lang="ruby" line="1"]class Bitmap
  #--------------------------------------------------------------------------
  # ● 保存成 png 格式
  #     filename : 文件名
  #     alpha    : 透明通道有效
  #--------------------------------------------------------------------------
  def save_png(filename, alpha = true)
    sgnt = "\x89PNG\r\n\x1a\n"
    ihdr = _chunk('IHDR', [width,height,8,(alpha ? 6 : 2),0,0,0].pack('N2C5'))
    data = []
    height.times do |y|
      data << 0
      width.times do |x|
        color = self.get_pixel(x, y)
        data << color.red << color.green << color.blue
        data << color.alpha if alpha
      end
    end
    idat = _chunk('IDAT', Zlib::Deflate.deflate(data.pack('C*')))
    iend = _chunk('IEND', "")
    File.open(filename, 'wb') do |file|
      file.write(sgnt)
      file.write(ihdr)
      file.write(idat)
      file.write(iend)
    end
  end
private
  #--------------------------------------------------------------------------
  # ● チャンクの作成
  #     name : チャンク名
  #     data : チャンクデータ
  #--------------------------------------------------------------------------
  def _chunk(name, data)
    return [data.size, name, data, Zlib.crc32(name + data)].pack('NA4A*N')
  end
end[/pre]
[/fold][fold=主代码][pre lang="ruby" line="1"]def make_tileset(b)
  ani = b.width == 64 ? false : true
  if ani
    as = Bitmap.new(b.width*3/2, 128) # nx4
    for i in 0...(b.width / 64)
      c = Bitmap.new 64, 96  # 2x3
      a = Bitmap.new 96, 128 # 3x4
      c.blt(0, 0, b, Rect.new(i * 64, 0, 64, 96))
      a.blt(0, 0, c, Rect.new(0, 0, 32, 32))       # A
      a.blt(64, 0, c, Rect.new(32, 0, 32, 32))     # C
      a.blt(0, 32, c, Rect.new(0, 32, 16, 16))     # ↖
      a.blt(80, 32, c, Rect.new(48, 32, 16, 16))   # ↗
      a.blt(0, 112, c, Rect.new(0, 80, 16, 16))    # ↙
      a.blt(80, 112, c, Rect.new(48, 80, 16, 16))  # ↘
      a.blt(16, 32, c, Rect.new(16, 32, 32, 16))   # D^
      a.blt(48, 32, c, Rect.new(16, 32, 32, 16))   # D ^
      a.blt(0, 48, c, Rect.new(0, 48, 16, 32))     # D<
      a.blt(0, 80, c, Rect.new(0, 48, 16, 32))     # D <
      a.blt(80, 48, c, Rect.new(48, 48, 16, 32))   # D>
      a.blt(80, 80, c, Rect.new(48, 48, 16, 32))   # D >
      a.blt(16, 112, c, Rect.new(16, 80, 32, 16))  # D_
      a.blt(48, 112, c, Rect.new(16, 80, 32, 16))  # D _
      a.blt(16, 48, c, Rect.new(16, 48, 32, 32))   # D<^
      a.blt(48, 48, c, Rect.new(16, 48, 32, 32))   # D^>
      a.blt(48, 80, c, Rect.new(16, 48, 32, 32))   # D_>
      a.blt(16, 80, c, Rect.new(16, 48, 32, 32))   # D<_
      a.fill_rect(32, 0, 32, 32, c.get_pixel(0, 0))# B
      as.blt(i * 96, 0, a, a.rect)
    end
    return as
  else
    c = b
    a = Bitmap.new 96, 128 # 3x4
    a.blt(0, 0, c, Rect.new(0, 0, 32, 32))       # A
    a.blt(64, 0, c, Rect.new(32, 0, 32, 32))     # C
    a.blt(0, 32, c, Rect.new(0, 32, 16, 16))     # ↖
    a.blt(80, 32, c, Rect.new(48, 32, 16, 16))   # ↗
    a.blt(0, 112, c, Rect.new(0, 80, 16, 16))    # ↙
    a.blt(80, 112, c, Rect.new(48, 80, 16, 16))  # ↘
    a.blt(16, 32, c, Rect.new(16, 32, 32, 16))   # D^
    a.blt(48, 32, c, Rect.new(16, 32, 32, 16))   # D ^
    a.blt(0, 48, c, Rect.new(0, 48, 16, 32))     # D<
    a.blt(0, 80, c, Rect.new(0, 48, 16, 32))     # D <
    a.blt(80, 48, c, Rect.new(48, 48, 16, 32))   # D>
    a.blt(80, 80, c, Rect.new(48, 48, 16, 32))   # D >
    a.blt(16, 112, c, Rect.new(16, 80, 32, 16))  # D_
    a.blt(48, 112, c, Rect.new(16, 80, 32, 16))  # D _
    a.blt(16, 48, c, Rect.new(16, 48, 32, 32))   # D<^
    a.blt(48, 48, c, Rect.new(16, 48, 32, 32))   # D^>
    a.blt(48, 80, c, Rect.new(16, 48, 32, 32))   # D_>
    a.blt(16, 80, c, Rect.new(16, 48, 32, 32))   # D<_
    a.fill_rect(32, 0, 32, 32, c.get_pixel(0, 0))# B
    return a
  end
end
def conv_a_tileset(path, ani = false)
  filename = File.basename(path, ".*")
  Dir.mkdir(filename) unless FileTest.directory?(filename)
  b = Bitmap.new path
  s = Sprite.new # 一听雪碧
  if ani
    for x in 0...2
      for y in 0...4
        c = Bitmap.new 192, 96  # 3x2x3
        c.blt(0, 0, b, Rect.new(x * 256, y * 96, 192, 96))
        a = make_tileset(c)
        s.bitmap = a
        s.update
        Graphics.update
        a.save_png("#{filename}/A#{x}#{y}.png")
        c.clear
        c = Bitmap.new 64, 96  # 2x3
        c.blt(0, 0, b, Rect.new(x * 256 + 192, y * 96, 64, 96))
        a = make_tileset(c)
        s.bitmap = a
        s.update
        Graphics.update
        a.save_png("#{filename}/#{x}#{y}.png")
        c.clear
      end
    end
  else
    for x in 0...8
      for y in 0...4
        c = Bitmap.new 64, 96  # 2x3
        c.blt(0, 0, b, Rect.new(x * 64, y * 96, 64, 96))
        a = make_tileset(c)
        s.bitmap = a
        s.update
        Graphics.update
        a.save_png("#{filename}/#{x}#{y}.png")
        c.clear
      end
    end
  end
end
def conv_tileset(path)
  filename = File.basename(path, ".*")
  Dir.mkdir(filename) unless FileTest.directory?(filename)
  b = Bitmap.new path
  a = Bitmap.new 256, 1024
  a.blt(0, 0, b, Rect.new(0, 0, 256, 512))
  a.blt(0, 512, b, Rect.new(256, 0, 256, 512))
  a.save_png("#{filename}/#{filename}.png")
end

Dir["./Tilesets/*.png"].each do |path|
  next if path.include?('A5') || path.include?('A4') || path.include?('A3')
  if path.include?('A')
    conv_a_tileset(path, path.include?('A1'))
  else
    conv_tileset(path)
  end
end

exit[/pre][/fold]

评分

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

查看全部评分


  -fk: -azogi:

…あたしは天

梦石
0
星屑
2308
在线时间
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.

在本版发帖返回顶部