This repository has been archived on 2019-12-07. You can view files and clone it, but cannot push or open issues or pull requests.
dungeon-gunner/source/World.h

56 lines
1.2 KiB
C
Raw Normal View History

2012-12-22 13:56:17 +00:00
/*
* World.h
*
* Created on: 29.08.2012
* Author: Felix
*/
#ifndef DG_WORLD_H_
#define DG_WORLD_H_
#include <map>
#include <vector>
#include <SFML/Graphics.hpp>
#include "abstract/Sprite.h"
2012-12-23 14:50:49 +00:00
class Sprite;
2012-12-22 13:56:17 +00:00
class Sprite;
/**
* A collection of sprites, which can be put into different layers.
*
* Uses Sprite instead of sf::Drawable to also manage deleting objects.
* Render order is determined by Physical::Category (higher number on top).
*/
class World : public sf::Drawable {
// Public functions.
public:
void insert(std::shared_ptr<Sprite> drawable);
void remove(std::shared_ptr<Sprite> drawable);
void step(int elapsed);
// Private types.
2012-12-22 13:56:17 +00:00
private:
2013-03-03 20:28:33 +00:00
class Interval {
public:
float start;
float end;
Interval(float center, float radius);
Interval getOverlap(Interval other) const;
float getLength();
};
// Private functions.
private:
2012-12-22 13:56:17 +00:00
void draw(sf::RenderTarget& target, sf::RenderStates states) const;
2013-03-03 20:28:33 +00:00
bool testCollision(std::shared_ptr<Sprite> spriteA, std::shared_ptr<Sprite> spriteB, int elapsed) const;
2012-12-22 13:56:17 +00:00
// Private variables.
private:
2012-12-23 14:50:49 +00:00
std::map<Sprite::Category, std::vector<std::shared_ptr<Sprite> > > mDrawables;
2012-12-22 13:56:17 +00:00
};
#endif /* DG_WORLD_H_ */