-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathtetris.hpp
44 lines (35 loc) · 919 Bytes
/
tetris.hpp
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
#pragma once
#include <SFML/Graphics.hpp>
#include <memory>
class Tetris {
static const std::uint32_t lines {20};
static const std::uint32_t cols {10};
static const std::uint32_t squares {4};
static const std::uint32_t shapes {7};
std::vector<std::vector<std::uint32_t>> area;
std::vector<std::vector<std::uint32_t>> forms;
struct Coords {
std::uint32_t x, y;
} z[squares], k[squares];
std::shared_ptr<sf::RenderWindow> window;
sf::Texture tiles, bg;
std::shared_ptr<sf::Sprite> sprite, background;
sf::Clock clock;
sf::Font font;
sf::Text txtScore, txtGameOver;
int dirx, color, score;
bool rotate, gameover;
float timercount, delay;
protected:
void events();
void draw();
void moveToDown();
void setRotate();
void resetValues();
void changePosition();
bool maxLimit();
void setScore();
public:
Tetris();
void run();
};