-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUpdator.cpp
More file actions
37 lines (34 loc) · 1.15 KB
/
Updator.cpp
File metadata and controls
37 lines (34 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include "Updator.hpp"
namespace StrategyGoo
{
Updator::Updator( entt::registry& registry_, BoardPosition start, GameBoard* board_,
size_t tileWidth, size_t tileHeight, std::string spriteName ) : registry( registry_ ), board( board_ ),
ENTITY_TILE_WIDTH_CONSTANT( tileWidth ), ENTITY_TILE_HEIGHT_CONSTANT( tileHeight )
{
id = registry.create();
registry.emplace< BoardPosition >( id, start.x, start.y );
registry.emplace< Sprite< 0 > >( id, spriteName );
RefrenceSprite().RefrenceSprite().setPosition( ToWorldPosition() );
registry.emplace< UpdatorRefrence >( id, *this );
}
BoardPosition& Updator::RefrenceBoardPosition() {
return registry.get< BoardPosition >( id );
}
Sprite< 0 >& Updator::RefrenceSprite() {
return registry.get< Sprite< 0 > >( id );
}
entt::registry& Updator::RefrenceRegistry() {
return registry;
}
GameBoard* Updator::GetBoard() {
return board;
}
entt::entity Updator::GetID() {
return id;
}
sf::Vector2f Updator::ToWorldPosition() {
auto position = RefrenceBoardPosition();
return sf::Vector2f( ( float ) position.x * ENTITY_TILE_WIDTH_CONSTANT,
( float ) position.y * ENTITY_TILE_WIDTH_CONSTANT );
}
}