Rudimentary map wrapping added
This commit is contained in:
parent
652ef21a50
commit
a28082cae3
|
@ -136,6 +136,7 @@ DEF_PROP_OBJ_REF(Tilemap, Table, FlashData, "flash_data")
|
|||
DEF_PROP_OBJ_REF(Tilemap, Table, Priorities, "priorities")
|
||||
|
||||
DEF_PROP_B(Tilemap, Visible)
|
||||
DEF_PROP_B(Tilemap, Wrapping)
|
||||
|
||||
DEF_PROP_I(Tilemap, OX)
|
||||
DEF_PROP_I(Tilemap, OY)
|
||||
|
@ -165,6 +166,7 @@ tilemapBindingInit()
|
|||
INIT_PROP_BIND( Tilemap, FlashData, "flash_data" );
|
||||
INIT_PROP_BIND( Tilemap, Priorities, "priorities" );
|
||||
INIT_PROP_BIND( Tilemap, Visible, "visible" );
|
||||
INIT_PROP_BIND( Tilemap, Wrapping, "wrapping" );
|
||||
INIT_PROP_BIND( Tilemap, OX, "ox" );
|
||||
INIT_PROP_BIND( Tilemap, OY, "oy" );
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -35,3 +35,7 @@ end
|
|||
def clamp_panorama
|
||||
$game_map.clamped_panorama = true
|
||||
end
|
||||
|
||||
def wrap_map
|
||||
$game_map.wrapping = true
|
||||
end
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -236,6 +236,7 @@ struct TilemapPrivate
|
|||
Table *mapData;
|
||||
Table *priorities;
|
||||
bool visible;
|
||||
bool wrapping;
|
||||
Vec2i origin;
|
||||
|
||||
Vec2i dispPos;
|
||||
|
@ -328,6 +329,7 @@ struct TilemapPrivate
|
|||
mapData(0),
|
||||
priorities(0),
|
||||
visible(true),
|
||||
wrapping(false),
|
||||
flashAlphaIdx(0),
|
||||
atlasSizeDirty(false),
|
||||
atlasDirty(false),
|
||||
|
@ -656,7 +658,7 @@ struct TilemapPrivate
|
|||
{
|
||||
int ox = x + viewpPos.x;
|
||||
int oy = y + viewpPos.y;
|
||||
if (ox < 0 || oy < 0 || ox >= mapData->xSize() || oy >= mapData->ySize())
|
||||
if (!wrapping && (ox < 0 || oy < 0 || ox >= mapData->xSize() || oy >= mapData->ySize()))
|
||||
return;
|
||||
|
||||
int tileInd =
|
||||
|
@ -1149,6 +1151,7 @@ DEF_ATTR_RD_SIMPLE(Tilemap, MapData, Table*, p->mapData)
|
|||
DEF_ATTR_RD_SIMPLE(Tilemap, FlashData, Table*, p->flashMap.getData())
|
||||
DEF_ATTR_RD_SIMPLE(Tilemap, Priorities, Table*, p->priorities)
|
||||
DEF_ATTR_RD_SIMPLE(Tilemap, Visible, bool, p->visible)
|
||||
DEF_ATTR_SIMPLE(Tilemap, Wrapping, bool, p->wrapping)
|
||||
DEF_ATTR_RD_SIMPLE(Tilemap, OX, int, p->origin.x)
|
||||
DEF_ATTR_RD_SIMPLE(Tilemap, OY, int, p->origin.y)
|
||||
|
||||
|
|
|
@ -63,6 +63,7 @@ public:
|
|||
DECL_ATTR( FlashData, Table* )
|
||||
DECL_ATTR( Priorities, Table* )
|
||||
DECL_ATTR( Visible, bool )
|
||||
DECL_ATTR( Wrapping, bool )
|
||||
DECL_ATTR( OX, int )
|
||||
DECL_ATTR( OY, int )
|
||||
|
||||
|
|
Loading…
Reference in New Issue