Skip to content

Commit 1c88d68

Browse files
committed
Add Drawable::getPos(), because position was also exposing pixel coordinates
1 parent 6cdb805 commit 1c88d68

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/jngl/Drawable.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2012-2024 Jan Niklas Hasse <[email protected]>
1+
// Copyright 2012-2025 Jan Niklas Hasse <[email protected]>
22
// For conditions of distribution and use, see copyright notice in LICENSE.txt
33

44
#include "Drawable.hpp"
@@ -13,6 +13,10 @@ Drawable::Drawable() = default;
1313

1414
Drawable::~Drawable() = default;
1515

16+
Vec2 Drawable::getPos() const {
17+
return { getX(), getY() };
18+
}
19+
1620
void Drawable::setPos(const double x, const double y) {
1721
setX(x);
1822
setY(y);

src/jngl/Drawable.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ class Drawable {
3030
/// Called when drawing a frame
3131
virtual void draw() const = 0;
3232

33+
/// Returns position (not center)
34+
Vec2 getPos() const;
35+
3336
/// Sets the position of the top-left of the Drawable
3437
virtual void setPos(double x, double y);
3538

@@ -93,9 +96,10 @@ class Drawable {
9396
/// Override height (in screen coordinates)
9497
void setHeight(float);
9598

99+
private:
100+
/// Position in pixel, NOT screen coordinates
96101
Vec2 position;
97102

98-
private:
99103
/// Width and height in pixel, NOT screen coordinates
100104
float width = 0;
101105
float height = 0;

0 commit comments

Comments
 (0)