realtime map resizing
This commit is contained in:
parent
3cb8091b11
commit
f67cb9ce78
|
|
@ -40,7 +40,7 @@ class DynamicLight
|
||||||
def update
|
def update
|
||||||
# dont render light if its disabled or not awaked
|
# dont render light if its disabled or not awaked
|
||||||
@light_sprite.visible = Settings[:light] && $light.awaked
|
@light_sprite.visible = Settings[:light] && $light.awaked
|
||||||
if (!Settings[:light] && $light.awaked)
|
if !Settings[:light] || !$light.awaked
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -422,7 +422,7 @@ class Game_Map
|
||||||
tile_id = data[x, y, i]
|
tile_id = data[x, y, i]
|
||||||
if tile_id == nil
|
if tile_id == nil
|
||||||
next #return 0
|
next #return 0
|
||||||
elsif @terrain_tags[tile_id] > 0
|
elsif @terrain_tags[tile_id] && @terrain_tags[tile_id] > 0
|
||||||
return @terrain_tags[tile_id]
|
return @terrain_tags[tile_id]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -549,4 +549,9 @@ class Game_Map
|
||||||
end
|
end
|
||||||
@map.data[x, y, z]
|
@map.data[x, y, z]
|
||||||
end
|
end
|
||||||
|
def resize(x, y, z)
|
||||||
|
@map.data.resize(x, y, z)
|
||||||
|
@map.width = x
|
||||||
|
@map.height = y
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -62,9 +62,9 @@ void Table::resize(int x, int y, int z){
|
||||||
|
|
||||||
std::vector<int16_t> newData(x*y*z);
|
std::vector<int16_t> newData(x*y*z);
|
||||||
|
|
||||||
for (int k = 0; k < std::min(z, zs); ++k)
|
for (int k = 0; k < z; ++k)
|
||||||
for (int j = 0; j < std::min(y, ys); ++j)
|
for (int j = 0; j < y; ++j)
|
||||||
for (int i = 0; i < std::min(x, xs); ++i)
|
for (int i = 0; i < x; ++i)
|
||||||
newData[x*y*k + x*j + i] = at(i, j, k);
|
newData[x*y*k + x*j + i] = at(i, j, k);
|
||||||
|
|
||||||
data.swap(newData);
|
data.swap(newData);
|
||||||
|
|
|
||||||
15
src/table.h
15
src/table.h
|
|
@ -52,11 +52,22 @@ public:
|
||||||
|
|
||||||
/* <internal */
|
/* <internal */
|
||||||
inline int16_t &at(int x, int y = 0, int z = 0){
|
inline int16_t &at(int x, int y = 0, int z = 0){
|
||||||
return data[xs*ys*z + xs*y + x];
|
int pos = xs*ys*z + xs*y + x;
|
||||||
|
if (pos >= 0 && pos < data.size()) {
|
||||||
|
return data[pos];
|
||||||
|
}
|
||||||
|
static int16_t dummy = 0;
|
||||||
|
dummy = 0;
|
||||||
|
return dummy;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const int16_t &at(int x, int y = 0, int z = 0) const{
|
inline const int16_t &at(int x, int y = 0, int z = 0) const{
|
||||||
return data[xs*ys*z + xs*y + x];
|
int pos = xs*ys*z + xs*y + x;
|
||||||
|
if (pos >= 0 && pos < data.size()) {
|
||||||
|
return data[pos];
|
||||||
|
}
|
||||||
|
static const int16_t fallback = 0;
|
||||||
|
return fallback;
|
||||||
}
|
}
|
||||||
|
|
||||||
sigc::signal<void> modified;
|
sigc::signal<void> modified;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue