Jump to content
Rpg²S Forum

*Isometric View 1.0


Luigi
 Share

Recommended Posts

Isometric View version 1.0

Descrizione:
Questa demo permette di creare delle mappe con un evolutissimo sistema di visuale isometrica, alternandolo anche a mappe normali, in cui sarà anche possibile creare scalinate che i pg potranno salire e scendere o mappe isometriche su più livelli d'altezza.

Autore:
by MGCaladtogel and Siegfried
Translated (in english) enhancements by GubiD

 


Screen

http://i218.photobucket.com/albums/cc200/GubiD/Iso3.jpg
http://i218.photobucket.com/albums/cc200/GubiD/Iso2.jpg
http://i218.photobucket.com/albums/cc200/GubiD/Iso1.jpg

 

Allegati
Demo

 

Istruzioni
Create 2 nuove classi e incollateci questi 2 script. Le istruzioni sono all'interno della demo

 

Script

 

 

 

#-------------------------------------------------------------------------------
# ? Script 2D_ISO, created by MGCaladtogel tranlated by GubiD
#-------------------------------------------------------------------------------
#==============================================================================
# New Variables: 
#  $game_map indicates the map of data (where you will place events)
#  $game_map_iso indicates the map into 2d-isometric view, although containing no events.
#==============================================================================

#==============================================================================
# ¦ Game_Map
#==============================================================================
class Game_Map
	#--------------------------------------------------------------------------
	# ? The scrolling must be carried out according to dimensions of chart
	#	 into isometric
	#--------------------------------------------------------------------------
	def scroll_down(distance)
		if $game_map.iso?
			corr = (($game_map.height + $game_map.width)%2 == 0 ? 0 : 4*16)
			@display_y = [@display_y + distance, 128*$game_map_iso.height - 4*480 - corr].min
		else
			@display_y = [@display_y + distance, (self.height - 15) * 128].min
		end
	end
	#--------------------------------------------------------------------------
	def scroll_right(distance)
		if $game_map.iso?
			@display_x = [@display_x + distance, 128*$game_map_iso.width - 4 * 640].min
		else
			@display_x = [@display_x + distance, (self.width - 20) * 128].min
		end
		
	end
end

#==============================================================================
# ¦ Game_Character
#==============================================================================
class Game_Character
	#--------------------------------------------------------------------------
	# ? Update the position of the characters to the screen according to x,y in isometric 
	#--------------------------------------------------------------------------
	def screen_x
		if $game_map.iso?
			return  (@real_x - @real_y)/4 + 32*$game_map.height - 0 - $game_map.display_x/4
		else
			return (@real_x - $game_map.display_x + 3) / 4 + 16
		end
	end
	#--------------------------------------------------------------------------
	def screen_y
		if $game_map.iso?
			y = (@real_y + @real_x) / 8 + 24 - $game_map.display_y/4
			if @jump_count >= @jump_peak
				n = @jump_count - @jump_peak
			else
				n = @jump_peak - @jump_count
			end
			return y - (@jump_peak * @jump_peak - n * n) / 2
		else
			y = (@real_y - $game_map.display_y + 3) / 4 + 32
			# Make y-coordinate smaller via jump count
			if @jump_count >= @jump_peak
				n = @jump_count - @jump_peak
			else
				n = @jump_peak - @jump_count
			end
			return y - (@jump_peak * @jump_peak - n * n) / 2
		end
	end
	#--------------------------------------------------------------------------
	def screen_z(height = 0)
		if $game_map.iso?
			if @always_on_top
				return 999
			end
			z = 9999#screen_y
			if @tile_id > 0
				return z + $game_map_iso.priorities[@tile_id] * (32 + (8*screen_th))
			end
		else # use default method
			if @always_on_top
				# 999, unconditional
				return 999
			end
			# Get screen coordinates from real coordinates and map display position
			z = (@real_y - $game_map.display_y + 3) / 4 + 32
			# If tile
			if @tile_id > 0
				# Add tile priority * 32
				return z + $game_map.priorities[@tile_id] * 32
				# If character
			else
				# If height exceeds 32, then add 31
				return z + ((height > 32) ? 31 : 0)
			end
		end
	end
end

#==============================================================================
# ¦ Game_Player
#==============================================================================
class Game_Player < Game_Character
	#--------------------------------------------------------------------------
	# ? Sets up use for directions using 1,3,7,9 coordinated to up/down/left/right
	#	 so that the scrolling occurs cleaner.
	#--------------------------------------------------------------------------
	alias gmpl_iso_update update
	def update
		if $game_map.iso?
			last_moving = moving?
			unless moving? or $game_system.map_interpreter.running? or
				@move_route_forcing or $game_temp.message_window_showing
				case Input.dir8
				when 1..2
					move_down
				when 3
					move_right
				when 4
					move_left
				when 7
					move_left
				when 6
					move_right
				when 8..9
					move_up
				end
			end
			last_real_x = @real_x
			last_real_y = @real_y
			super
			disp_y = screen_y + $game_map.display_y/4
			disp_x = screen_x + $game_map.display_x/4
			if CENTER_Y - (4*disp_y - $game_map.display_y) < 0
				$game_map.scroll_down(4*disp_y - $game_map.display_y - CENTER_Y)
			end
			if CENTER_X - (4*disp_x - $game_map.display_x) > 0
				$game_map.scroll_left(CENTER_X - (4*disp_x - $game_map.display_x))
			end
			if CENTER_X - (4*disp_x - $game_map.display_x) < 0
				$game_map.scroll_right(4*disp_x - $game_map.display_x - CENTER_X)
			end
			if CENTER_Y - (4*disp_y - $game_map.display_y) > 0
				$game_map.scroll_up(CENTER_Y - (4*disp_y - $game_map.display_y))
			end
			unless moving?
				if last_moving
					result = check_event_trigger_here([1,2])
					if result == false
						unless $DEBUG and Input.press?(Input::CTRL)
							if @encounter_count > 0
								@encounter_count -= 1
							end
						end
					end
				end
				if Input.trigger?(Input::C)
					check_event_trigger_here([0])
					check_event_trigger_there([0,1,2])
				end
			end
		else
			gmpl_iso_update
		end
	end
	
end

#==============================================================================
# ¦ Scene_Title
#==============================================================================
class Scene_Title
	alias main_orig main
	#--------------------------------------------------------------------------
	# ? Loads MapInfos so that Iso map id's can be loaded according to the current map.
	#--------------------------------------------------------------------------
	def main
		$data_map_infos		= load_data("Data/MapInfos.rxdata")
		main_orig
	end
end

#==============================================================================
# ¦ Spriteset_Map
#==============================================================================
class Spriteset_Map
	#--------------------------------------------------------------------------
	# ? Generates the map, then lays the iso view map (parent map) over it, but uses
	#	  $game_map for data
	#--------------------------------------------------------------------------
	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) #creates standard 2d map
		if $game_map.iso?
			map_infos = $data_map_infos[$game_map.map_id]
			$game_map_iso = Game_Map.new #creates new iso map
			$game_map_iso.setup(map_infos.parent_id) #draws map
			@tilemap.tileset = RPG::Cache.tileset($game_map_iso.tileset_name) #sets correct tileset
			for i in 0..6 #draws autotiles
				autotile_name = $game_map.autotile_names[i]
				@tilemap.autotiles[i] = RPG::Cache.autotile(autotile_name)
			end
			@tilemap.map_data = $game_map_iso.data #reads terrain tags and else
			@tilemap.priorities = $game_map_iso.priorities #sets iso map priorities
		else
			@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
		end
		@panorama = Plane.new(@viewport1) #create pan plane
		@panorama.z = -1000
		@fog = Plane.new(@viewport1)  #creates fog plane
		@fog.z = 3000
		@character_sprites = []#initializes character update thread
		for i in $game_map.events.keys.sort #add events to map from $game_map, NOT ISO
			sprite = Sprite_Character.new(@viewport1, $game_map.events[i])
			@character_sprites.push(sprite)
		end
		@character_sprites.push(Sprite_Character.new(@viewport1, $game_player)) #add player to map
		@weather = RPG::Weather.new(@viewport1) #draw weather
		@picture_sprites = [] 
		for i in 1..50 #draw setup pictures
			@picture_sprites.push(Sprite_Picture.new(@viewport2,
			$game_screen.pictures[i]))
		end
		@timer_sprite = Sprite_Timer.new #start timer
		update
	end
	#--------------------------------------------------------------------------
	# ? Caution: Updated the panorama to draw in the same fashion and update according to 
	#				iso view settings
	#	 Get the original displacement settings and expand them:
	#	   @panorama.ox = $game_map.display_x / 4
	#	   @panorama.oy = $game_map.display_y / 4
	#	 to :
	#	   @panorama.ox = $game_map.display_y / 8
	#	   @panorama.oy = $game_map.display_y / 8
	#--------------------------------------------------------------------------
	alias upd_iso_map update
	def update(map_id = $game_map.map_id)
		#if pan settings changed.. update pan info
		if $game_map.iso?
			if @panorama_name != $game_map_iso.panorama_name or
				@panorama_hue != $game_map_iso.panorama_hue
				@panorama_name = $game_map_iso.panorama_name
				@panorama_hue = $game_map_iso.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 #reset frame count to 0
			end
			#if fog settings changed.. update fog info
			if @fog_name != $game_map_iso.fog_name or @fog_hue != $game_map_iso.fog_hue
				@fog_name = $game_map_iso.fog_name
				@fog_hue = $game_map_iso.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 #reset frame count to 0
			end
			#update tilemap offset
			@tilemap.ox = $game_map.display_x / 4
			@tilemap.oy = $game_map.display_y / 4
			#redraw tilemap to current offset
			@tilemap.update
			#update pan and fog offsets.
			@panorama.ox = $game_map.display_x / 4
			@panorama.oy = $game_map.display_y / 4
			@fog.zoom_x = $game_map_iso.fog_zoom / 100.0
			@fog.zoom_y = $game_map_iso.fog_zoom / 100.0
			@fog.opacity = $game_map_iso.fog_opacity
			@fog.blend_type = $game_map_iso.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
			#update event and character sprites
			for sprite in @character_sprites
				sprite.update
			end
			#update weather
			@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
			#update pictures
			for sprite in @picture_sprites
				sprite.update
			end
			@timer_sprite.update
			#update screen tone/shake/flash
			@viewport1.tone = $game_screen.tone
			@viewport1.ox = $game_screen.shake
			@viewport3.color = $game_screen.flash_color
			@viewport1.update
			@viewport3.update
		else #use standard update process tilemap update process
			upd_iso_map
		end
	end
end

#==============================================================================
# ¦ Interpreter
#==============================================================================
class Interpreter
	#--------------------------------------------------------------------------
	# ? Change Map Settings
	#--------------------------------------------------------------------------
	def command_204
		case @parameters[0]
		when 0 #change panorama
			if $game_map.iso?
				$game_map_iso.panorama_name = @parameters[1]
				$game_map_iso.panorama_hue = @parameters[2]
			else
				$game_map.panorama_name = @parameters[1]
				$game_map.panorama_hue = @parameters[2]
			end
		when 1 #change fog settings
			if $game_map.iso?
				$game_map_iso.fog_name = @parameters[1]
				$game_map_iso.fog_hue = @parameters[2]
				$game_map_iso.fog_opacity = @parameters[3]
				$game_map_iso.fog_blend_type = @parameters[4]
				$game_map_iso.fog_zoom = @parameters[5]
				$game_map_iso.fog_sx = @parameters[6]
				$game_map_iso.fog_sy = @parameters[7]
			else
				$game_map.fog_name = @parameters[1]
				$game_map.fog_hue = @parameters[2]
				$game_map.fog_opacity = @parameters[3]
				$game_map.fog_blend_type = @parameters[4]
				$game_map.fog_zoom = @parameters[5]
				$game_map.fog_sx = @parameters[6]
				$game_map.fog_sy = @parameters[7]
			end
		when 2 #change battleback
			if $game_map.iso?
				$game_map_iso.battleback_name = @parameters[1]
				$game_temp_iso.battleback_name = @parameters[1]
			else
				$game_map.battleback_name = @parameters[1]
				$game_temp.battleback_name = @parameters[1]
			end
		end
		return true
	end
	#--------------------------------------------------------------------------
	# ? Change fog tone
	#--------------------------------------------------------------------------
	def command_205
		if $game_map.iso?
			$game_map_iso.start_fog_tone_change(@parameters[0], @parameters[1] * 2)
		else
			$game_map.start_fog_tone_change(@parameters[0], @parameters[1] * 2)
		end
		return true
	end
	#--------------------------------------------------------------------------
	# ? Change fog opacity
	#--------------------------------------------------------------------------
	def command_206
		if $game_map.iso?
			$game_map_iso.start_fog_opacity_change(@parameters[0], @parameters[1] * 2)
		else
			$game_map.start_fog_opacity_change(@parameters[0], @parameters[1] * 2)
		end
		return true
	end
end

 

 

 

 

 

 

#==============================================================================
# o Sprite_Character add-on : Fix Pic
#------------------------------------------------------------------------------
# Script curtisy of Siegfried which is made to work with MGCaladtogel's iso script
#------------------------------------------------------------------------------
# Updates passability to check height changes
#------------------------------------------------------------------------------
# Rules for the map passabilities :
# -Apply the numbered tileset
# -Each number is equivalent to a height (tileset infinite, infinite height)
# -For the nonpassable tiles, put an inaccessible height.
#==============================================================================
# o ISO_LVL2_Config
#============================================================================== 
module ISO_LVL2_Config
	# Passable height from one tile to another
	DIFF_N = 2
	# Passable height from one tile to another: stairs, height change
	DIFF_L = 2
	# Falling speed
	FALLING_SPEED = 0.5
end

#==============================================================================
# o Game_Map
#==============================================================================
class Game_Map
	#--------------------------------------------------------------------------
	# o Attributes
	#--------------------------------------------------------------------------
	attr_accessor   :map
	#is iso map?
	def iso?
		if $data_map_infos[@map_id].name.include?("ISO")
			return true
		else
			return false
		end
	end
end

#==============================================================================
# o Game_Character
#==============================================================================
class Game_Character
	#--------------------------------------------------------------------------
	# o Attributes
	#--------------------------------------------------------------------------
	attr_accessor   :x
	attr_accessor   :y
	attr_accessor   :h
	attr_accessor   :th
	
	#--------------------------------------------------------------------------
	# o Initialize
	#--------------------------------------------------------------------------
	alias sieg_iso_initialize initialize
	def initialize
		@h = 0
		@th = 0
		sieg_iso_initialize
	end
	#--------------------------------------------------------------------------
	# o Screen_th : height of the ground
	#--------------------------------------------------------------------------
	def screen_th
		tile_id = $game_map.map.data[self.x,self.y,0]
		t_x = (tile_id - 384) % 8	 
		t_y = (tile_id - 384) / 8
		th = t_x + t_y * 8
		return th
	end
	#--------------------------------------------------------------------------
	# o Screen_h : height of the character
	#--------------------------------------------------------------------------
	def screen_h
		return @h 
	end
	
	#--------------------------------------------------------------------------
	# Update character/event rise/fall according to position on map.
	#--------------------------------------------------------------------------
	alias iso_gm_update update
	def update
		if $game_map.iso?
			if screen_h < screen_th
				@h = screen_th
			elsif screen_h > screen_th
				if (screen_h - screen_th) > 1.5
					@h -= [iSO_LVL2_Config::FALLING_SPEED * 3, 1].min
				else
					@h -= ISO_LVL2_Config::FALLING_SPEED
				end
			end 
		end
		iso_gm_update
	end
	#--------------------------------------------------------------------------
	# o Screen_x
	#--------------------------------------------------------------------------
	alias iso_screen_x screen_x
	def screen_x
		return  iso_screen_x if !$game_map.iso?
		return  (@real_x - @real_y)/4 + 32 * $game_map.height - 0 - $game_map.display_x / 4
	end
	#--------------------------------------------------------------------------
	# o Screen_y
	#--------------------------------------------------------------------------
	alias iso_screen_y screen_y
	def screen_y
		return iso_screen_y if !$game_map.iso?
		y = (@real_y + @real_x) / 8 + 24 - $game_map.display_y / 4 - (self.screen_h) * 8
		if @jump_count >= @jump_peak
			n = @jump_count - @jump_peak
		else
			n = @jump_peak - @jump_count
		end
		return y - (@jump_peak * @jump_peak - n * n) / 2
	end
	#--------------------------------------------------------------------------
	# o Screen_z
	#--------------------------------------------------------------------------
	alias iso_screen_z screen_z
	def screen_z(height = 0)
		return iso_screen_z if !$game_map.iso?
		if @always_on_top
			return 999
		end
		z = screen_y
		if @tile_id > 0
			return z + $game_map_iso.priorities[@tile_id] * 32
		else
			return z + ((height > 32) ? 31 : 0)
		end
	end
end

#==============================================================================
# o Passabilities and interactions with events
#==============================================================================
#==============================================================================
# o Game_Character
#==============================================================================
class Game_Character
	#--------------------------------------------------------------------------
	# o Passable?
	#--------------------------------------------------------------------------
	alias sieg_gc_passable? passable?
	def passable?(x, y, d)
		if !$game_map.iso?
			return sieg_gc_passable?(x, y, d)
		end
		@diff_n = ISO_LVL2_Config::DIFF_N
		@diff_l = ISO_LVL2_Config::DIFF_L
		
		new_x = x + (d == 6 ? 1 : d == 4 ? -1 : d == 1 ? -1 : d == 3 ? 1 : d == 7 ? -1 : d == 9 ? 1 : 0)
		new_y = y + (d == 2 ? 1 : d == 8 ? -1 : d == 1 ? 1 : d == 3 ? 1 : d == 7 ? -1 : d == 9 ? -1 : 0)
		
		
		tile_id = $game_map.map.data[x, y, 0]
		t_x= (tile_id - 384)%8	 
		t_y= (tile_id - 384)/8
		h = t_x + t_y * 8
		
		new_tile_id = $game_map.map.data[new_x, new_y,0]
		new_t_x= (new_tile_id - 384)%8	 
		new_t_y= (new_tile_id - 384)/8
		new_h = new_t_x + new_t_y * 8
		
		tile_tag = $game_map.terrain_tag(x, y)
		tile_tag_new = $game_map.terrain_tag(new_x, new_y)
		
		if tile_tag == 1
			@diff = @diff_l
		else
			@diff = @diff_n
		end
		
		unless $game_map.valid?(new_x, new_y) and (new_h - h) <= @diff and (new_h - h) >= -@diff
			return false
		end
		
		if @through
			return true
		end
		
		unless $game_map.passable?(x, y, d, self) and (new_h - h) <= @diff and (new_h - h) >= -@diff
			return false
		end
		
		unless $game_map.passable?(new_x, new_y, 10 - d) and (new_h - h) <= @diff and (new_h - h) >= -@diff
			return false
		end
		
		for event in $game_map.events.values
			if event.x == new_x and event.y == new_y and (new_h - h) <= @diff and (new_h - h) >= -@diff
				unless event.through and (new_h - h) <= @diff_n
					if self != $game_player
						return false
					end
					if event.character_name != ""
						return false
					end
				end
			end
		end
		
		if $game_player.x == new_x and $game_player.y == new_y and (new_h - h) <= @diff and (new_h - h) >= -@diff
			unless $game_player.through
				if @character_name != ""
					return false
				end
			end
		end
		
		return true
	end
end

#==============================================================================
# o Game_Event
#==============================================================================
class Game_Event < Game_Character
	#--------------------------------------------------------------------------
	# o Start
	#--------------------------------------------------------------------------
	alias iso_evnt_start start
	def start
		if !$game_map.iso?
			iso_evnt_start
			return
		end
		@diff_n = 1
		# Dialogue 
		tile_id = $game_map.map.data[$game_player.x,$game_player.y,0]
		t_x = (tile_id - 384) % 8	 
		t_y = (tile_id - 384) / 8
		h = t_x + t_y * 8
		
		ev_tile_id = $game_map.map.data[self.x,self.y,0]
		ev_t_x = (ev_tile_id - 384) % 8	 
		ev_t_y = (ev_tile_id - 384) / 8
		ev_h = ev_t_x + ev_t_y * 8
		
		if @list.size > 1 and (ev_h - h).abs <= @diff_n
			@starting = true
		end
	end
end

 

 

 

Link to comment
Share on other sites

L'avevo già visto su rmxp.org, ma c'è un problema non da sottovalutare...

Bisognacrearsi i chipset (o tileset) da soli per intero...

Un po' esagerato...

 

Volete due giochi Completi e Seri fatti con RPG MAKER? Cliccate su...

www.raldon.altervista.org

 

Problemi con Raldon? Segnalali su...

www.raldon.forumfree.net

 

Partecipante al Rpg2s.net Game Contest 2008/2009

http://www.rpg2s.net/contest/GameContest0809/gc0809-bannerino.jpg

Gioco in Sviluppo: Raldon

 

 

Posizioni raggiunte nei Contest

http://rpg2s.net/gif/SCContest1Oct.gifhttp://rpg2s.net/gif/SCContest1Oct.gifhttp://rpg2s.net/gif/SCContest3Oct.gifhttp://img76.imageshack.us/img76/1260/destroy3gr3.pnghttp://img233.imageshack.us/img233/7186/comics2hd8.gifhttp://www.rpg2s.net/gif/GC_bestoftool3.gif

http://www.rpg2s.net/gif/GC_premio3.gifhttp://www.rpg2s.net/gif/GC_premio3.gifhttp://www.rpg2s.net/gif/GC_premio1.gifhttp://www.rpg2s.net/gif/GC_premio2.gifhttp://www.rpg2s.net/gif/GC_grafica3.gifhttp://www.rpg2s.net/gif/GC_programmazione3.gifhttp://www.rpg2s.net/gif/GC_programmazione1.gifhttp://www.rpg2s.net/awards/furordipopolo/Popolo3K.gifhttp://www.rpg2s.net/awards/furordipopolo/Popolo2XP.gifhttp://www.rpg2s.net/awards/furordipopolo/Popolo2BEST.gif

http://www.rpg2s.net/awards/bestuser2.jpghttp://www.rpg2s.net/awards/bestmaker2.jpghttp://www.rpg2s.net/awards/mostpresent1.jpghttp://www.rpg2s.net/awards/mostproductive1.jpg

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...