Repository navigation
Expand file tree
/
Copy pathmainMenuState.h
More file actions
75 lines (57 loc) · 1.63 KB
/
Copy pathmainMenuState.h
File metadata and controls
75 lines (57 loc) · 1.63 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
//
// Created by Nina on 2022/1/10.
//
#ifndef HELLOSFML_MAINMENUSTATE_H
#define HELLOSFML_MAINMENUSTATE_H
#ifndef PD110_1_FP_MAINMENUSTATE_H
#define PD110_1_FP_MAINMENUSTATE_H
#include "GameState.h"
#include "Button.h"
class mainMenuState: public State{
private:
// variable
sf::RectangleShape background;
sf::RectangleShape Banner;
sf::Font font;
sf::Text banner_text; // text on the Banner
// Decoration
sf::Texture decoration_t1;
sf::Sprite decoration_s1;
sf::Texture decoration_t2;
sf::Sprite decoration_s2;
sf::Texture decoration_t3;
sf::Sprite decoration_s3;
float ballDirX;
float ballDirY;
float ballGravity = .1f;
sf::Vector2f ballVelocity = sf::Vector2f(4.f, 2.f);
float decoDir;
// music
sf::Music music;
std::map<std::string ,Button*> button; // map the button by string
// function
void initFont(); // font
void initButton();
void initBanner();
void initDecoration();
void initMusic();
public:
mainMenuState(sf::RenderWindow* window, std:: stack<State*>* states); // constructor
virtual ~mainMenuState(); // destructor
// functions
void endstate();
void updateInput(const float& dt);
void updateButton();
void renderButtons(sf::RenderTarget* target = NULL);
void ballmove();
void ballCollision();
void updateBall();
void imageMove();
void imageAnimation();
void updateImageAnimation();
void update(const float& dt);
void render(sf::RenderTarget* target = nullptr);
void ballVelocityChange();
};
#endif //PD110_1_FP_MAINMENUSTATE_H
#endif //HELLOSFML_MAINMENUSTATE_H