 |
Minesweeper2
V1.1.1
Game in C++ by Górka Mateusz
|
Care about display on the interface.
More...
#include <Display.hpp>
|
static TField * | Template [NUM_FIELD_VIEW] = {NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL} |
| Templates of Field view. More...
|
|
Care about display on the interface.
◆ Display()
Construct a new Display object (default constructor)
◆ ~Display()
◆ pointer()
Field code to element on Templete array.
- Parameters
-
- Returns
- short int - id in the Templete array.
< id of field
- First time create new TField
- Return pointer
18 else if( field.
covered() )
id = 11;
19 else id = field.
val();
◆ config()
void Display::config |
( |
const Vector2D & |
size | ) |
|
Config a Display class.
- Load button textures
- Set positions and default texture of mode button
- Load font
- Score counter text config
- Set position and texture of mine counter
- Stopwatch text config
- Set position and texture of stopwatch
- Load start button
46 mine_txt.setFillColor( sf::Color::White );
◆ changeButt()
void Display::changeButt |
( |
const bool |
mode | ) |
|
Change a view of mode button.
- Postcondition
- Change texture in butt_mode
◆ board()
void Display::board |
( |
sf::RenderTarget & |
target, |
|
|
const Board *const |
board |
|
) |
| const |
Display board on the window.
- Parameters
-
target | - window target |
board | - game board |
Draw every field
125 if( !
board->created() ){
126 for( pos.
y = 0; pos.
y <
board->h(); ++pos.
y ){
127 for( pos.
x = 0; pos.
x <
board->w(); ++pos.
x ){
137 for( pos.
y = 0; pos.
y <
board->h(); ++pos.
y )
138 for( pos.
x = 0; pos.
x <
board->w(); ++pos.
x ){
150 for( pos.
y = 0; pos.
y <
board->h(); ++pos.
y )
151 for( pos.
x = 0; pos.
x <
board->w(); ++pos.
x ){
◆ draw()
void Display::draw |
( |
sf::RenderTarget & |
target | ) |
const |
Draw a interface of the game.
- Parameters
-
- Mode button draw
- Score counter draw
- Stopwatch draw
◆ drawStart()
void Display::drawStart |
( |
sf::RenderTarget & |
target | ) |
const |
|
inline |
Draw start button on interface.
- Parameters
-
◆ stopwatch()
void Display::stopwatch |
( |
unsigned int |
seconds | ) |
|
Update a value of stopwatch time.
- Parameters
-
91 if( seconds / 60 < 10 ) strm <<
'0';
92 strm << seconds / 60 <<
':';
93 if( seconds % 60 < 10 ) strm <<
'0';
◆ mineCounter()
void Display::mineCounter |
( |
short signed int |
mine | ) |
|
Update value of mine on the display.
- Parameters
-
◆ hideHint()
void Display::hideHint |
( |
| ) |
|
|
inline |
◆ Template
TField * Display::Template = {NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL} |
|
staticprivate |
Templates of Field view.
Default: array of NULL.
id | name |
0 | empty |
1-8 | values |
9 | mine |
10 | flag |
11 | covered |
- See also
- NUM_FIELD_VIEW, TField
Declaration od Template[]
◆ flag_texture
sf::Texture Display::flag_texture |
|
private |
◆ click_texture
sf::Texture Display::click_texture |
|
private |
Click mode "click" texture.
◆ mode_butt
sf::Sprite Display::mode_butt |
|
private |
◆ font
◆ start_texture
sf::Texture Display::start_texture |
|
private |
Mine counter counter backgroun texture.
◆ start_butt
sf::Sprite Display::start_butt |
|
private |
Mine counter counter background.
◆ mine_texture
sf::Texture Display::mine_texture |
|
private |
Mine counter counter backgroun texture.
◆ mine_bg
sf::Sprite Display::mine_bg |
|
private |
Mine counter counter background.
◆ mine_txt
sf::Text Display::mine_txt |
|
private |
Mine counter counter text.
◆ stopwatch_texture
sf::Texture Display::stopwatch_texture |
|
private |
Stopwatch background textrue.
◆ stopwatch_bg
sf::Sprite Display::stopwatch_bg |
|
private |
◆ stopwatch_txt
sf::Text Display::stopwatch_txt |
|
private |
◆ hintPos
Position of hint, NULL if no hint to display.
The documentation for this class was generated from the following files:
void hint()
Set a hint style.
Definition: TField.hpp:38
void board(sf::RenderTarget &target, const Board *const board) const
Display board on the window.
Definition: Display.cpp:121
#define COUNTER_X_BG
x position of mine counter background (from top-left corner)
Definition: Const.hpp:34
Templete of field view.
Definition: TField.hpp:13
sf::Sprite mode_butt
Mode button spirte.
Definition: Display.hpp:31
bool covered() const
Is field covered? (is covered)
Definition: Field.hpp:126
sf::Text mine_txt
Mine counter counter text.
Definition: Display.hpp:40
#define COUNTER_Y
y position of mine counter text (from top-left corner)
Definition: Const.hpp:37
sf::Sprite mine_bg
Mine counter counter background.
Definition: Display.hpp:39
sf::Texture mine_texture
Mine counter counter backgroun texture.
Definition: Display.hpp:38
sf::Sprite stopwatch_bg
Stopwatch background.
Definition: Display.hpp:43
#define STOPWATCH_X_BG
x position of stopwatch background (from top-right corner)
Definition: Const.hpp:27
Vector2D * hintPos
Position of hint, NULL if no hint to display.
Definition: Display.hpp:49
#define COUNTER_FONT
size of stopwatch font [px]
Definition: Const.hpp:38
sf::Font LoadFontFromResource(const char *const name)
Create a new sf::Font and load it from resoruces.
Definition: Func.cpp:28
void set(const Vector2D &pos)
Set position.
Definition: TField.hpp:32
sf::Texture start_texture
Mine counter counter backgroun texture.
Definition: Display.hpp:35
sf::Texture flag_texture
Click mode flag texture.
Definition: Display.hpp:29
sf::Texture click_texture
Click mode "click" texture.
Definition: Display.hpp:30
T x
X coordinate of vectior.
Definition: Vector2D.hpp:11
sf::Text stopwatch_txt
Stopwatch text.
Definition: Display.hpp:44
sf::Font font
Font.
Definition: Display.hpp:33
#define COUNTER_Y_BG
y position of mine counter background (from top-left corner)
Definition: Const.hpp:35
sf::Texture LoadTextureFromResource(const char *const name)
Creates a new sf::Texture and loads it with Texture data from a resource (.rc) file https://github....
Definition: Func.cpp:6
bool flagged() const
Is field flagged? ** flagged field is covered! **.
Definition: Field.hpp:109
#define STOPWATCH_Y
y position of stopwatch text (from top-right corner)
Definition: Const.hpp:30
#define NUM_FIELD_VIEW
Number of fields views.
Definition: Const.hpp:51
sf::Texture stopwatch_texture
Stopwatch background textrue.
Definition: Display.hpp:42
sf::Sprite start_butt
Mine counter counter background.
Definition: Display.hpp:36
static TField *const pointer(const Field &field)
Field code to element on Templete array.
Definition: Display.cpp:14
#define START_Y
y position of start button (from top edge
Definition: Const.hpp:42
#define STOPWATCH_Y_BG
y position of stopwatch background (from top-right corner)
Definition: Const.hpp:28
uint8_t val() const
Return value of field.
Definition: Field.hpp:72
#define MODE_BUTT_W
Width of mode button.
Definition: Const.hpp:23
#define FIELD_SIZE
Sizes of field on the board.
Definition: Const.hpp:19
#define COUNTER_X
x position of mine counter text (from top-left corner)
Definition: Const.hpp:36
void normal()
Remove hint style.
Definition: TField.hpp:44
#define STOPWATCH_X
x position of stopwatch text (from top-right corner)
Definition: Const.hpp:29
T y
Y coordinate of vectior.
Definition: Vector2D.hpp:12
#define STOPWATCH_FONT
size of stopwatch font [px]
Definition: Const.hpp:31
static TField * Template[NUM_FIELD_VIEW]
Templates of Field view.
Definition: Display.hpp:26
Field of the board.
Definition: Field.hpp:26
#define MODE_BUTT_Y
Y position of mode button (x is variable)
Definition: Const.hpp:24
#define START_X
x position of start button (from center point)
Definition: Const.hpp:41