Skip to content

Instantly share code, notes, and snippets.

@Furkanzmc
Last active August 29, 2015 13:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Furkanzmc/9938615 to your computer and use it in GitHub Desktop.
Save Furkanzmc/9938615 to your computer and use it in GitHub Desktop.
An Entity System that inherits BaseEntitySystem
#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()));
}
}
#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