-
Notifications
You must be signed in to change notification settings - Fork 0
/
BoardGraphics.h
68 lines (54 loc) · 1.98 KB
/
BoardGraphics.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
66
67
68
#ifndef __BOARDGRAPHICS_H__
#define __BOARDGRAPHICS_H__
/**
* BoardGraphics.h
*
* $Revision$
* $Id$
*
* CBoardGraphics objekti ottaa luonnissa itselleen TetrisBoard-objektin, jota
* se mallintaa ruudulle.
*
* Piirto tapahtuu Graphics-luokkaa käyttäen.
*
* Tämän tulee rekisteröityä omalle TetrisBoardilleen changeListeneriksi:
* m_board->registerBoardChangeListener(this);
* jonka jälkeen tämä saa tiedon kun laudalla muuttuu joku, ja osaa piirtää
* muutoksen.
*
*/
#include "BoardChangeListener.h"
#include "Panel.h"
#include "TetrisBoard.h"
#include "Graphics.h"
#include "Config.h"
#include "GameStateListener.h"
class CBoardGraphics : public VBoardChangeListener, public VPanel, public VGameStateListener {
public:
/**
* myBoard = board jonka tämä luokka piirtää
* offsetX = mistä koordinaatista tämä alkaa piirtää
* offsetY = --||--
*
*/
CBoardGraphics(CTetrisBoard *myBoard, int offsetX, int offsetY);
virtual ~CBoardGraphics();
/** @see BoardChangeListener.h */
virtual void handleFreshBoard();
virtual void handleChangeInLines(const int *changedLines[], const int numLines);
virtual void handleChangeInCoord(const int x, const int y, const CELL_TYPE ct);
virtual void handleChangeInStats(const int score, const int reml, const int remll, const int level);
/** @see GameStateListener.h */
virtual void handleGameState(VGameStateListener::GAMESTATE state);
private:
CTetrisBoard *board; // tämä ei ole vastuussa boardin tuhoamisesta!
SGraphics *g; // eikä myöskään grafiikan tuhoamisesta!
SConfig *settings;
int m_squareWidth;
int m_squareHeight;
bool m_visible;
void drawCell(const int x, const int y, CELL_TYPE ct); // x ja y ovat boardin koordinaatteja, eivät ruudun
SGraphics::GCOLOR getCellTypeColor(const int x, const int y, const CELL_TYPE ct);
char getCellTypeChar(const int x, const int y, const CELL_TYPE ct);
};
#endif // __BOARDGRAPHICS_H__