-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathblock.h
55 lines (38 loc) · 1010 Bytes
/
block.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
#ifndef BLOCK_H
#define BLOCK_H
#include "ball.h"
class Block : public GameObject, public IObserver {
public:
Block(float start_x, float start_y, float width, float height, int durability);
~Block();
float getWidth() const;
float getHeight() const;
void setSize(const sf::Vector2f &size);
float getLeft() const;
float getRight() const;
float getTop() const;
float getBottom() const;
bool isAlive() const;
void onHint();
void handleBallPosChange(Ball &ball);
Block* clone();
static unsigned getScore();
static void resetScore();
private:
void draw(sf::RenderTarget& target, sf::RenderStates states) const;
void updateShapeColor();
int life_cnt;
static unsigned score;
};
/** Prototype pattern **/
class BlockSpawner {
public:
BlockSpawner(float width, float height);
~BlockSpawner();
Block* getBlock(int type) const;
private:
Block *easyBlock;
Block *mediumBlock;
Block *strongBlock;
};
#endif