-
Notifications
You must be signed in to change notification settings - Fork 0
/
QuestionBox.cpp
79 lines (68 loc) · 1.7 KB
/
QuestionBox.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 <SFML/Graphics/RectangleShape.hpp>
#include <SFML/Graphics/Texture.hpp>
#include "QuestionBox.h"
QuestionBox::QuestionBox() {
x = 50;
y = 50;
w = 700;
h = 400;
}
//Checks for collisions of the answer buttons
bool QuestionBox::collision(sf::Vector2i mouseCoords, bool left) {
sf::IntRect inCorrectButtonArea(x + w - 140, y + h - 80, 80, 60);
sf::IntRect correctButtonArea(x + 60, y + 320, 80, 60);
if(left){
if (correctButtonArea.contains(mouseCoords)){
return true;
}
}
else{
if(inCorrectButtonArea.contains(mouseCoords)) {
return true;
}
}
return false;
}
sf::RectangleShape QuestionBox::showBox(){
sf::RectangleShape box(sf::Vector2f(w,h));
box.setPosition(x, y);
return box;
}
sf::RectangleShape QuestionBox::showButton(bool left){
sf::RectangleShape button(sf::Vector2f(80, 60));
if(left){
button.setPosition(x + w -140, y + h - 80);
if (isSpecial()){
button.setFillColor(sf::Color::Blue);
} else {
button.setFillColor(sf::Color::Red);
}
} else {
button.setPosition(x + 60, y + 320);
if (isSpecial()){
button.setFillColor(sf::Color::Red);
} else {
button.setFillColor(sf::Color::Green);
}
}
return button;
}
bool QuestionBox::getVisible() {
return visible;
}
bool QuestionBox::isSpecial() const {
return special;
}
void QuestionBox::makeVisibile() {
if(!visible){
visible = true;
}
}
void QuestionBox::makeInVisible(){
if(visible){
visible = false;
}
}
void QuestionBox::setSpecial(bool special) {
QuestionBox::special = special;
}