Renders Isometric Maps!

GubiD's Isometric Map Renderer
Version: 1.0
By: GubiD

Introduction

This script takes an isometric map(predetermined by the isometric view script) and renders you a png of it including heights. This makes it easier to develop isometric tilesets and overall isometric maps. Cause it does all the placement etc for you.

Features
  • Renders Isomap to PNG file
  • Replaceable default tiles (IsoNode.png in the Pictures folder)

Screenshots
Image

Demo
Why Yes!

Script

  1. #==============================================================================
  2. # Iso Node - The iso sprite
  3. #==============================================================================
  4. class IsoNode < Sprite
  5.   def initialize(x,y)
  6.      super(nil)
  7.      @sx = x
  8.      @sy = y
  9.      @real_x = x*128
  10.      @real_y = y*128
  11.      @iso = $game_map.iso?
  12.      self.bitmap = RPG::Cache.picture("IsoNode").clone
  13.      @h = 0
  14.   end
  15.   def update
  16.      @h = get_height
  17.      self.x = screen_x
  18.      self.y = screen_y
  19.      self.z = screen_z
  20.      super
  21.   end
  22.   #----------------------------------------------------------------------------
  23.   # Get Height - Return Screen Tile Height for the current position
  24.   #----------------------------------------------------------------------------
  25.   def get_height
  26.      return 0 if !@iso
  27.      tile_id = $game_map.map.data[@sx,@sy,0]
  28.      return 0 if tile_id == nil
  29.      t_x = (tile_id - 384) % 8      
  30.      t_y = (tile_id - 384) / 8
  31.      th = t_x + t_y * 8
  32.      return th
  33.   end
  34.   #----------------------------------------------------------------------------
  35.   # Screen X - sets X based on current map position
  36.   #----------------------------------------------------------------------------
  37.   def screen_x
  38.      if !@iso
  39.         return (@real_x - $game_map.display_x + 3) / 4 + 16
  40.      else
  41.         return   (@real_x - @real_y)/4 + 32*$game_map.height - 0 - $game_map.display_x/4+2-32
  42.      end
  43.   end
  44.   #----------------------------------------------------------------------------
  45.   # Screen Y - sets Y based on current map position
  46.   #----------------------------------------------------------------------------
  47.   def screen_y
  48.      if !@iso
  49.         y = (@real_y - $game_map.display_y + 3) / 4 + 32
  50.         return y
  51.      else
  52.         y = ((@real_y + @real_x) / 8 + 24 - $game_map.display_y / 4 - (@h) * 8) + 7 -32
  53.         return y
  54.      end
  55.   end
  56.   def screen_z
  57.      if !@iso
  58.         # Get screen coordinates from real coordinates and map display position
  59.         z = (@real_y - $game_map.display_y + 3) / 4 + 32
  60.         # If height exceeds 32, then add 31
  61.         return z
  62.      else
  63.        
  64.         z = @h * 8
  65.         if screen_y < $game_player.screen_y
  66.            if @h > $game_player.screen_h
  67.               z -= 4
  68.            end
  69.         else
  70.            if @h > $game_player.screen_h
  71.               z -= 2
  72.            end
  73.         end
  74.         return z
  75.      end
  76.   end
  77. end
  78.  
  79. $drawn_iso_maps = []
  80. #==============================================================================
  81. # Scene Map Changes
  82. #==============================================================================
  83. class Scene_Map
  84.   attr_reader :iso_sprites
  85.   alias upd_gm_draw_iso update
  86.   def update
  87.      upd_gm_draw_iso
  88.      update_iso_draw
  89.   end
  90.   def update_iso_draw
  91.      if $game_map.iso?
  92.         if !$drawn_iso_maps.include?($game_map.map_id)
  93.            if @iso_sprites == nil
  94.               draw_iso_frame
  95.            else
  96.               clear_iso_frame
  97.               draw_iso_frame
  98.            end
  99.         else
  100.            return if @iso_sprites == nil
  101.            @iso_sprites.each {|spr| spr.update}
  102.         end
  103.      end
  104.   end
  105.   def clear_iso_frame
  106.      @iso_sprites.each {|spr| spr.dispose}
  107.      @iso_sprites = nil
  108.   end
  109.   def draw_iso_frame
  110.      @iso_sprites = []
  111.      for x in 0...$game_map.width
  112.         for y in 0...$game_map.height
  113.            @iso_sprites.push(IsoNode.new(x,y))
  114.         end
  115.      end
  116.      $drawn_iso_maps.push($game_map.map_id)
  117.      name = $data_map_info[$game_map.map_id].name
  118.      MapScreenshotMaker.take_iso(name)
  119.   end
  120. end
  121.  
  122. #==============================================================================
  123. # ** MapScreenshotMaker
  124. #==============================================================================
  125. module MapScreenshotMaker
  126.   def self.take_iso(filename="IsoShot", dir = "Graphics/IsoMaps/")
  127.      #create bitmap
  128.      both = $game_map.width+$game_map.height
  129.      bitmap = Bitmap.new(both*32, (both/2)*32)
  130.      #save current display view
  131.      sx, sy = $game_map.display_x, $game_map.display_y
  132.      #set to 0
  133.      $game_map.display_x, $game_map.display_y = 0,0
  134.      #update sprites, and render to bitmap
  135.      $scene.iso_sprites.each {|spr|
  136.         spr.update
  137.         bitmap.blt(spr.x, spr.y, spr.bitmap, Rect.new(0,0,64,32))
  138.      }
  139.      #save bitmap to file
  140.      bitmap.make_png(filename, dir)
  141.      #reset display view
  142.      $game_map.display_x, $game_map.display_y = sx, sy
  143.      #update iso sprites to location
  144.      $scene.iso_sprites.each {|spr|
  145.         spr.update
  146.      }
  147.   end
  148. end
Expand to see the code.


Instructions

This script has a couple of requirements:
  • SDK
  • MACL
  • Isometric View
It would be best to use the demo, but you would simply place this script in a project with the above required scripts (which are included in the demo) and transfer your player to a map including the name of ISO and it will be rendered for you to the Graphics\IsoMaps folder of your project.

Compatibility
This will not work in VX

Credits and Thanks
Makers of the SDK and MACL for giving me the ability to write to PNG file.
McCaladtogel for his original Isometric script, which I modified into Isometric Views (XP/VX)
Seigfried for his help in nailing down Isometric height movement.

Author's Notes
This script is only for RMXP and cannot be used inside of VX. However you can render your maps in XP, and import the made tilesets to VX.
I dont know of any compatiblity problems. However do keep in mind that this script displays 100's of sprites on screen at once. This causes major lag, but shouldnt really matter, because it is intended for game dev only. As in to render the maps for you, so that you can turn them into what you want.

Terms and Conditions
Intended for Development use only(cause its too slow otherwise). Please do not repost this script elsewhere without my permission.
Quite impressive.
I already was planing to use the GTBS after you added the ismetric battle with height, now with this script it would be easier to create the maps.
Thank you for the comments. I hope to see some new iso tilesets evolve from this. At least that was my main goal. Plus it saved me huge amounts of time while making some of mine. I will release them once, I have polished them up a little bit.
FF Tactis here i come
Wow, this will be abundantly helpful for tileset creation. Thank you very much for making this.

Original thread: https://www.hbgames.org/forums/viewtopic.php?t=64600