|
|
@@ -2,13 +2,18 @@
|
|
|
#include "Camera.h"
|
|
|
#include "Graphics.h"
|
|
|
#include "sprites.h"
|
|
|
+#include "Rect.h"
|
|
|
+#include "TileRenderer.h"
|
|
|
#include "misc.h"
|
|
|
|
|
|
#define MAP WalrusRPG::Map
|
|
|
+#define RECT WalrusRPG::Utils::Rect
|
|
|
+#define TILERENDERER WalrusRPG::TileRenderer
|
|
|
|
|
|
MAP::Map(int width, int height, unsigned *layer0, unsigned *layer1)
|
|
|
- : tset(overworld, 16, 16), time_render(0)
|
|
|
+ : anim(), time_render(0)
|
|
|
{
|
|
|
+ this->renderer = new TileRenderer(overworld, 16, 16);
|
|
|
this->width = width;
|
|
|
this->height = height;
|
|
|
this->layer0 = layer0;
|
|
|
@@ -29,8 +34,8 @@ void MAP::update(unsigned dt)
|
|
|
void MAP::render(WalrusRPG::Camera &camera, unsigned dt)
|
|
|
{
|
|
|
time_render += dt;
|
|
|
- signed t_width = tset.get_tile_width();
|
|
|
- signed t_height = tset.get_tile_height();
|
|
|
+ signed t_width = renderer->get_tile_width();
|
|
|
+ signed t_height = renderer->get_tile_height();
|
|
|
// By Eiyeron : I assumed that the camera's position is the top left pixel.
|
|
|
// Margins moves the rendered map if we go outside of the bounds (specially on the left or on the top).
|
|
|
signed offset_x = camera.get_x() % t_width * -1;
|
|
|
@@ -77,13 +82,13 @@ void MAP::render(WalrusRPG::Camera &camera, unsigned dt)
|
|
|
unsigned index = (start_x + i) + (start_y + j) * this->width;
|
|
|
unsigned tile_over = this->layer0[index];
|
|
|
if (tile_over != 0)
|
|
|
- tset.render_tile(this->layer0[index], offset_x + i * t_width, offset_y + j * t_height, time_render);
|
|
|
+ renderer->render(this->layer0[index], RECT(offset_x + i * t_width, offset_y + j * t_height));
|
|
|
// layer1 : Over-layer
|
|
|
if (this->layer1 == NULL)
|
|
|
continue;
|
|
|
tile_over = this->layer1[index];
|
|
|
if (tile_over != 0)
|
|
|
- tset.render_tile(tile_over, offset_x + i * t_width, offset_y + j * t_height, time_render);
|
|
|
+ renderer->render(tile_over, RECT(offset_x + i * t_width, offset_y + j * t_height));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -97,7 +102,7 @@ bool MAP::is_tile_solid(unsigned x, unsigned y) const
|
|
|
|
|
|
bool MAP::is_pixel_solid(unsigned x, unsigned y) const
|
|
|
{
|
|
|
- return is_tile_solid(x / tset.get_tile_width(), y / tset.get_tile_height());
|
|
|
+ return is_tile_solid(x / renderer->get_tile_width(), y / renderer->get_tile_height());
|
|
|
}
|
|
|
|
|
|
unsigned MAP::get_width() const
|