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_
|
|
|
|
|
2013-03-29 16:59:35 +00:00
|
|
|
#include "abstract/Character.h"
|
2013-03-29 17:34:51 +00:00
|
|
|
#include "abstract/Sprite.h"
|
2012-12-22 13:56:17 +00:00
|
|
|
|
2013-03-29 16:59:35 +00:00
|
|
|
class Character;
|
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:
|
|
|
|
void insert(std::shared_ptr<Sprite> drawable);
|
2013-03-29 16:59:35 +00:00
|
|
|
void insertCharacter(std::shared_ptr<Character> character);
|
2013-07-21 08:52:50 +00:00
|
|
|
void remove(std::shared_ptr<Sprite> drawable);
|
2012-12-22 13:56:17 +00:00
|
|
|
void step(int elapsed);
|
2013-03-29 16:59:35 +00:00
|
|
|
void think(int elapsed);
|
2013-03-29 17:48:49 +00:00
|
|
|
std::vector<std::shared_ptr<Character> >
|
2013-08-07 15:39:43 +00:00
|
|
|
getCharacters(const Vector2f& position, float maxDistance) const;
|
|
|
|
bool raycast(const Vector2f& lineStart,
|
|
|
|
const Vector2f& lineEnd) const;
|
2013-08-18 11:13:49 +00:00
|
|
|
std::vector<std::shared_ptr<Sprite> > getNearbySprites(
|
|
|
|
const Vector2f& position, float radius) const;
|
2012-12-22 13:56:17 +00:00
|
|
|
|
2013-03-27 13:38:34 +00:00
|
|
|
private:
|
|
|
|
|
2013-03-03 20:55:15 +00:00
|
|
|
private:
|
2012-12-22 13:56:17 +00:00
|
|
|
void draw(sf::RenderTarget& target, sf::RenderStates states) const;
|
2013-05-26 18:16:36 +00:00
|
|
|
void applyMovement(std::shared_ptr<Sprite> sprite, int elapsed);
|
2012-12-22 13:56:17 +00:00
|
|
|
|
|
|
|
private:
|
2012-12-23 14:50:49 +00:00
|
|
|
std::map<Sprite::Category, std::vector<std::shared_ptr<Sprite> > > mDrawables;
|
2013-03-29 16:59:35 +00:00
|
|
|
std::vector<std::shared_ptr<Character> > mCharacters;
|
2012-12-22 13:56:17 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* DG_WORLD_H_ */
|