-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDoor.cpp
79 lines (65 loc) · 1.51 KB
/
Door.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
#include "stdafx.h"
#include "Door.h"
bool Door::firstConstructed=true;
sf::SoundBuffer Door::soundBuffer;
sf::Sound Door::mouseOverSound;
Door::Door(const float& x, const float& y, int level, bool boss) : monster(level, boss)
{
doorFont.loadFromFile("fonts/arial.ttf");
doorText.setFont(doorFont);
doorText.setString("soup");
//load sounds the first time a door is made
if(firstConstructed)
{
soundBuffer.loadFromFile("sounds/click.wav");
mouseOverSound.setBuffer(soundBuffer);
firstConstructed=false;
}
doorShape.setSize(sf::Vector2f(240,500));
doorShape.setOutlineThickness(-5);
doorShape.setFillColor(sf::Color(120,60,0,255));
MyAlgorithms::CenterOrigin(doorShape);
doorShape.setPosition(x,y);
monster.SetPosition(x,y);
}
void Door::SetPosition(const float& x, const float& y)
{
doorShape.setPosition(x, y);
}
void Door::MouseOver(bool b)
{
//if you weren't previously moused over and now you are
if (!isMousedOver && b)
mouseOverSound.play();
isMousedOver=b;
if(isMousedOver)
doorShape.setOutlineColor(sf::Color::White);
else
doorShape.setOutlineColor(doorShape.getFillColor());
}
const Door::DoorState& Door::GetState()
{
return state;
}
const sf::RectangleShape& Door::GetShape()
{
return doorShape;
}
void Door::openAnimation()
{
}
void Door::Select(bool b)
{
isSelected=b;
}
void Door::Open()
{
sf::Color currentCol = doorShape.getFillColor();
currentCol.a=0;
doorShape.setFillColor(currentCol);
doorShape.setOutlineColor(currentCol);
}
Monster& Door::GetMonster()
{
return monster;
}