From 57fe8f3c4124819b95164547333a33f4c45eac8d Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Sun, 10 Mar 2019 12:07:40 -0400 Subject: Editor now allows tile placement You can scroll through the three layers (map, track, object) with Z/X. You can swap between focusing on the map and the tileset with TAB. You can place tiles with enter or space. Pretty rudimentary, but it's a start. --- src/tileset.h | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'src/tileset.h') diff --git a/src/tileset.h b/src/tileset.h index 8a565bc..745ea1d 100644 --- a/src/tileset.h +++ b/src/tileset.h @@ -1,15 +1,53 @@ #ifndef TILESET_H_B89AE7A1 #define TILESET_H_B89AE7A1 +#include +#include "renderer.h" #include "enums.h" +#include "consts.h" class Tileset { public: + Tileset(SDL_Renderer* ren, std::string filename) + { + surface_ptr surf(IMG_Load(("../res/" + filename).c_str())); + + if (!surf) + { + throw img_error(); + } + + image_.reset(SDL_CreateTextureFromSurface(ren, surf.get())); + size_ = { surf->w, surf->h }; + numTiles_ = size_.h() / TILE_SIZE.h(); + } + bool canEntityMoveTo(ColliderType collider, size_t tile) const { return true; } + + const texture_ptr& getImage() const + { + return image_; + } + + const vec2i& getSize() const + { + return size_; + } + + size_t getNumTiles() const + { + return numTiles_; + } + +private: + + texture_ptr image_; + vec2i size_; + size_t numTiles_; }; #endif /* end of include guard: TILESET_H_B89AE7A1 */ -- cgit 1.4.1