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

Project1

 找回密码
 注册会员
搜索
查看: 12027|回复: 21

傻瓜式XP的地图放到VX作为远景图

 关闭 [复制链接]

Lv2.观梦者

傻♂逼

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

烫烫烫开拓者

发表于 2008-8-26 04:26:27 | 显示全部楼层 |阅读模式

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

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

x
重要更新:
--------------
再次修正严重bug
修正一个非常严重的bug
更新远景遮挡,全傻瓜式导出
更新四方位支持 2008年8月26日-
--------------
补丁:
添加到main以前
内容-针对上一个更新包兼容问题
  1. #==============================================================================
  2. # ** Game_Map
  3. #==============================================================================

  4. class Game_Map
  5.   #--------------------------------------------------------------------------
  6.   # * Public Instance Variables
  7.   #--------------------------------------------------------------------------
  8.   attr_reader :map
  9.   attr_accessor :tilemap_tone
  10.   attr_accessor :tilemap_plane
  11.   attr_accessor :tilemap_zoom_x
  12.   attr_accessor :tilemap_zoom_y
  13.   attr_accessor :tilemap_tile_width
  14.   attr_accessor :tilemap_tile_height
  15.   #--------------------------------------------------------------------------
  16.   # * Alias Listings
  17.   #--------------------------------------------------------------------------
  18.   alias seph_tilemap_gmap_init initialize
  19.   #--------------------------------------------------------------------------
  20.   # * Object Initialization
  21.   #--------------------------------------------------------------------------
  22.   def initialize
  23.     # Original Initialization
  24.     seph_tilemap_gmap_init
  25.     # Sets Special Tilemap Properties
  26.     @tilemap_tone        = nil
  27.     @tilemap_plane       = false
  28.     @tilemap_zoom_x      = 1.0
  29.     @tilemap_zoom_y      = 1.0
  30.     @tilemap_tile_width  = 32
  31.     @tilemap_tile_height = 32
  32.   end
  33. end


  34. #==============================================================================
  35. # Super Tilemap
  36. # 作者:釣到一隻猴子@_@ ( AAM@_@ )
  37. # 版本:Ver.1.0
  38. # 本資訊不得刪除
  39. #==============================================================================
  40. #==============================================================================
  41. # ■ Tilemap
  42. #------------------------------------------------------------------------------
  43. #  顯示地圖的核心。
  44. #==============================================================================

  45. class Tilemap
  46. #--------------------------------------------------------------------------
  47. # ● 定量
  48. #--------------------------------------------------------------------------
  49. Animated_Autotiles_Frames = 15
  50. Scroll_Times = 4
  51. Autotiles = [
  52.    [ [27, 28, 33, 34], [ 5, 28, 33, 34], [27,  6, 33, 34], [ 5,  6, 33, 34],
  53.      [27, 28, 33, 12], [ 5, 28, 33, 12], [27,  6, 33, 12], [ 5,  6, 33, 12] ],
  54.    [ [27, 28, 11, 34], [ 5, 28, 11, 34], [27,  6, 11, 34], [ 5,  6, 11, 34],
  55.      [27, 28, 11, 12], [ 5, 28, 11, 12], [27,  6, 11, 12], [ 5,  6, 11, 12] ],
  56.    [ [25, 26, 31, 32], [25,  6, 31, 32], [25, 26, 31, 12], [25,  6, 31, 12],
  57.      [15, 16, 21, 22], [15, 16, 21, 12], [15, 16, 11, 22], [15, 16, 11, 12] ],
  58.    [ [29, 30, 35, 36], [29, 30, 11, 36], [ 5, 30, 35, 36], [ 5, 30, 11, 36],
  59.      [39, 40, 45, 46], [ 5, 40, 45, 46], [39,  6, 45, 46], [ 5,  6, 45, 46] ],
  60.    [ [25, 30, 31, 36], [15, 16, 45, 46], [13, 14, 19, 20], [13, 14, 19, 12],
  61.      [17, 18, 23, 24], [17, 18, 11, 24], [41, 42, 47, 48], [ 5, 42, 47, 48] ],
  62.    [ [37, 38, 43, 44], [37,  6, 43, 44], [13, 18, 19, 24], [13, 14, 43, 44],
  63.      [37, 42, 43, 48], [17, 18, 47, 48], [13, 18, 43, 48], [ 1,  2,  7,  8] ]
  64. ]
  65. #--------------------------------------------------------------------------
  66. # ● 定義外部變數
  67. #--------------------------------------------------------------------------
  68. attr_reader :layers
  69. attr_accessor :tileset
  70. attr_accessor :autotiles
  71. attr_accessor :map_data
  72. attr_accessor :flash_data
  73. attr_accessor :priorities
  74. attr_accessor :visible
  75. attr_accessor :ox
  76. attr_accessor :oy
  77. attr_accessor :tone
  78. attr_accessor :zoom_x
  79. attr_accessor :zoom_y
  80. #--------------------------------------------------------------------------
  81. # ● 初始化
  82. #--------------------------------------------------------------------------
  83. def initialize(viewport,map_data=$game_map.map)
  84.    # 生成圖層
  85.    @layers = []
  86.    for l in 0..5
  87.      layer = Sprite.new(viewport)
  88.      layer.bitmap = Bitmap.new(map_data.data.xsize*32, map_data.data.ysize*32)
  89.      layer.z = (l == 0 ? 0 : (64 + 32 * (l - 1)))
  90.      @layers << layer
  91.    end
  92.    @map_data = map_data.data
  93.    # 定義變數
  94.    @tileset    = nil
  95.    @autotiles  = []
  96.    @map_data   = nil
  97.    @flash_data = nil
  98.    @priorities = nil
  99.    @visible    = true
  100.    @ox = @o_ox = 0
  101.    @oy = @o_oy = 0
  102.    @tone       = nil
  103.    @zoom_x     = 1.0
  104.    @zoom_y     = 1.0
  105. end
  106. #--------------------------------------------------------------------------
  107. # ● 釋放
  108. #--------------------------------------------------------------------------
  109. def dispose
  110.    # 釋放圖層
  111.    for layer in @layers
  112.      layer.dispose
  113.    end
  114. end
  115. #--------------------------------------------------------------------------
  116. # ● 更新
  117. #--------------------------------------------------------------------------
  118. def update
  119.    # 地圖資訊更換
  120.    if @o_map_data != @map_data
  121.      @o_map_data = @map_data
  122.      refresh
  123.    end
  124.    # 偏移座標更換
  125.    if @o_ox != @ox or @o_oy != @oy
  126.      sx = @ox - @o_ox
  127.      sy = @oy - @o_oy
  128.      @o_ox = @ox
  129.      @o_oy = @oy
  130.      refresh#_map(sx, sy)
  131.    end
  132.    # 色調更換
  133.    if @o_tone != @tone
  134.      @o_tone = @tone
  135.      @tone = Tone.new(0, 0, 0, 0) if @tone.nil?
  136.      for layer in @layers
  137.        layer.tone = @tone
  138.      end
  139.    end
  140.    # 比例更換
  141.    if @o_zoom_x != @zoom_x
  142.      @o_zoom_x = @zoom_x
  143.      for layer in @layers
  144.        layer.zoom_x = @zoom_x
  145.      end
  146.    end
  147.    if @o_zoom_y != @zoom_y
  148.      @o_zoom_y = @zoom_y
  149.      for layer in @layers
  150.        layer.zoom_y = @zoom_y
  151.      end
  152.    end
  153.    # 自動元件動畫
  154.    if Graphics.frame_count % Animated_Autotiles_Frames == 0
  155.      # 更新自動元件
  156.      refresh_autotiles
  157.    end
  158.    get_bitmap.save2png("VX/Graphics/Parallaxes/" + $iiii.to_s + ".png") if $start_out
  159. end
  160. #--------------------------------------------------------------------------
  161. # ● 更新元件
  162. #--------------------------------------------------------------------------
  163. def refresh_map(sx, sy)
  164.    # 圖層捲動
  165.    move(0, sx)
  166.    move(0, sy)
  167.    # 循環所有優先級
  168.    for p in 0..5
  169.      # 循環所有圖層
  170.      for z in 0...@map_data.zsize
  171.        # 循環所有X座標
  172.        for x in 0...@map_data.xsize
  173.          # 循環所有Y座標
  174.          for y in 0...@map_data.ysize
  175.            # 當偏移座標不正常時略過
  176.            next if @ox < 0
  177.            next if @oy < 0
  178.            # 取得元件ID
  179.            mx = @ox / 32
  180.            my = @oy / 32
  181.            id = @map_data[x + mx, y + my, z]
  182.            # 當元件ID不正常時略過
  183.            next if id == 0
  184.            # 當圖層不符時略過
  185.            next unless p == @priorities[id]
  186.            # 描繪元件(自動元件)
  187.            id < 384 ? draw_autotile(x, y, p, id) : draw_tile(x, y, p, id)
  188.          end
  189.        end
  190.      end
  191.    end
  192.    # 循環所有優先級
  193.    for p in 0..5
  194.      # 循環所有圖層
  195.      for z in 0...@map_data.zsize
  196.        # 循環所有X座標
  197.        for x in 0...@map_data.xsize
  198.          # 循環所有Y座標
  199.          for y in 0...@map_data.ysize
  200.            # 當偏移座標不正常時略過
  201.            next if @ox < 0
  202.            next if @oy < 0
  203.            # 取得元件ID
  204.            mx = @ox / 32
  205.            my = @oy / 32
  206.            id = @map_data[x + mx, y + my, z]
  207.            # 當元件ID不正常時略過
  208.            next if id == 0
  209.            # 當圖層不符時略過
  210.            next unless p == @priorities[id]
  211.            # 描繪元件(自動元件)
  212.            id < 384 ? draw_autotile(x, y, p, id) : draw_tile(x, y, p, id)
  213.          end
  214.        end
  215.      end
  216.    end
  217. end
  218. #--------------------------------------------------------------------------
  219. # ● 圖層捲動
  220. #--------------------------------------------------------------------------
  221. def move(d, v)
  222.    # 設定單次移動距離
  223.    #v /= Scroll_Times
  224.    # 循環次數
  225.    #for i in 0...Scroll_Times
  226.    #  # 判斷方向
  227.    #  case d
  228.    #  when 0
  229.    #    # 移動圖層
  230.    #    for layer in @layers
  231.    #      bitmap = layer.bitmap
  232.    #      layer.bitmap.blt(v, 0, bitmap, Rect.new(0, 0, 640, 480))
  233.    #    end
  234.    #  when 1
  235.    #    # 移動圖層
  236.    #    for layer in @layers
  237.    #      bitmap = layer.bitmap
  238.    #      layer.bitmap.blt(0, v, bitmap, Rect.new(0, 0, 640, 480))
  239.    #    end
  240.    #  end
  241.    #end
  242. end
  243. #--------------------------------------------------------------------------
  244. # ● 初次描繪地圖
  245. #--------------------------------------------------------------------------
  246. def refresh
  247.    # 循環所有優先級
  248.    for p in 0..5
  249.      # 循環所有圖層
  250.      for z in 0...@map_data.zsize
  251.        # 循環所有X座標
  252.        for x in 0...@map_data.xsize
  253.          # 循環所有Y座標
  254.          for y in 0...@map_data.ysize
  255.            # 當偏移座標不正常時略過
  256.            next if @ox < 0
  257.            next if @oy < 0
  258.            # 取得元件ID
  259.            mx = @ox / 32
  260.            my = @oy / 32
  261.            id = @map_data[x + mx, y + my, z]
  262.            # 當元件ID不正常時略過
  263.            next if id == 0
  264.            # 當圖層不符時略過
  265.            next unless p == @priorities[id]
  266.            # 描繪元件(自動元件)
  267.            id < 384 ? draw_autotile(x, y, p, id) : draw_tile(x, y, p, id)
  268.          end
  269.        end
  270.      end
  271.    end
  272. end
  273. #--------------------------------------------------------------------------
  274. # ● 更新自動元件
  275. #--------------------------------------------------------------------------
  276. def refresh_autotiles
  277.    # 循環所有優先級
  278.    for p in 0..5
  279.      # 循環所有圖層
  280.      for z in 0...@map_data.zsize
  281.        # 循環所有X座標
  282.        for x in 0...@map_data.xsize
  283.          # 循環所有Y座標
  284.          for y in 0...@map_data.ysize
  285.            # 當偏移座標不正常時略過
  286.            next if @ox < 0
  287.            next if @oy < 0
  288.            # 取得元件ID
  289.            mx = @ox / 32
  290.            my = @oy / 32
  291.            id = @map_data[x + mx, y + my, z]
  292.            # 當元件ID不正常時略過
  293.            next if id == 0
  294.            # 當圖層不符時略過
  295.            next unless p == @priorities[id]
  296.            # 描繪元件(自動元件)
  297.            draw_autotile(x, y, p, id) if id < 384
  298.          end
  299.        end
  300.      end
  301.    end
  302. end
  303. #--------------------------------------------------------------------------
  304. # ● 描繪元件
  305. #--------------------------------------------------------------------------
  306. def draw_tile(x, y, z, id)
  307.    # 設定元件矩形座標範圍
  308.    rect = Rect.new((id - 384) % 8 * 32, (id - 384) / 8 * 32, 32, 32)
  309.    # 假想座標轉為實際座標
  310.    x *= 32
  311.    y *= 32
  312.    # 描繪圖形
  313.    @layers[z].bitmap.blt(x, y, @tileset, rect)
  314. end
  315. #--------------------------------------------------------------------------
  316. # ● 描繪自動元件
  317. #--------------------------------------------------------------------------
  318. def draw_autotile(x, y, z, tile_id)
  319.    # 取得自動元件
  320.    autotile = @autotiles[tile_id / 48 - 1]
  321.    # 取得自動元件ID
  322.    tile_id %= 48
  323.    # 生成暫時圖形區塊
  324.    bitmap = Bitmap.new(32, 32)
  325.    # 取得自動元件編號
  326.    tiles = Autotiles[tile_id / 8][tile_id % 8]
  327.    # 自動元件動畫
  328.    frames = autotile.width / 96
  329.    # 設定動畫偏移座標
  330.    anim = (Graphics.frame_count / Animated_Autotiles_Frames) % frames * 96
  331.    # 生成自動元件圖塊
  332.    for i in 0...4
  333.      tile_position = tiles[i] - 1
  334.      src_rect = Rect.new(tile_position % 6 * 16 + anim,
  335.                          tile_position / 6 * 16, 16, 16)
  336.      bitmap.blt(i % 2 * 16, i / 2 * 16, autotile, src_rect)
  337.    end
  338.    # 假想座標轉為實際座標
  339.    x *= 32
  340.    y *= 32
  341.    # 描繪圖形
  342.    @layers[z].bitmap.blt(x, y, bitmap, Rect.new(0, 0, 32, 32))
  343. end
  344.    #--------------------------------------------------------------------------
  345.   # * Collect Bitmap
  346.   #--------------------------------------------------------------------------
  347.   def get_bitmap
  348.     # Creates New Blank Bitmap
  349.     bitmap = Bitmap.new(@layers[0].bitmap.width, @layers[0].bitmap.height)
  350.     # Passes Through All Layers
  351.     for layer in @layers
  352.       bitmap.blt(0, 0, layer.bitmap,
  353.         Rect.new(0, 0, bitmap.width, bitmap.height))
  354.     end
  355.     # Return Bitmap
  356.     return bitmap
  357.   end
  358. end
复制代码
现在连遮挡图一起生成咯~~

使用方法很傻瓜
http://rpg.blue/upload_program/files/范例工程_100285530.rar
下载这个工程,一个脚本是ForVX的,一个是ForXP的。
然后运行XP工程,按照范例里的使用方法执行脚本:make_map2png
程序会创建VX目录,拷贝VX目录下的所有文件到VX工程的根目录,粘贴。运行VX看看吧。
注意:使用完后务必删除XP工程里的VX目录下的所有文件。以方便下一次使用。。。
----------------------------------------------------------------------------
如果还不会就看范例咯。。。
有两个名字叫...的脚本一定要拷贝哦~~如果你觉得远景遮挡图的z太大,直接修改
  #--------------------------------------------------------------------------
  # ● 生成远景
  #--------------------------------------------------------------------------
  def create_parallax
    @parallax = Plane.new(@viewport1)
    @parallax.z = 1
    @parallax1 = Plane.new(@viewport3)
    @parallax1.z = 99999
  end
这里的@parallax1.z = 99999为理想值即可。。。
[td][/td]
梦想世界——点击进入
哎呀,蛋疼什么的最有爱了

Lv3.寻梦者 (暗夜天使)

名侦探小柯

梦石
0
星屑
3239
在线时间
3615 小时
注册时间
2006-9-6
帖子
37397

开拓者贵宾第3届短篇游戏大赛主流游戏组亚军第5届短篇游戏比赛亚军

发表于 2008-8-26 04:41:09 | 显示全部楼层
高级类么……
回复 支持 反对

使用道具 举报

Lv2.观梦者

傻♂逼

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

烫烫烫开拓者

 楼主| 发表于 2008-8-26 16:32:19 | 显示全部楼层
以下引用越前リョーマ于2008-8-25 20:41:09的发言:

高级类么……

比2远景慢一些,3远快好多,以此来方便不用做通行判断
哎呀,蛋疼什么的最有爱了
回复 支持 反对

使用道具 举报

Lv2.观梦者

傻♂逼

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

烫烫烫开拓者

 楼主| 发表于 2008-8-27 01:16:54 | 显示全部楼层
更新四方位支持
哎呀,蛋疼什么的最有爱了
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
65
在线时间
385 小时
注册时间
2007-7-27
帖子
4106

开拓者

发表于 2008-8-27 03:07:48 | 显示全部楼层
……还不如把xp的tilemap弄进去,直接读xp的图块……
吸吸
回复 支持 反对

使用道具 举报

Lv2.观梦者

傻♂逼

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

烫烫烫开拓者

 楼主| 发表于 2008-8-27 03:58:16 | 显示全部楼层
以下引用trentswd于2008-8-26 19:07:48的发言:

……还不如把xp的tilemap弄进去,直接读xp的图块……

我喜欢用远景,而且模拟的tilemap你知道有多卡吗?
哎呀,蛋疼什么的最有爱了
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
65
在线时间
385 小时
注册时间
2007-7-27
帖子
4106

开拓者

发表于 2008-8-27 04:03:20 | 显示全部楼层
以下引用yangff于2008-8-26 19:58:16的发言:


以下引用trentswd于2008-8-26 19:07:48的发言:

……还不如把xp的tilemap弄进去,直接读xp的图块……


我喜欢用远景,而且模拟的tilemap你知道有多卡吗?


[本贴由作者于 2008-8-26 19:59:01 最后编辑]

http://rpg.blue/viewthread.php?tid=100822
吸吸
回复 支持 反对

使用道具 举报

Lv2.观梦者

傻♂逼

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

烫烫烫开拓者

 楼主| 发表于 2008-8-27 04:11:13 | 显示全部楼层
这个程序我有更优化的。
但是ruby和c没有可比性,你的明白?
哎呀,蛋疼什么的最有爱了
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
65
在线时间
385 小时
注册时间
2007-7-27
帖子
4106

开拓者

发表于 2008-8-27 04:35:30 | 显示全部楼层
脚本语言自然在效率上比不上编译语言
吸吸
回复 支持 反对

使用道具 举报

Lv2.观梦者

傻♂逼

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

烫烫烫开拓者

 楼主| 发表于 2008-8-27 04:40:16 | 显示全部楼层
以下引用trentswd于2008-8-26 20:35:30的发言:

脚本语言自然在效率上比不上编译语言

所以会非常影响速度
哎呀,蛋疼什么的最有爱了
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-3-29 17:36

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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