Last active
August 29, 2015 13:58
-
-
Save Furkanzmc/9938615 to your computer and use it in GitHub Desktop.
An Entity System that inherits BaseEntitySystem
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "ShipEntitySystem.h" | |
ShipEntitySystem::ShipEntitySystem(sf::RenderWindow &window) | |
: mRenderWindow(window) | |
{ | |
} | |
ShipEntitySystem::~ShipEntitySystem() | |
{ | |
} | |
bool ShipEntitySystem::checkForProcessing() | |
{ | |
return true; | |
} | |
void ShipEntitySystem::processEntity(Entity &entity) | |
{ | |
//The equivelent of enumerator COMPONENTS::SPRITE | |
if (entity.hasComponent(1)) { | |
entity.getComponentManager()->getComponentOfEntity<SpriteComponent>(entity.getEntityID())->move(.3f, .3f); | |
} | |
drawEntity(entity); | |
} | |
void ShipEntitySystem::drawEntity(Entity &entity) | |
{ | |
//The equivelent of enumerator COMPONENTS::SPRITE | |
if (entity.hasComponent(1)) { | |
mRenderWindow.draw(*entity.getComponentManager()->getComponentOfEntity<SpriteComponent>(entity.getEntityID())); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef SHIPENTITYSYSTEM_H | |
#define SHIPENTITYSYSTEM_H | |
#include "BaseEntitySystem.h" | |
#include <SFML/Graphics.hpp> | |
#include "MovementComponent.h" | |
#include "ComponentManager.h" | |
using namespace zmc; | |
class ShipEntitySystem : public BaseEntitySystem | |
{ | |
public: | |
ShipEntitySystem(sf::RenderWindow &window); | |
~ShipEntitySystem(); | |
private: | |
sf::RenderWindow &mRenderWindow; | |
private: | |
virtual bool checkForProcessing(); | |
virtual void processEntity(zmc::Entity &entity); | |
void drawEntity(zmc::Entity &entity); | |
}; | |
#endif // SHIPENTITYSYSTEM_H |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment