Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

use RMXP maps in RMVX (Tilemap 66RPG, 0.70)

a research of Tilemap. I know there was already a "Tilemap 1.0", but I'm not satisifed with the algorithm (when I use that script, I can't get 40 FPS, and there are some priorities bugs), so I wrote this one.

use this algorithm in RMVX-RGSS2.0, we can use our RMXP maps & RMXP Tilemap resources easily. and also, we can use 16*16 resources easily.

I have not finished dynamic autotile and cell flash, etc. Because there is no requirement now^^

First post at : http://bbs.66rpg.com/forumTopicRead.asp?id=75115

by 柳柳@66RPG

Code:
 #==============================================================================
# â–  Spriteset_Map
#------------------------------------------------------------------------------
#  处理地图画面活动块和元件的类。本类在
# Scene_Map 类的内部使用。
#==============================================================================

class Spriteset_Map
  #--------------------------------------------------------------------------
  # ● 初始化对像
  #--------------------------------------------------------------------------
  def initialize
    # 生成显示端口
    @viewport1 = Viewport.new(0, 0, 640, 480)
    @viewport2 = Viewport.new(0, 0, 640, 480)
    @viewport3 = Viewport.new(0, 0, 640, 480)
    @viewport2.z = 200
    @viewport3.z = 5000
    # 生成元件地图
    # @tilemap = Tilemap.new(@viewport1)
    # @tilemap.tileset = RPG::Cache.tileset($game_map.tileset_name)
    # for i in 0..6
    #   autotile_name = $game_map.autotile_names[i]
    #   @tilemap.autotiles[i] = RPG::Cache.autotile(autotile_name)
    # end
    # @tilemap.map_data = $game_map.data
    # @tilemap.priorities = $game_map.priorities
    
    @map_sp = []
    for i in 0...$game_map.height + 7
      @map_sp[i] = Sprite.new(@viewport1)
      @map_sp[i].bitmap = Bitmap.new($game_map.width * 32 , 192)
#      @map_sp[i].bitmap.draw_text(0, 0, $game_map.width * 32 , 32, i.to_s)
      @map_sp[i].z = 32 + i * 32
    end
    
    for i in 0...$game_map.width
      for j in 0...$game_map.height
        for k in [0,1,2]
          tile_id = $game_map.data[i,j,k]
          next if tile_id == 0
          numb = j + $game_map.priorities[tile_id]
          if tile_id < 384
            tid = tile_id / 48 
            bmp = at48(tile_id - tid * 48, RPG::Cache.autotile($game_map.autotile_names[tid-1]))
            tx = i * 32
            ty = (5 - $game_map.priorities[tile_id])* 32 
            @map_sp[numb].bitmap.blt(tx, ty, bmp, bmp.rect)
            next
          end
          x = (tile_id - 384) % 8 * 32
          y = (tile_id - 384) / 8 * 32
          rect = Rect.new(x, y, 32, 32)
          tx = i * 32
          ty = (5 - $game_map.priorities[tile_id])* 32 
          @map_sp[numb].bitmap.blt(tx, ty, RPG::Cache.tileset($game_map.tileset_name), rect)
#          @map_sp[numb].bitmap.draw_text(tx, ty, 32, 32, numb.to_s)
        end
      end
    end
    
    for i in 0...$game_map.height + 6
      @map_sp[i].y = i * 32 -  160
    end
    
    
    # 生成远景平面
    @panorama = Plane.new(@viewport1)
    @panorama.z = -1000
    # 生成雾平面
    @fog = Plane.new(@viewport1)
    @fog.z = 3000
    # 生成角色活动块
    @character_sprites = []
    for i in $game_map.events.keys.sort
      sprite = Sprite_Character.new(@viewport1, $game_map.events[i])
      @character_sprites.push(sprite)
    end
    @character_sprites.push(Sprite_Character.new(@viewport1, $game_player))
    # 生成天气
    @weather = RPG::Weather.new(@viewport1)
    # 生成图片
    @picture_sprites = []
    for i in 1..50
      @picture_sprites.push(Sprite_Picture.new(@viewport2,
        $game_screen.pictures[i]))
    end
    # 生成计时器块
    @timer_sprite = Sprite_Timer.new
    # 刷新画面
    update
  end
  #--------------------------------------------------------------------------
  # ● 释放
  #--------------------------------------------------------------------------
  def dispose
    # 释放元件地图
    # @tilemap.tileset.dispose
    # for i in 0..6
    #   @tilemap.autotiles[i].dispose
    # end
    # @tilemap.dispose
    # 释放远景平面
    @panorama.dispose
    # 释放雾平面
    @fog.dispose
    # 释放角色活动块
    for sprite in @character_sprites
      sprite.dispose
    end
    # 释放天候
    @weather.dispose
    # 释放图片
    for sprite in @picture_sprites
      sprite.dispose
    end
    # 释放计时器块
    @timer_sprite.dispose
    # 释放显示端口
    @viewport1.dispose
    @viewport2.dispose
    @viewport3.dispose
  end
  #--------------------------------------------------------------------------
  # ● 刷新画面
  #--------------------------------------------------------------------------
  def update
    # 远景与现在的情况有差异发情况下
    if @panorama_name != $game_map.panorama_name or
       @panorama_hue != $game_map.panorama_hue
      @panorama_name = $game_map.panorama_name
      @panorama_hue = $game_map.panorama_hue
      if @panorama.bitmap != nil
        @panorama.bitmap.dispose
        @panorama.bitmap = nil
      end
      if @panorama_name != ""
        @panorama.bitmap = RPG::Cache.panorama(@panorama_name, @panorama_hue)
      end
      Graphics.frame_reset
    end
    # 雾与现在的情况有差异的情况下
    if @fog_name != $game_map.fog_name or @fog_hue != $game_map.fog_hue
      @fog_name = $game_map.fog_name
      @fog_hue = $game_map.fog_hue
      if @fog.bitmap != nil
        @fog.bitmap.dispose
        @fog.bitmap = nil
      end
      if @fog_name != ""
        @fog.bitmap = RPG::Cache.fog(@fog_name, @fog_hue)
      end
      Graphics.frame_reset
    end
    # 刷新元件地图
    for i in 0...$game_map.height + 6
      @map_sp[i].y = i * 32 -  160 - $game_map.display_y / 4
      @map_sp[i].x = - $game_map.display_x / 4
      @map_sp[i].z = (i * 128 - $game_map.display_y + 3) / 4 + 32
    end
#    @tilemap.ox = $game_map.display_x / 4
#    @tilemap.oy = $game_map.display_y / 4
#    @tilemap.update
    # 刷新远景平面
    @panorama.ox = $game_map.display_x / 8
    @panorama.oy = $game_map.display_y / 8
    # 刷新雾平面
    @fog.zoom_x = $game_map.fog_zoom / 100.0
    @fog.zoom_y = $game_map.fog_zoom / 100.0
    @fog.opacity = $game_map.fog_opacity
    @fog.blend_type = $game_map.fog_blend_type
    @fog.ox = $game_map.display_x / 4 + $game_map.fog_ox
    @fog.oy = $game_map.display_y / 4 + $game_map.fog_oy
    @fog.tone = $game_map.fog_tone
    # 刷新角色活动块
    for sprite in @character_sprites
      sprite.update
    end
    # 刷新天候图形
    @weather.type = $game_screen.weather_type
    @weather.max = $game_screen.weather_max
    @weather.ox = $game_map.display_x / 4
    @weather.oy = $game_map.display_y / 4
    @weather.update
    # 刷新图片
    for sprite in @picture_sprites
      sprite.update
    end
    # 刷新计时器块
    @timer_sprite.update
    # 设置画面的色调与震动位置
    @viewport1.tone = $game_screen.tone
    @viewport1.ox = $game_screen.shake
    # 设置画面的闪烁色
    @viewport3.color = $game_screen.flash_color
    # 刷新显示端口
    @viewport1.update
    @viewport3.update
  end
  
  def at48(i, bmp)
    a = [
      [27,28,5 ,28,27,6 ,5 ,6 ,27,28,5 ,28,27,6 ,5 ,6 ],
      [33,34,33,34,33,34,33,34,33,12,33,12,33,12,33,12],
      [27,28,5 ,28,27,6 ,5 ,6 ,27,28,5 ,28,27,6 ,5 ,6 ],
      [11,34,11,34,11,34,11,34,11,12,11,12,11,12,11,12],
      [25,26,25,6 ,25,26,25,6 ,15,16,15,16,15,16,15,16],
      [31,32,31,32,31,12,31,12,21,22,21,12,11,22,11,12],
      [29,30,29,30,5 ,30,5 ,30,39,40,5 ,40,39,6 ,5 ,6 ],
      [35,36,11,36,35,36,11,36,45,46,45,46,45,46,45,46],
      [25,30,15,16,13,14,13,14,17,18,17,18,41,42,5 ,42],
      [31,36,45,46,19,20,19,12,23,24,11,24,47,48,47,48],
      [37,38,37,6 ,13,18,13,14,37,42,17,18,13,18,1 ,2 ],
      [43,44,43,44,19,24,43,44,43,48,47,48,43,48,7 ,8 ]
      ]
    bitmap = Bitmap.new(32, 32)
    xy = getrect(i)
    y = xy[1] * 2
    x = xy[0] * 2
    #p i,y,x,a[y][x],a[y][x+1],a[y+1][x],a[y+1][x+1]
    bitmap.blt(0, 0, bmp, Rect.new(get_at(a[y][x])[0] * 16,get_at(a[y][x])[1] * 16, 16,16))
    bitmap.blt(16, 0, bmp, Rect.new(get_at(a[y][x+1])[0] * 16,get_at(a[y][x+1])[1] * 16, 16,16))
    bitmap.blt(0, 16, bmp, Rect.new(get_at(a[y+1][x])[0] * 16,get_at(a[y+1][x])[1]* 16, 16,16))
    bitmap.blt(16, 16, bmp, Rect.new(get_at(a[y+1][x+1])[0] * 16,get_at(a[y+1][x+1])[1]* 16, 16,16))
    return bitmap
    
  end
  
  def getrect(id)
    x = id % 8 
    y = id / 8
    return [x, y]
  end    
  
  def get_at(id)
    id -= 1
    x = id % 6
    y = id / 6
    return [x, y]
  end  
      
end
 

OS

Sponsor

Haha, already got scripts for VX going? I suppose this means VX was released in Japan already?

Would it be possible to see English comments in there?
 
Hmm, VX is still twenty-five days from release in Japan. Do you have access to the program, already? Are you an employee of Enterbrain!?
 
No he just saying that, in a near future, when rmvx will be out and as RGSS2.0 will be closed to the current RGSS, we could then use it with VX, if we want to use RMXP maps.

But I assume this script will need some edit.
 

Sles

Member

Chronnopro;331186":e49hz3ub said:
so that means that all the scripts released for rmxp will not work on vx?

You are correct. Most, if not all, of the modules will have been re-written, but not entirely changed. I'm under the impression that some scripts will only need minor edits.
 
Its good to see scripts are already in devlopment for the new RPG Maker. It would be a shame to not be able to use the RMXP scripts in RMVX, it seems like a big waste. Perhaps next year we'll be seeing topics with both versions of scripts. Complicates things a bit.
 
Luminier;329599":1i2kzj2h said:
Hmm, VX is still twenty-five days from release in Japan. Do you have access to the program, already? Are you an employee of Enterbrain!?


Still....
Lumi brings up a good point...
 
在66RPG上已看過了,在這裡在頂一下吧.
----------------------------------------------------------
For RGSS-2.0,this is a algorithm.Algorithm is not a program.if you don't know this word, you can look it up in a dictionary.
 
This was really nice of you to post this for us! ^_^

BTW, I just visited your site, and I love the way it looks.

@RPG Wizard
This is a RMVX script that works in RMXP. From what I know, the scripting system for RMVX is the same as the one used for RMXP, but it's just much cleaner.

I've not been over to the Ruby forge, but it's possible that the RGSS2 has been posted over there. I believe the old RGSS was posted there when RMXP was released.
 

Kaoii

Member

Sorry if this is a necropost, but I think this is something worth asking. Could this script possibly be used in RMVX to get around some of its mapping restrictions?
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top