-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOptions.cpp
More file actions
executable file
·66 lines (54 loc) · 1.51 KB
/
Copy pathOptions.cpp
File metadata and controls
executable file
·66 lines (54 loc) · 1.51 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
#include "Options.h"
#include <SFML/Window/Mouse.hpp>
#include <SFML/Window/Keyboard.hpp>
#include "Game.h"
#include "Menu.h"
#include <SFML/Window/Event.hpp>
Options::Options() {
t_music.openFromFile("Music/options.ogg");
t_music.setLoop(true);
t_music.play();
tex1.loadFromFile("Textures/backgroundoptions.jpeg");
background.setTexture(tex1);
background.setScale(0.85,0.85);
f1.loadFromFile("Fonts/neuropolxrg.ttf");
tx1.setFont(f1);
tx2.setFont(f1);
tx3.setFont(f1);
tx1.setString("How to play:");
tx1.setPosition(100,150);
tx1.setCharacterSize(40);
tx2.setString("Avoid the disks to win!");
tx2.setPosition(150,230);
tx3.setString("Game developed by Cedermaz Francisco Agustin");
tx3.setPosition(110,650);
tx3.setCharacterSize(22);
teximagef.loadFromFile("Textures/imagescore.png");
imagef.setTexture(teximagef);
imagef.setScale(1,1);
imagef.setPosition(530,30);
texbb.loadFromFile("Textures/buttonback.png");
buttonback.setTexture(texbb);
buttonback.setPosition(20,20);
buttonback.setScale(0.1,0.1);
}
void Options::Update (Game &g, RenderWindow & win) {
Vector2f mouse = win.mapPixelToCoords(Mouse::getPosition(win));
FloatRect boundsback = buttonback.getGlobalBounds();
if(boundsback.contains(mouse)){
if(Mouse::isButtonPressed(Mouse::Left)){
t_music.stop();
g.SetScene(new Menu());
}
}
}
void Options::Draw (RenderWindow & win) {
win.clear({0,0,0});
win.draw(background);
win.draw(tx1);
win.draw(tx2);
win.draw(tx3);
win.draw(imagef);
win.draw(buttonback);
win.display();
}