Minesweeper2  V1.1.1 Game in C++ by Górka Mateusz
TField.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include "SFML/Graphics.hpp"
4 #include "Const.hpp"
5 #include "Vector2D.hpp"
6 #include <stdint.h>
7 
13 class TField : public sf::Drawable {
14 private:
15  sf::Texture texture;
16  sf::Sprite sprite;
17 
18 public:
20  TField() = delete;
21 
26  TField( const uint8_t id );
27 
32  inline void set( const Vector2D& pos )
33  { sprite.setPosition( pos.x*FIELD_SIZE, pos.y*FIELD_SIZE + GUI_MARGIN_T ); }
34 
38  inline void hint()
39  { sprite.setScale( 0.9, 0.9 ); }
40 
44  inline void normal()
45  { sprite.setScale( 1, 1 ); }
46 
47 public:
53  inline void draw( sf::RenderTarget& target, sf::RenderStates state ) const override
54  { target.draw( sprite ); }
55 
56 
57 public:
61  static const char* const TEXTURE_ARR[ NUM_FIELD_VIEW ];
62 
63 };
TField::hint
void hint()
Set a hint style.
Definition: TField.hpp:38
TField
Templete of field view.
Definition: TField.hpp:13
Vector2D_t< short int >
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
TField::draw
void draw(sf::RenderTarget &target, sf::RenderStates state) const override
Draw method.
Definition: TField.hpp:53
Const.hpp
TField::set
void set(const Vector2D &pos)
Set position.
Definition: TField.hpp:32
Vector2D_t::x
T x
X coordinate of vectior.
Definition: Vector2D.hpp:11
Vector2D.hpp
TField::TField
TField()=delete
Constructor deleted.
NUM_FIELD_VIEW
#define NUM_FIELD_VIEW
Number of fields views.
Definition: Const.hpp:51
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
TField::normal
void normal()
Remove hint style.
Definition: TField.hpp:44
Vector2D_t::y
T y
Y coordinate of vectior.
Definition: Vector2D.hpp:12