added support for smaller maps than the window
This commit is contained in:
@@ -5,8 +5,8 @@
|
|||||||
#include "camera.hpp"
|
#include "camera.hpp"
|
||||||
|
|
||||||
Rectangle Camera::get_bounds() {
|
Rectangle Camera::get_bounds() {
|
||||||
int minx = std::clamp(center.x-(tiles_rendered_x/2), 0, max_x - tiles_rendered_x);
|
int minx = std::clamp(center.x-(tiles_rendered_x/2), 0, std::max(0,max_x - tiles_rendered_x));
|
||||||
int miny = std::clamp(center.y-(tiles_rendered_y/2), 0, max_y - tiles_rendered_y);
|
int miny = std::clamp(center.y-(tiles_rendered_y/2), 0, std::max(0,max_y - tiles_rendered_y));
|
||||||
int width = std::min(tiles_rendered_x, max_x-minx);
|
int width = std::min(tiles_rendered_x, max_x-minx);
|
||||||
int height = std::min(tiles_rendered_y, max_y-miny);
|
int height = std::min(tiles_rendered_y, max_y-miny);
|
||||||
return Rectangle{minx, miny, width, height};
|
return Rectangle{minx, miny, width, height};
|
||||||
|
|||||||
@@ -3,10 +3,7 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#include "visualizer.hpp"
|
#include "visualizer.hpp"
|
||||||
#define TILE_WIDTH 48
|
|
||||||
#define TILE_HEIGHT 48
|
|
||||||
#define WALL_CHAR '#'
|
|
||||||
#define FLOOR_CHAR '.'
|
|
||||||
bool Visualizer::update(InputResult input) {
|
bool Visualizer::update(InputResult input) {
|
||||||
if(input.keycode == KEY_ESCAPE) {
|
if(input.keycode == KEY_ESCAPE) {
|
||||||
return true;
|
return true;
|
||||||
@@ -46,7 +43,7 @@ void Visualizer::render(Renderer *renderer) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return; // for breaking
|
||||||
}
|
}
|
||||||
|
|
||||||
void Visualizer::initialize(GameInitArgs args) {
|
void Visualizer::initialize(GameInitArgs args) {
|
||||||
|
|||||||
@@ -8,8 +8,12 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#ifndef RLA_IIPP_VISUALIZER_HPP
|
#ifndef RLA_IIPP_VISUALIZER_HPP
|
||||||
#define RLA_IIPP_VISUALIZER_HPP
|
#define RLA_IIPP_VISUALIZER_HPP
|
||||||
#define MAP_SIZE_W 20
|
#define MAP_SIZE_W 10
|
||||||
#define MAP_SIZE_H 20
|
#define MAP_SIZE_H 10
|
||||||
|
#define TILE_WIDTH 48
|
||||||
|
#define TILE_HEIGHT 48
|
||||||
|
#define WALL_CHAR '#'
|
||||||
|
#define FLOOR_CHAR '.'
|
||||||
|
|
||||||
class Visualizer : public Game {
|
class Visualizer : public Game {
|
||||||
public:
|
public:
|
||||||
|
|||||||
Reference in New Issue
Block a user