Project_Maat/src/Level.cpp
Teo-CD 3666b9e7e9 Entities are now constructable
Added utility function to display error window
Added textures
Added font
Added a way to choose resources location
2019-06-07 22:20:34 +02:00

37 lines
881 B
C++

//
// Created by trotfunky on 06/06/19.
//
#include "Level.h"
Level::Level(const pugi::xml_document& xmlDoc, const TextureStore& textureStore)
: textures(textureStore),
size(xmlDoc.child("Level").attribute("width").as_int(),xmlDoc.child("Level").attribute("width").as_int())
{
pugi::xml_node levelNode = xmlDoc.child("Level");
for(const pugi::xml_node& child : levelNode.children())
{
if(!strncmp(child.name(),"Entity",6))
{
entities.emplace_back(child,textures.at(child.attribute("textureId").as_int(0)).get());
}
}
}
void Level::render(sf::RenderWindow& renderWindow) const
{
for(const Entity& entity : entities)
{
renderWindow.draw(entity.getShape());
}
}
void Level::runStep()
{
for(Entity& entity: entities)
{
// FIXME : For testing purposes
entity.move();
}
}