Pause menu

This commit is contained in:
2020-08-22 14:29:39 +02:00
parent 94aed4cd02
commit 7e67bebae2
2 changed files with 56 additions and 8 deletions
+9 -7
View File
@@ -277,14 +277,18 @@ public:
texture = t;
}
void setTexture(const std::string &img_path) {
if(polygon)
polygon.reset();
texture = std::make_shared<Texture>(renderer, img_path);
}
virtual void setColor(const std::string &color) = 0;
void setTexture(Font &font, const std::string &text, const std::string &color = "FFFFFF", const std::string &outline_color = "000000", int outline_size = -1) {
texture = std::make_shared<Texture>(renderer, font, text, color, outline_color, outline_size);
}
virtual void setColor(const std::string &color) = 0;
virtual void unsetTexture() {
texture.reset();
}
virtual void unsetColor() {
polygon.reset();
}
// per second, relative to window width
void setMovementSpeed(double speed) {
movementSpeed = speed;
@@ -655,19 +659,17 @@ public:
}
}
virtual void setColor(const std::string &color) {
if(texture)
texture.reset();
polygon = std::make_shared<Rect>(0,0,1,1);
polygon->setColor(color);
polygon->updateCollision(collisionPushX(), collisionPushY(), collisionWidth(), collisionHeight());
}
virtual void specialAction(int /*UNUSED*/) {};
virtual void render() {
if(texture != NULL && !getHidden())
SDL_RenderCopy(renderer->getRendererPtr(), texture->getTexturePtr(), NULL, &rect);
if(polygon) {
polygon->render(*renderer);
}
if(texture != NULL && !getHidden())
SDL_RenderCopy(renderer->getRendererPtr(), texture->getTexturePtr(), NULL, &rect);
if(hasCollisions() && renderer->getRenderColiders() && !getHidden()) {
for(const auto &col : getCollisions())
col->render(*renderer, colider_color);