Separate out Main.cpp
This commit is contained in:
parent
77d634015f
commit
48886ecfd8
10 changed files with 219 additions and 170 deletions
12
include/Block.hpp
Normal file
12
include/Block.hpp
Normal file
|
@ -0,0 +1,12 @@
|
|||
#pragma once
|
||||
|
||||
#include <BlockType.hpp>
|
||||
|
||||
class Block {
|
||||
public:
|
||||
BlockType* type;
|
||||
sf::Vector2i position;
|
||||
int rotation_state;
|
||||
Block();
|
||||
std::vector<sf::Vector2i> get_tiles();
|
||||
};
|
17
include/BlockType.hpp
Normal file
17
include/BlockType.hpp
Normal file
|
@ -0,0 +1,17 @@
|
|||
#pragma once
|
||||
|
||||
#include <TileType.hpp>
|
||||
|
||||
class BlockType {
|
||||
public:
|
||||
static BlockType i, j, l, o, s, t, z;
|
||||
static BlockType* list[];
|
||||
static BlockType* random() {
|
||||
return list[rand() % 7];
|
||||
}
|
||||
TileType* tile_type;
|
||||
std::vector<std::vector<bool>> grid;
|
||||
uint width, height, starting_line;
|
||||
bool rotate;
|
||||
BlockType(TileType* _tile_type, const std::vector<std::vector<bool>> _grid, bool _rotate = true);
|
||||
};
|
16
include/Config.hpp
Normal file
16
include/Config.hpp
Normal file
|
@ -0,0 +1,16 @@
|
|||
#define TILE_SIZE 20
|
||||
|
||||
#define GRID_WIDTH 14
|
||||
#define GRID_HEIGHT 20
|
||||
|
||||
#define WINDOW_WIDTH 500
|
||||
#define WINDOW_HEIGHT 440
|
||||
|
||||
#define PLAYFIELD_X 20
|
||||
#define PLAYFIELD_Y 20
|
||||
|
||||
#define LINES_PER_LEVEL 5
|
||||
#define POINTS_1_LINE 40
|
||||
#define POINTS_2_LINES 100
|
||||
#define POINTS_3_LINES 300
|
||||
#define POINTS_4_LINES 1200
|
18
include/NumberRenderer.hpp
Normal file
18
include/NumberRenderer.hpp
Normal file
|
@ -0,0 +1,18 @@
|
|||
#pragma once
|
||||
|
||||
#include <SFML/Graphics.hpp>
|
||||
|
||||
class NumberRenderer {
|
||||
public:
|
||||
sf::Texture texture;
|
||||
sf::IntRect comma_rect;
|
||||
sf::IntRect numeral_rects[10];
|
||||
NumberRenderer(
|
||||
sf::Texture _texture,
|
||||
sf::IntRect _comma_rect,
|
||||
std::initializer_list<sf::IntRect> _numeral_rects
|
||||
);
|
||||
void render(sf::RenderWindow* window, uint number, int x, int y);
|
||||
private:
|
||||
sf::Sprite sprite;
|
||||
};
|
12
include/TileType.hpp
Normal file
12
include/TileType.hpp
Normal file
|
@ -0,0 +1,12 @@
|
|||
#pragma once
|
||||
|
||||
#include <SFML/Graphics/Rect.hpp>
|
||||
|
||||
#include <Config.hpp>
|
||||
|
||||
class TileType {
|
||||
public:
|
||||
sf::IntRect texture_rect;
|
||||
sf::IntRect ghost_texture_rect;
|
||||
TileType(sf::IntRect _texture_rect, sf::IntRect _ghost_texture_rect);
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue