-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMenu.h
65 lines (55 loc) · 1.59 KB
/
Menu.h
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
#pragma once
#include "SFML/Graphics.hpp"
#include "Mario.h"
#include<iostream>
#include<fstream>
#include <algorithm>
#include <vector>
#define MAX_NUMBER_OF_ITEMS 5
#define NUMBER_OF_RESULTS 3
#define WINDOW_WIDTH 1024
#define WINDOW_HEIGHT 512
class result {
public:
std::string date;
std::string score;
std::string time;
std::string coins;
std::string userName;
result(std::string date, std::string score, std::string time, std::string coins, std::string userName) :date(date), score(score), time(time), coins(coins), userName(userName) {};
};
class Menu
{
private:
Mario mario;
sf::View view;
bool isOn = true;
int selectedItemIndex = 0;
sf::Font font;
sf::Text menu[MAX_NUMBER_OF_ITEMS];
std::vector<result> loadedResults;
sf::Text resultsToDisplay[NUMBER_OF_RESULTS];
public:
friend class tileMap;
Menu();
~Menu();
void followMario(int center); //draw menu at mario's position
void draw(sf::RenderWindow& window, int center);
void drawMenuBackground(sf::RenderWindow& window, int center);
void drawBestResults(sf::RenderWindow& window, int center); //draws scoreboard
void drawResults(sf::RenderWindow& window, int center);
void drawBestResultsBackground(sf::RenderWindow& window, int center);
void drawHelpMenu(sf::RenderWindow& window, int center);
void MoveUp();
void MoveDown();
int GetPressedItem();
void setPressedItem(int item);
bool isON();
void setIsON(bool status);
void readResultsFromFile();
void loadResultsToArray();
static bool comparator(result i1, result i2);
void sortResults();
void gameWon(int center, sf::RenderWindow& window);
void reset();
};