-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtop_screen.cpp
107 lines (92 loc) · 2.5 KB
/
top_screen.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#include "head.h"
#include <iostream>
void top_screen()
{
//Texture load
sf::Texture button_back;
button_back.loadFromFile("data/button0.png");
button back(sf::Vector2f(150, 70), sf::Vector2f(75, 35), "BACK", font, 30, sf::Color::Black, button_back);
button down(sf::Vector2f(150, 70), sf::Vector2f(WIDTH - 75, HEIGHT - 35), "DOWN", font, 30, sf::Color::Black, button_back);
button up(sf::Vector2f(150, 70), sf::Vector2f(WIDTH - 75, 35), "UP", font, 30, sf::Color::Black, button_back);
button test(sf::Vector2f(150, 70), sf::Vector2f(WIDTH / 2, HEIGHT / 2), "TEST", font, 30, sf::Color::Black, button_back);
sf::View TView;
int pos_y = 0;
TView.reset(sf::FloatRect(0, pos_y, WIDTH, HEIGHT));
TView.setViewport(sf::FloatRect(0, 0, 1, 1));
while (States == Top)
{
sf::Event event;
while (windows.pollEvent(event))
{
if (event.type == sf::Event::Closed)
States = End;
if (event.type == sf::Event::MouseButtonPressed && event.key.code == sf::Mouse::Left)
{
if (back.mouse_over_button(windows))
States = Start;
if (down.mouse_over_button(windows))
{
pos_y += 50;
std::cout << pos_y << std::endl;
TView.reset(sf::FloatRect(0, pos_y, WIDTH, HEIGHT));
}
if (up.mouse_over_button(windows))
{
pos_y += 50;
std::cout << pos_y << std::endl;
TView.reset(sf::FloatRect(0, pos_y, WIDTH, HEIGHT));
}
}
if (event.type == sf::Event::MouseWheelMoved)
{
if (event.mouseWheel.delta == 1) //rolka do góry
{
pos_y -= 50;
TView.reset(sf::FloatRect(0, pos_y, WIDTH, HEIGHT));
}
else //rolka na dó³
{
pos_y += 50;
TView.reset(sf::FloatRect(0, pos_y, WIDTH, HEIGHT));
}
// display number of ticks mouse wheel has moved
//std::cout << event.mouseWheel.delta << '\n';
}
} //while
windows.clear(sf::Color::Green);
windows.setView(TView); //Nowy widok
windows.draw(rank);
windows.setView(windows.getDefaultView()); //Koniec elementów dla nowego widoku, rysujemy elementy na które widok nie ma wp³ywu
windows.draw(back);
windows.draw(down); //Do przesuwania widoku w dó³
windows.draw(up); //Do przesuwania widoku w górê
windows.display();
} //while
}
/*
klasa RankView
{
RankPosition
{
Rectangle z kolorem
Indeks z lewej nr_pozycji
Lewa stron: nick
Prawa stron: punkty
virtual draw (..)
{
rectangele, text, tex
}
vector <RankPositon>
push_back(nick, punkty)
RankView(Rank)
RankView()
~RankView()
{
vector clear
}
vitual draw(...)
{
for(..)
draw(vector.at)
}
*/