Remove default render target of nullptr.

This commit is contained in:
SeanOMik 2020-07-03 13:34:22 -05:00
parent ca64ab7a21
commit 7ced4f85cf
No known key found for this signature in database
GPG Key ID: FA4D55AC05268A88
5 changed files with 5 additions and 28 deletions

View File

@ -77,34 +77,11 @@ public:
} }
} }
void Render(sf::RenderTarget* target = nullptr) override { void Render(sf::RenderTarget* target) override {
target->draw(shape); target->draw(shape);
} }
}; };
/*class PlayerEvent : public simpleengine::Event {
private:
SnakePlayerEntity snake_player;
public:
explicit PlayerEvent(sf::RenderWindow* window) : simpleengine::Event(window),
snake_player(SnakePlayerEntity(window->getSize())) {
}
void CheckForQuit() override {
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Escape)) {
quit = true;
}
}
void Update(const float& delta_time) override {
snake_player.Update(delta_time);
}
void Render(sf::RenderTarget* target = nullptr) override {
snake_player.Render(target);
}
};*/
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
simpleengine::Game game(500, 500, "First Example"); simpleengine::Game game(500, 500, "First Example");
game.AddEvent(new simpleengine::EntityEvent(game.GetWindow(), new SnakePlayerEntity(game.GetWindow()->getSize()))); game.AddEvent(new simpleengine::EntityEvent(game.GetWindow(), new SnakePlayerEntity(game.GetWindow()->getSize())));

View File

@ -17,7 +17,7 @@ namespace simpleengine {
virtual ~Component() = default; virtual ~Component() = default;
virtual void Update(const float& delta_time) = 0; virtual void Update(const float& delta_time) = 0;
virtual void Render(sf::RenderTarget* target = nullptr) {}; // Most components won't need to be rendered. virtual void Render(sf::RenderTarget* target) {}; // Most components won't need to be rendered.
protected: protected:
Entity* owning_entity; Entity* owning_entity;
}; };

View File

@ -24,7 +24,7 @@ namespace simpleengine {
virtual void Move(const float& delta_time, const float& x, const float& y) {}; virtual void Move(const float& delta_time, const float& x, const float& y) {};
virtual void Update(const float& delta_time) = 0; virtual void Update(const float& delta_time) = 0;
virtual void Render(sf::RenderTarget* target = nullptr) = 0; virtual void Render(sf::RenderTarget* target) = 0;
virtual void Destroying() {}; // Called when the entity is about to be destroyed. virtual void Destroying() {}; // Called when the entity is about to be destroyed.
void DestroyEntity() { void DestroyEntity() {

View File

@ -23,7 +23,7 @@ namespace simpleengine {
virtual void CheckForQuit() = 0; // Ran every Update to check if we're gonna quit. virtual void CheckForQuit() = 0; // Ran every Update to check if we're gonna quit.
virtual void Quiting() {} // Ran when a State is about to be destroyed. virtual void Quiting() {} // Ran when a State is about to be destroyed.
virtual void Update(const float& delta_time) = 0; virtual void Update(const float& delta_time) = 0;
virtual void Render(sf::RenderTarget* target = nullptr) = 0; virtual void Render(sf::RenderTarget* target) = 0;
protected: protected:
sf::RenderWindow* window; sf::RenderWindow* window;
bool quit = false; bool quit = false;

View File

@ -31,7 +31,7 @@ namespace simpleengine {
entity->Update(delta_time); entity->Update(delta_time);
} }
void Render(sf::RenderTarget* target = nullptr) override { void Render(sf::RenderTarget* target) override {
entity->Render(target); entity->Render(target);
} }
private: private: