wPlot2D version: 0.1.0
A lightweight C++ library for clear and customizable 2D scientific plots.
Loading...
Searching...
No Matches
wPositionComponent.hpp
Go to the documentation of this file.
1/*
2+---------------------------------------------------------------------------------------------------------------------------------------------------+
3Created by Wilfried Koch.
4Copyright @ 2025 Wilfried Koch. All rights reserved.
5+---------------------------------------------------------------------------------------------------------------------------------------------------+
6*/
7
8#ifndef W_POSITION_COMPONENT_HPP
9#define W_POSITION_COMPONENT_HPP
10
12
13#pragma GCC diagnostic push
14#pragma GCC diagnostic ignored "-Wfloat-equal"
15#pragma GCC diagnostic ignored "-Wswitch-default"
16#include <SFML/Graphics.hpp>
17#pragma GCC diagnostic pop
18
19namespace wEngine
20{
21
44 {
45 public:
50 PositionComponent( sf::Vector2f position = sf::Vector2f( 0.0f, 0.0f ) );
51
52 /*
53 * @brief Virtual destructor.
54 */
55 virtual ~PositionComponent( ) = default;
56
61 [[nodiscard]] sf::Vector2f getPosition( ) const;
62
67 [[nodiscard]] sf::Vector2f getLastPosition( ) const;
68
73 void setPosition( sf::Vector2f newPosition );
74
81 void move( const sf::Vector2f& offset );
82
86 void debugPrint( ) const;
87 private:
88 sf::Vector2f mPosition;
89 sf::Vector2f mLastPosition;
90 };
91
92}//End of namespace wEngine
93
94#endif
Component()
Protected constructor to restrict instantiation to derived classes.
Definition wComponent.cpp:17
void move(const sf::Vector2f &offset)
Moves the position by an offset.
Definition wPositionComponent.cpp:52
void setPosition(sf::Vector2f newPosition)
Sets the 2D position to a new value.
Definition wPositionComponent.cpp:40
sf::Vector2f getPosition() const
Gets the current position of the component.
Definition wPositionComponent.cpp:30
void debugPrint() const
Outputs the position (x, y) to standard output for debugging.
Definition wPositionComponent.cpp:64
virtual ~PositionComponent()=default
sf::Vector2f getLastPosition() const
Returns the previous position (before the last move).
Definition wPositionComponent.cpp:35
PositionComponent(sf::Vector2f position=sf::Vector2f(0.0f, 0.0f))
Constructs a PositionComponent with the given position.
Definition wPositionComponent.cpp:17
Definition wColorComponent.cpp:9