-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMapObject.cpp
80 lines (70 loc) · 1.58 KB
/
MapObject.cpp
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#include "stdafx.h"
#include "MapObject.h"
const sf::Vector2i MapObject::OBJECT_SIZE(32,32);
MapObject::MapObject(MapObject::ObjectType object) : thisObject(object), isShowing(true)
{
shape.setSize(sf::Vector2f(32,32));
shape.setOrigin(shape.getGlobalBounds().width/2, shape.getGlobalBounds().height/2);
UpdateImage();
}
void MapObject::UpdateImage()
{
switch (thisObject)
{
case MapObject::wall:
shape.setFillColor(sf::Color::Black);
shape.setOutlineThickness(-1);
shape.setOutlineColor(sf::Color::White);
break;
case MapObject::path:
shape.setFillColor(sf::Color::Yellow);
shape.setOutlineThickness(0);
break;
case MapObject::empty:
shape.setFillColor(sf::Color::Red);
shape.setOutlineThickness(-1);
shape.setOutlineColor(sf::Color::Black);
break;
case MapObject::spawn:
shape.setFillColor(sf::Color::Green);
shape.setOutlineThickness(-1);
shape.setOutlineColor(sf::Color::Magenta);
break;
case MapObject::exit:
shape.setFillColor(sf::Color::Magenta);
shape.setOutlineThickness(-4);
shape.setOutlineColor(sf::Color::Blue);
break;
default:
break;
}
}
void MapObject::Draw()
{
if(isShowing)
Game::Instance()->mainWindow_.draw(shape);
}
bool MapObject::HandleEvents(const sf::Event& someEvent)
{
return false;
}
void MapObject::Update()
{
}
void MapObject::ChangeType(MapObject::ObjectType newType)
{
thisObject=newType;
UpdateImage();
}
void MapObject::SetPosition(const sf::Vector2f& pos)
{
shape.setPosition(sf::Vector2f(pos));
}
const sf::Vector2f& MapObject::GetPos()
{
return shape.getPosition();
}
void MapObject::Show(bool b)
{
isShowing=b;
}