You can now set a sprite as a background in Background which will simplify a lot of games that just place sprites over a single image.
This commit is contained in:
parent
6fb20c5085
commit
e1d61dc2c1
9 changed files with 79 additions and 22 deletions
|
@ -7,6 +7,8 @@
|
|||
namespace lel {
|
||||
|
||||
struct Cell {
|
||||
int col = 0;
|
||||
int row = 0;
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
int w = 0;
|
||||
|
@ -15,16 +17,11 @@ namespace lel {
|
|||
int mid_y = 0;
|
||||
int max_w = 0;
|
||||
int max_h = 0;
|
||||
int col = 0;
|
||||
int row = 0;
|
||||
bool right = false;
|
||||
bool bottom = false;
|
||||
bool expand = false;
|
||||
bool center = false;
|
||||
bool percent = false;
|
||||
|
||||
Cell(int col, int row) : col(col), row(row) {}
|
||||
Cell() {}
|
||||
};
|
||||
|
||||
using Row = std::vector<std::string>;
|
||||
|
@ -36,16 +33,17 @@ namespace lel {
|
|||
int grid_w = 0;
|
||||
int grid_h = 0;
|
||||
Cell cur;
|
||||
Cell main;
|
||||
std::vector<Row> grid;
|
||||
CellMap cells;
|
||||
|
||||
Parser(int x, int y, int width, int height);
|
||||
Parser();
|
||||
Parser() : cur{.col=0, .row=0} {};
|
||||
|
||||
void position(int x, int y, int width, int height);
|
||||
void id(std::string name);
|
||||
void id(const std::string& name);
|
||||
void reset();
|
||||
bool parse(std::string input);
|
||||
bool parse(const std::string& input);
|
||||
void finalize();
|
||||
std::optional<std::string> hit(int x, int y);
|
||||
};
|
||||
|
|
|
@ -104,6 +104,7 @@ namespace guecs {
|
|||
float h = 0.0f;
|
||||
sf::Color color=THEME.BG_COLOR;
|
||||
shared_ptr<sf::RectangleShape> shape = nullptr;
|
||||
shared_ptr<sf::Sprite> sprite = nullptr;
|
||||
|
||||
Background(lel::Parser& parser, sf::Color bg_color=THEME.BG_COLOR) :
|
||||
x(parser.grid_x),
|
||||
|
@ -117,5 +118,8 @@ namespace guecs {
|
|||
|
||||
void init();
|
||||
void render(sf::RenderWindow& window);
|
||||
|
||||
void set_color(sf::Color c);
|
||||
void set_sprite(const std::string& name, bool stretch=false);
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue