-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOption.cpp
More file actions
89 lines (84 loc) · 2.07 KB
/
Option.cpp
File metadata and controls
89 lines (84 loc) · 2.07 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#include"SFML/Graphics.hpp"
#include"Interface.h"
#include<iostream>
#include"Ludo.h"
using namespace std;
int main()
{
sf::RenderWindow win(sf::VideoMode::getFullscreenModes()[2], "OPTION");
Interface A((float)win.getSize().y, (float)win.getSize().x);
sf::Texture pic;
pic.loadFromFile("Ludo_pic.jpg");
sf::Sprite spr;
spr.setScale(sf::Vector2f(1,1));
spr.setTexture(pic);
//-------------------BACKGROUND IMAGE--------------
while (win.isOpen())
{
sf::Event event;
while (win.pollEvent(event))
{
if (event.type == event.Closed)
{
win.close();
}
}
if (sf::Mouse::isButtonPressed(sf::Mouse::Left))
{
sf::Vector2i mousePosition = sf::Mouse::getPosition(win);
if (A.text[0].getGlobalBounds().contains(static_cast<sf::Vector2f>(mousePosition)))
{
A.text[0].setFillColor(sf::Color::Color(22, 160, 133));
}
if (A.text[1].getGlobalBounds().contains(static_cast<sf::Vector2f>(mousePosition)))
{
A.text[1].setFillColor(sf::Color::Color(31, 97, 141));
Ludo l1(win,2);
l1.setNop(2);
l1.play(win);
}
else
{
A.text[1].setFillColor(sf::Color::Black);
}
if (A.text[2].getGlobalBounds().contains(static_cast<sf::Vector2f>(mousePosition)))
{
A.text[2].setFillColor(sf::Color::Blue);
Ludo l2(win, 3);
l2.setNop(3);
l2.play(win);
}
else
{
A.text[2].setFillColor(sf::Color::Black);
}
if (A.text[3].getGlobalBounds().contains(static_cast<sf::Vector2f>(mousePosition)))
{
A.text[3].setFillColor(sf::Color::Color(31,97, 141));
Ludo l3(win,4);
l3.setNop(4);
l3.play(win);
}
else
{
A.text[3].setFillColor(sf::Color::Black);
}
if (A.text[4].getGlobalBounds().contains(static_cast<sf::Vector2f>(mousePosition)))
{
A.text[4].setFillColor(sf::Color::Color(31,97,141));
Ludo l4(win,6);
l4.setNop(6);
l4.play(win);
}
else
{
A.text[4].setFillColor(sf::Color::Black);
}
}
win.clear();
win.draw(spr);
A.Draw(win);
win.display();
}
return 0;
}