Minesweeper2  V1.1.1 Game in C++ by Górka Mateusz
TField Class Reference

Templete of field view. More...

#include <TField.hpp>

+ Inheritance diagram for TField:

Public Member Functions

 TField ()=delete
 Constructor deleted. More...
 
 TField (const uint8_t id)
 Construct a new TField object. More...
 
void set (const Vector2D &pos)
 Set position. More...
 
void hint ()
 Set a hint style. More...
 
void normal ()
 Remove hint style. More...
 
void draw (sf::RenderTarget &target, sf::RenderStates state) const override
 Draw method. More...
 

Static Public Attributes

static const char *const TEXTURE_ARR [NUM_FIELD_VIEW]
 Array of texture file code. More...
 

Private Attributes

sf::Texture texture
 Texture of field. More...
 
sf::Sprite sprite
 Sprite of field. More...
 

Detailed Description

Templete of field view.

See also
Display

Constructor & Destructor Documentation

◆ TField() [1/2]

TField::TField ( )
delete

Constructor deleted.

◆ TField() [2/2]

TField::TField ( const uint8_t  id)

Construct a new TField object.

Parameters
id- code of field.
  • Load a texture
  • Create a sprite
22  {
25 
27  sprite.setTexture( texture );
28 }

Member Function Documentation

◆ set()

void TField::set ( const Vector2D pos)
inline

Set position.

Parameters
pos-
33  { sprite.setPosition( pos.x*FIELD_SIZE, pos.y*FIELD_SIZE + GUI_MARGIN_T ); }

◆ hint()

void TField::hint ( )
inline

Set a hint style.

39  { sprite.setScale( 0.9, 0.9 ); }

◆ normal()

void TField::normal ( )
inline

Remove hint style.

45  { sprite.setScale( 1, 1 ); }

◆ draw()

void TField::draw ( sf::RenderTarget &  target,
sf::RenderStates  state 
) const
inlineoverride

Draw method.

Parameters
target-
state-
54  { target.draw( sprite ); }

Member Data Documentation

◆ texture

sf::Texture TField::texture
private

Texture of field.

◆ sprite

sf::Sprite TField::sprite
private

Sprite of field.

◆ TEXTURE_ARR

const char *const TField::TEXTURE_ARR
static
Initial value:
= {
"FE",
"F1",
"F2",
"F3",
"F4",
"F5",
"F6",
"F7",
"F8",
"FM",
"FF",
"FC",
}

Array of texture file code.

Codes are defined in inc/gui.rc.


The documentation for this class was generated from the following files:
TField::TEXTURE_ARR
static const char *const TEXTURE_ARR[NUM_FIELD_VIEW]
Array of texture file code.
Definition: TField.hpp:61
TField::sprite
sf::Sprite sprite
Sprite of field.
Definition: TField.hpp:16
GUI_MARGIN_T
#define GUI_MARGIN_T
GUI top margin.
Definition: Const.hpp:20
Vector2D_t::x
T x
X coordinate of vectior.
Definition: Vector2D.hpp:11
LoadTextureFromResource
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
TField::texture
sf::Texture texture
Texture of field.
Definition: TField.hpp:15
FIELD_SIZE
#define FIELD_SIZE
Sizes of field on the board.
Definition: Const.hpp:19
Vector2D_t::y
T y
Y coordinate of vectior.
Definition: Vector2D.hpp:12