-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEBlock.cpp
More file actions
73 lines (55 loc) · 1.43 KB
/
Copy pathEBlock.cpp
File metadata and controls
73 lines (55 loc) · 1.43 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
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
#include "EBlock.h"
#include <random>
int rand_int(int low, int high)
{
static std::default_random_engine re{};
using Dist = std::uniform_int_distribution<int>;
static Dist uid{};
return uid(re, Dist::param_type{ low,high });
}
EBlock::EBlock()
{
drawingGroup.push_back(backgroundShape);
backgroundShape.setSize(sf::Vector2f(50.0f, 25.0f));
backgroundShape.setFillColor(sf::Color::Yellow);
backgroundShape.setOrigin(sf::Vector2f(backgroundShape.getGlobalBounds().width / 2, backgroundShape.getGlobalBounds().height / 2));
setPosition(sf::Vector2f(rand_int(100, 500), rand_int(100, 500)));
}
EBlock::~EBlock()
{
}
void EBlock::Init()
{
titleText.setFont(*textFont);
titleText.setString("Hello World");
titleText.setCharacterSize(24);
titleText.setFillColor(sf::Color::Red);
drawingGroup.push_back(titleText);
}
void EBlock::Update()
{
backgroundShape.setPosition(getPosition());
titleText.setPosition(getPosition());
}
void EBlock::TranslateBlock()
{
}
void EBlock::TranslateBlock(std::string& getString)
{
}
bool EBlock::isMouseHovering(sf::Vector2f mousePosition)
{
return backgroundShape.getGlobalBounds().contains(mousePosition);
}
void EBlock::readyForSelect()
{
backgroundShape.setOutlineThickness(5);
backgroundShape.setOutlineColor(sf::Color::Green);
selected_b = true;
}
void EBlock::readyForDeselect()
{
backgroundShape.setOutlineThickness(0);
backgroundShape.setOutlineColor(sf::Color::Green);
selected_b = false;
}