diff options
author | Paweł Redman <pawel.redman@gmail.com> | 2017-10-17 16:39:13 +0200 |
---|---|---|
committer | Paweł Redman <pawel.redman@gmail.com> | 2017-10-17 16:39:13 +0200 |
commit | f66cf28c8b4d80122896c87dba8af74ea1872eba (patch) | |
tree | 6d84c736463a3c210ba3791dc074df8565eb6559 /src/common.hpp | |
parent | 672180b2ee3ed9b9ff984538a85e6eaf2e1c91bc (diff) |
New vectors. Start refactoring to use it.
Diffstat (limited to 'src/common.hpp')
-rw-r--r-- | src/common.hpp | 19 |
1 files changed, 7 insertions, 12 deletions
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 <list> #include <unordered_set> #include <SFML/Graphics.hpp> +#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<int64_t, 2> sector_index_t; + typedef vec_t<int64_t, 2> tile_index_t; class entity_t; @@ -70,7 +64,7 @@ namespace world { procgen::perlin_noise_t perlin; std::map<sector_index_t, sector_t> 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<sector_t*> get_sectors(sf::FloatRect rect); std::list<entity_t*> get_entities(sf::FloatRect rect); + std::list<entity_t*> 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(); |