Rudimentary map wrapping added

This commit is contained in:
Mathew Velasquez 2015-11-20 21:08:00 -05:00
parent 652ef21a50
commit a28082cae3
7 changed files with 26 additions and 1 deletions

View file

@ -108,6 +108,13 @@ class Game_Character
# Increase animation count by 1
@anime_count += 1
end
# Wrap position
if @x * 128 == @real_x && @y * 128 == @real_y
@x %= $game_map.width
@y %= $game_map.height
@real_x = @x * 128
@real_y = @y * 128
end
end
#--------------------------------------------------------------------------
# * Frame Update (stop)

View file

@ -27,6 +27,7 @@ class Game_Map
attr_accessor :bg_name # bg file name
attr_accessor :particles_type # particles name
attr_accessor :clamped_panorama # panorama is clamped?
attr_accessor :wrapping # map is wrapping?
attr_reader :passages # passage table
attr_reader :priorities # prioroty table
attr_reader :terrain_tags # terrain tag table
@ -106,6 +107,8 @@ class Game_Map
@particles_type = nil
# Unclamp panorama
@clamped_panorama = false
# Unwrap map
@wrapping = false
# Construct map name path
mapinfo = load_data("Data/MapInfos.rxdata")
@ -225,6 +228,7 @@ class Game_Map
# y : y-coordinate
#--------------------------------------------------------------------------
def valid?(x, y)
return true if @wrapping
return (x >= 0 and x < width and y >= 0 and y < height)
end
#--------------------------------------------------------------------------
@ -241,6 +245,8 @@ class Game_Map
# impassable
return false
end
x %= self.width
y %= self.height
# Change direction (0,2,4,6,8,10) to obstacle bit (0,1,2,4,8,0)
bit = (1 << (d / 2 - 1)) & 0x0f
# Loop in all events

View file

@ -35,3 +35,7 @@ end
def clamp_panorama
$game_map.clamped_panorama = true
end
def wrap_map
$game_map.wrapping = true
end

View file

@ -124,6 +124,8 @@ class Spriteset_Map
# * Frame Update
#--------------------------------------------------------------------------
def update
# Update tilemap
@tilemap.wrapping = $game_map.wrapping
# If panorama is different from current one
if @panorama_name != $game_map.panorama_name or
@panorama_hue != $game_map.panorama_hue