Add hiding of stuff and scene pause
This commit is contained in:
@@ -172,7 +172,7 @@ public:
|
||||
virtual std::pair<std::pair<double,double>,std::pair<double,double>> getDoubleRect() = 0;
|
||||
virtual void setPos(double x, double y) = 0;
|
||||
bool colidesWith(const RenderObject &other) const {
|
||||
if(!hasCollisions() || !other.hasCollisions()) {
|
||||
if(!hasCollisions() || !other.hasCollisions() || getHidden() || other.getHidden()) {
|
||||
return false;
|
||||
}
|
||||
for( const auto &x : collisions ) {
|
||||
@@ -226,7 +226,7 @@ public:
|
||||
void setHidden(bool hid) {
|
||||
hidden = hid;
|
||||
}
|
||||
bool getHidden() {
|
||||
bool getHidden() const {
|
||||
return hidden;
|
||||
}
|
||||
void setColiderColor(const std::string &color) {
|
||||
@@ -283,6 +283,8 @@ public:
|
||||
prev_ticks = now_ticks;
|
||||
}
|
||||
std::vector<std::shared_ptr<RenderObject>> getCollisions(RenderObject &r) {
|
||||
if(r.getHidden())
|
||||
return {};
|
||||
std::vector<std::shared_ptr<RenderObject>> ret{};
|
||||
for(const auto &x : collisionObjects) {
|
||||
if(x->colidesWith(r)) {
|
||||
@@ -336,6 +338,9 @@ public:
|
||||
Renderer &getRenderer() {
|
||||
return *renderer;
|
||||
}
|
||||
void setPrevTicks(int ticks) {
|
||||
prev_ticks = ticks;
|
||||
}
|
||||
private:
|
||||
std::vector<std::shared_ptr<RenderObject>> renderObjects;
|
||||
std::vector<std::shared_ptr<RenderObject>> collisionObjects;
|
||||
@@ -369,9 +374,9 @@ public:
|
||||
setTexture(texture);
|
||||
}
|
||||
virtual void render() {
|
||||
if(texture != NULL)
|
||||
if(texture != NULL && !getHidden())
|
||||
SDL_RenderCopy(renderer->getRendererPtr(), texture->getTexturePtr(), NULL, &rect);
|
||||
if(hasCollisions() && renderer->getRenderColiders()) {
|
||||
if(hasCollisions() && renderer->getRenderColiders() && !getHidden()) {
|
||||
for(const auto &col : getCollisions())
|
||||
col->render(*renderer, colider_color);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user