From 7934d623dad0b649effab43dc2899d6d47748b9b Mon Sep 17 00:00:00 2001 From: Maximilian Giller Date: Sun, 11 Jun 2023 13:24:27 +0200 Subject: [PATCH] Initial attempts --- CMakeLists.txt | 2 +- assets/grass_plus.png | Bin 0 -> 18930 bytes src/game/level/level_config.hpp | 11 +++-- src/levels.hpp | 2 +- src/sprites/sprite_factory.cpp | 50 ++++++++++++++++++++++ src/sprites/sprite_factory.hpp | 4 ++ src/sprites/sprite_sheet.cpp | 19 +++++++++ src/sprites/sprite_sheet.hpp | 8 ++++ src/sprites/tiling/tilemap.cpp | 57 ++++++++++++++++++++++++++ src/sprites/tiling/tilemap.hpp | 26 ++++++++++++ src/sprites/tiling/tilemap_config.hpp | 45 ++++++++++++++++++++ src/sprites/tiling/tileset.cpp | 6 +++ src/sprites/tiling/tileset.hpp | 14 +++++++ src/sprites/tiling/tileset_config.hpp | 21 ++++++++++ src/texture_config.h | 17 +++++--- src/tilemaps.hpp | 21 ++++++++++ 16 files changed, 293 insertions(+), 10 deletions(-) create mode 100644 assets/grass_plus.png create mode 100644 src/sprites/tiling/tilemap.cpp create mode 100644 src/sprites/tiling/tilemap.hpp create mode 100644 src/sprites/tiling/tilemap_config.hpp create mode 100644 src/sprites/tiling/tileset.cpp create mode 100644 src/sprites/tiling/tileset.hpp create mode 100644 src/sprites/tiling/tileset_config.hpp create mode 100644 src/tilemaps.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index fa8c037..7641a4f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -88,7 +88,7 @@ set(SOURCES src/game/level/level_config.hpp src/game/level/level_loader.cpp src/game/level/level_loader.hpp - src/levels.hpp) + src/levels.hpp src/sprites/tiling/tilemap.cpp src/sprites/tiling/tilemap.hpp src/sprites/tiling/tilemap_config.hpp src/tilemaps.hpp src/sprites/tiling/tileset_config.hpp src/sprites/tiling/tileset.cpp src/sprites/tiling/tileset.hpp) set(PHYSICS_00_SOURCES src/prototypes/physics_00.cpp) diff --git a/assets/grass_plus.png b/assets/grass_plus.png new file mode 100644 index 0000000000000000000000000000000000000000..2b6fb6a3ff78a66f8661c61a7029bc257b67a18e GIT binary patch literal 18930 zcma&O1ymeO(?7b4`z|g4b{BUG5G+V=4=%waKp+Xh-C-ABTmmF`0t5}g-IhS`AW3jb zaCf{nsF%Cn3r9_v+m_2n z25R#g>2Zk2K7hcuxfLa3EHoS=wTl{)e|MhV|6W}BU0B-f_&Q5g)tyH~lY)j%ok7=$ z#V&`-b(r7(Uf27+JO4iV;fA94Cw@gA25oHy4NeB`$DE?N4`mWHjoMz=+*i7OThH!C z*M!SMS4$6Y|Nr-oU3-TD0DuBi73B1Na@NhAGk$)lEUsWzEmi$FJZxH8s@bnK)4X|q z-=%Ja$)Ylt>^b4z5hr9zo4(`I7)kvIuc?p!yQr3JeHyd$!C@=$W61dlFfZuB#P3>I zllk_bjy2+BHDl>gFfQ<2P*e@%qGsTyQ_B6jMXjH`Z?7HSc6HBSk~n@%!a`)Mh69Aa zP!Se_h$l~87d|4R$0BTtUr=!c^IQdQL0`LfS_V#f{1bO zr~@(#fD8q~uvPs5u<9b^e~6MbknRM<5hokY`0cdwh0r=NHMZP%i~7u|)De;9)h-{4 zrNZ>;wLOS8RRuBQ+ zgNnZMzx0j3bPP;zI;KN`ZcF$gBLOGR^~1V4^SSVp)4_nXu0iEmO%nUxq6SG~spY3b z4N5@+fZF;c($o5#2fq3FTHz3;HZ8F!H%B`q4^p2xPz{x>-S;ta8gQ*RCP~R{vH_Ni zo+0TC&xIc_Y6#abA@4E%N7L5_RtiLnHzHLgM0`EAz$}JYuH+ zO2P^R{um>dlBDO>!tAG&@qCs+!LdkfrRaBzsI|I3-Ryd--M>+J%AANU;Ihg+-VED^cfU&re+y z!?U?=abA>7y(qRSV~@pRAFm7jk;IvqjbiFj)o^+5Wk*o5Fo?#j|LD0)*Y@*Y6R#c_ zd%3I>NZ^m+yik4xoErnrvm~H!t?F?Yv^@7Da<+b%c#0DrR`jO^L5X3Y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 100644 --- a/src/game/level/level_config.hpp +++ b/src/game/level/level_config.hpp @@ -5,17 +5,22 @@ #include #include #include +#include "../../sprites/tiling/tilemap_config.hpp" struct LevelConfig { std::string name; sf::Vector2f worldMapSize = {}; + TileMapConfig tileMapConfig = {}; std::vector playerSpawnPoints = {}; - LevelConfig(std::string name, const sf::Vector2f &worldMapSize, + LevelConfig(std::string name, const std::string &tileMapName, const std::vector &playerSpawnPoints) - : name(std::move(name)), worldMapSize(worldMapSize), playerSpawnPoints(playerSpawnPoints) - { } + : name(std::move(name)), playerSpawnPoints(playerSpawnPoints) + { + tileMapConfig = TileMapConfig(tileMapName, {}); + worldMapSize = tileMapConfig.getSize(); + } LevelConfig() = default; diff --git a/src/levels.hpp b/src/levels.hpp index 8e7e25e..d6ce8c2 100644 --- a/src/levels.hpp +++ b/src/levels.hpp @@ -8,7 +8,7 @@ #define INITIAL_LEVEL "default" std::map const LEVELS = { - {"default", LevelConfig("Default", {25, 25}, {{1, 1}})} + {"default", LevelConfig("Default", "grass", {{1, 1}})} }; #endif //HOLESOME_LEVELS_HPP diff --git a/src/sprites/sprite_factory.cpp b/src/sprites/sprite_factory.cpp index 551d9c4..777d6cf 100644 --- a/src/sprites/sprite_factory.cpp +++ b/src/sprites/sprite_factory.cpp @@ -95,3 +95,53 @@ std::shared_ptr SpriteFactory::createSheet(const std::string& name) LOG(INFO) << "Creating sheet " << name; return std::make_shared(texture, config.columns, config.rows); } + +std::shared_ptr SpriteFactory::createTileMap(const std::string &name) +{ + // Get config + auto tilemap_config = all_tilemaps.find(name); + + if (tilemap_config == all_tilemaps.end()) + { + LOG(ERROR) << "Tilemap " << name << " not found. Could not create tilemap."; + return nullptr; + } + + // Construct tilemap + auto config = tilemap_config->second; + std::shared_ptr tileSet = createTileSet(config.tileSheet); + if (sheet == nullptr) + { + LOG(ERROR) << "Sheet " << config.sheetName << " not found. Could not create tilemap."; + return nullptr; + } + + LOG(INFO) << "Creating tilemap " << name; + auto tilemap = std::make_shared(sheet, config.tileSize, config.tileCount); + tilemap->setTilemap(config.tilemap); + return tilemap; +} + +std::shared_ptr SpriteFactory::createTileSet(const std::string &name) +{ + // Get config + auto tileset_config = all_tilesets.find(name); + + if (tileset_config == all_tilesets.end()) + { + LOG(ERROR) << "Tileset " << name << " not found. Could not create tileset."; + return nullptr; + } + + // Construct tileset + auto config = tileset_config->second; + auto sheet = createSheet(config.sheetName); + if (sheet == nullptr) + { + LOG(ERROR) << "Sheet " << config.sheetName << " not found. Could not create tileset."; + return nullptr; + } + + LOG(INFO) << "Creating tileset " << name; + return std::make_shared(sheet, config.tileIndices); +} diff --git a/src/sprites/sprite_factory.hpp b/src/sprites/sprite_factory.hpp index b6f55ad..d351941 100644 --- a/src/sprites/sprite_factory.hpp +++ b/src/sprites/sprite_factory.hpp @@ -8,6 +8,8 @@ #include "animated_sprite.hpp" #include "sprite_sheet.hpp" #include "../logging/easylogging++.h" +#include "tiling/tilemap.hpp" +#include "tiling/tileset.hpp" class SpriteFactory { @@ -15,6 +17,8 @@ public: static std::shared_ptr createSingleSprite(const std::string& name, sf::Vector2f size = sf::Vector2f(0, 0)); static std::shared_ptr createAnimatedSprite(const std::string& name, sf::Vector2f size = sf::Vector2f(0, 0)); static std::shared_ptr createSheet(const std::string& name); + static std::shared_ptr createTileMap(const std::string& name); + std::shared_ptr createTileSet(const std::string &name); }; diff --git a/src/sprites/sprite_sheet.cpp b/src/sprites/sprite_sheet.cpp index ef2c308..a044761 100644 --- a/src/sprites/sprite_sheet.cpp +++ b/src/sprites/sprite_sheet.cpp @@ -3,6 +3,10 @@ SpriteSheet::SpriteSheet(const std::shared_ptr& texture, int columns, int rows) { + this->texture = texture; + this->columns = columns; + this->rows = rows; + // Extract sprites from texture sprites = std::vector(); int spriteWidth = texture->getSize().x / columns; @@ -47,3 +51,18 @@ std::shared_ptr SpriteSheet::getAnimation(int startingSequenceIn } return std::make_shared(animation); } + +int SpriteSheet::getRows() const +{ + return rows; +} + +int SpriteSheet::getColumns() const +{ + return columns; +} + +std::shared_ptr SpriteSheet::getTexture() const +{ + return texture; +} diff --git a/src/sprites/sprite_sheet.hpp b/src/sprites/sprite_sheet.hpp index ff4b0f9..02959b2 100644 --- a/src/sprites/sprite_sheet.hpp +++ b/src/sprites/sprite_sheet.hpp @@ -17,7 +17,15 @@ public: std::shared_ptr getAnimation(int startingSequenceIndex, int numberOfFrames) const; + std::shared_ptr getTexture() const; + + int getColumns() const; + int getRows() const; + private: + int columns; + int rows; + std::shared_ptr texture; std::vector sprites; }; diff --git a/src/sprites/tiling/tilemap.cpp b/src/sprites/tiling/tilemap.cpp new file mode 100644 index 0000000..44dc87a --- /dev/null +++ b/src/sprites/tiling/tilemap.cpp @@ -0,0 +1,57 @@ +#include "tilemap.hpp" + +TileMap::TileMap(std::shared_ptr tileSet, std::vector> tiles) +{ + // resize the vertex array to fit the level size + vertices.setPrimitiveType(sf::Quads); + + unsigned int size = tiles.size(); + vertices.resize(size * size * 4); + + // populate the vertex array, with one quad per tile + for (unsigned int y = 0; y < size; ++y) + for (unsigned int x = 0; x < size; ++x) + { + // get the current tile number + int tileNumber = tiles[size - 1 - y][x]; + + // TODO + // Follow: https://www.sfml-dev.org/tutorials/2.5/graphics-vertex-array.php#example-tile-map + // find its position in the tileset texture + int tu = tileNumber % (tileset.getSize().y / tileSize.y); + int tv = tileNumber / (tileset.getSize().y / tileSize.y); + + // get a pointer to the current tile's quad + sf::Vertex *quad = &vertices[(y + x * width) * 4]; + + // define its 4 corners + quad[0].position = sf::Vector2f(y * tileSize.y, x * tileSize.y); + quad[1].position = sf::Vector2f((y + 1) * tileSize.y, x * tileSize.y); + quad[2].position = sf::Vector2f((y + 1) * tileSize.y, (x + 1) * tileSize.y); + quad[3].position = sf::Vector2f(y * tileSize.y, (x + 1) * tileSize.y); + + // define its 4 texture coordinates + quad[0].texCoords = sf::Vector2f(tu * tileSize.y, tv * tileSize.y); + quad[1].texCoords = sf::Vector2f((tu + 1) * tileSize.y, tv * tileSize.y); + quad[2].texCoords = sf::Vector2f((tu + 1) * tileSize.y, (tv + 1) * tileSize.y); + quad[3].texCoords = sf::Vector2f(tu * tileSize.y, (tv + 1) * tileSize.y); + } +} + +void TileMap::draw(sf::RenderWindow *window) +{ + window->draw(*this); +} + +void TileMap::draw(sf::RenderTarget &target, sf::RenderStates states) const +{ + // apply the transform + // TODO? NEEDED? +// states.transform *= getTransform(); + + // apply the tileset texture + states.texture = &tileMapTexture; + + // draw the vertex array + target.draw(vertices, states); +} diff --git a/src/sprites/tiling/tilemap.hpp b/src/sprites/tiling/tilemap.hpp new file mode 100644 index 0000000..ac33d5f --- /dev/null +++ b/src/sprites/tiling/tilemap.hpp @@ -0,0 +1,26 @@ +#ifndef HOLESOME_TILEMAP_HPP +#define HOLESOME_TILEMAP_HPP + + +#include +#include +#include +#include "../../game/game_object.h" +#include "tileset.hpp" + +class TileMap : public GameObject, public sf::Drawable +{ +public: + TileMap(std::shared_ptr tileSet, std::vector> tiles); + + void draw(sf::RenderWindow *window) override; + + void draw(sf::RenderTarget &target, sf::RenderStates states) const override; + +private: + sf::VertexArray vertices; + sf::Texture tileMapTexture; +}; + + +#endif //HOLESOME_TILEMAP_HPP diff --git a/src/sprites/tiling/tilemap_config.hpp b/src/sprites/tiling/tilemap_config.hpp new file mode 100644 index 0000000..017a62b --- /dev/null +++ b/src/sprites/tiling/tilemap_config.hpp @@ -0,0 +1,45 @@ +#ifndef HOLESOME_TILEMAP_CONFIG_HPP +#define HOLESOME_TILEMAP_CONFIG_HPP + +#include +#include +#include +#include +#include + +struct TileMapConfig +{ + std::string tileSheet; + + std::vector backgroundTileSelection = {}; + + std::vector> tiles = {}; + + TileMapConfig(std::string tileSheet, std::vector> tiles, + std::vector backgroundTileSelection = {}) + { + this->tileSheet = std::move(tileSheet); + this->backgroundTileSelection = std::move(backgroundTileSelection); + this->tiles = std::move(tiles); + + // Make sure all rows are the same length and that the map is square + int size = tiles.size(); + for (auto &row : tiles) + { + if (row.size() != size) + { + throw std::runtime_error("Tile map is not square"); + } + } + } + + TileMapConfig() = default; + + sf::Vector2f getSize() const + { + int size = tiles.size(); + return {static_cast(size), static_cast(size)}; + } +}; + +#endif //HOLESOME_TILEMAP_CONFIG_HPP diff --git a/src/sprites/tiling/tileset.cpp b/src/sprites/tiling/tileset.cpp new file mode 100644 index 0000000..55ec019 --- /dev/null +++ b/src/sprites/tiling/tileset.cpp @@ -0,0 +1,6 @@ +#include "tileset.hpp" + +TileSet::TileSet(const std::shared_ptr& sheet, const std::vector& tileIndices) +{ + +} diff --git a/src/sprites/tiling/tileset.hpp b/src/sprites/tiling/tileset.hpp new file mode 100644 index 0000000..38a12c7 --- /dev/null +++ b/src/sprites/tiling/tileset.hpp @@ -0,0 +1,14 @@ +#ifndef HOLESOME_TILESET_HPP +#define HOLESOME_TILESET_HPP + + +#include "../sprite_sheet.hpp" + +class TileSet +{ +public: + TileSet(const std::shared_ptr& sheet, const std::vector& tileIndices); +}; + + +#endif //HOLESOME_TILESET_HPP diff --git a/src/sprites/tiling/tileset_config.hpp b/src/sprites/tiling/tileset_config.hpp new file mode 100644 index 0000000..e30faa3 --- /dev/null +++ b/src/sprites/tiling/tileset_config.hpp @@ -0,0 +1,21 @@ +#ifndef HOLESOME_TILESET_CONFIG_HPP +#define HOLESOME_TILESET_CONFIG_HPP + +#include +#include + +struct TileSetConfig +{ + std::string sheetName; + std::vector tileIndices = {}; + + TileSetConfig() = default; + + TileSetConfig(std::string sheetName, std::vector tileIndices) + { + this->sheetName = std::move(sheetName); + this->tileIndices = std::move(tileIndices); + } +}; + +#endif //HOLESOME_TILESET_CONFIG_HPP diff --git a/src/texture_config.h b/src/texture_config.h index 872ba00..be648ea 100644 --- a/src/texture_config.h +++ b/src/texture_config.h @@ -6,6 +6,7 @@ #include "sprites/configs/animation_config.hpp" #include "sprites/configs/sheet_config.hpp" #include "sprites/configs/sprite_config.hpp" +#include "sprites/tiling/tileset_config.hpp" #define PLAYER_SKIN "ring" @@ -15,9 +16,10 @@ */ std::map const all_textures = { {"numbers", "assets/numbers.png"}, - {"64", "assets/64.png"}, - {"edge", "assets/edge.png"}, - {"ring", "assets/ring.png"} + {"64", "assets/64.png"}, + {"edge", "assets/edge.png"}, + {"ring", "assets/ring.png"}, + {"grasses", "assets/grass_plus.png"} }; /** @@ -25,7 +27,8 @@ std::map const all_textures = { * The key is the name of the sheet, the value is the sheet config. */ std::map const all_sheets = { - {"numbers", SheetConfig("numbers", 4, 2)} + {"numbers", SheetConfig("numbers", 4, 2)}, + {"grasses", SheetConfig("grasses", 25, 14)} }; /** @@ -41,9 +44,13 @@ std::map const all_animations = { * The key is the name of the singleSprite, the value is the singleSprite config. */ std::map const all_sprites = { - {"64", SpriteConfig("64")}, + {"64", SpriteConfig("64")}, {"edge", SpriteConfig("edge")}, {"ring", SpriteConfig("ring")} }; +std::map const all_tilesets = { + {"grass", TileSetConfig("grasses", {58})} +}; + #endif //HOLESOME_TEXTURE_CONFIG_H diff --git a/src/tilemaps.hpp b/src/tilemaps.hpp new file mode 100644 index 0000000..139d72d --- /dev/null +++ b/src/tilemaps.hpp @@ -0,0 +1,21 @@ +#ifndef HOLESOME_TILEMAPS_HPP +#define HOLESOME_TILEMAPS_HPP + +#include +#include +#include "sprites/tiling/tilemap_config.hpp" + +std::map const all_tilemaps = { + {"grass", TileMapConfig("grass", {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},})} +}; + +#endif //HOLESOME_TILEMAPS_HPP