From f66cf28c8b4d80122896c87dba8af74ea1872eba Mon Sep 17 00:00:00 2001 From: Paweł Redman Date: Tue, 17 Oct 2017 16:39:13 +0200 Subject: New vectors. Start refactoring to use it. --- src/common.hpp | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'src/common.hpp') diff --git a/src/common.hpp b/src/common.hpp index f458190..75dd17d 100644 --- a/src/common.hpp +++ b/src/common.hpp @@ -6,6 +6,7 @@ #include #include #include +#include "math.hpp" namespace procgen { class prng_t { @@ -29,7 +30,7 @@ namespace procgen { ~perlin_noise_t(); void generate(prng_t *prng, size_t size); - float get(float x, float y, float scale); + float get(v2f_t x, float scale); }; } @@ -43,15 +44,8 @@ namespace world { char type; }; - class sector_index_t { - public: - int64_t x, y; - - sector_index_t (); - sector_index_t (int64_t x_, int64_t y_); - sector_index_t (float x_, float y_); - bool operator<(sector_index_t B) const; - }; + typedef vec_t sector_index_t; + typedef vec_t tile_index_t; class entity_t; @@ -70,7 +64,7 @@ namespace world { procgen::perlin_noise_t perlin; std::map sectors; - void generate_tile(ssize_t lx, ssize_t ly, tile_t *tile); + void generate_tile(tile_t *tile, tile_index_t index); void generate(sector_t *sector, sector_index_t index); public: @@ -81,6 +75,7 @@ namespace world { // FIXME: iterators instead of returning std::lists std::list get_sectors(sf::FloatRect rect); std::list get_entities(sf::FloatRect rect); + std::list get_render_entities(sf::FloatRect rect); void render(sf::RenderWindow *window); @@ -98,7 +93,7 @@ namespace world { size_t cookie = 0; public: - sf::FloatRect bounds; + sf::FloatRect bounds, render_bounds; void link(world_t *world); void unlink(); -- cgit