31 virtual void draw()
const = 0;
34 virtual void setPos(
double x,
double y);
37 template <
class Vect>
void setPos(Vect p) {
54 void setLeft(
double x);
58 void setTop(
double y);
62 void setRight(
double x);
66 void setBottom(
double y);
106 return (box.getX() <= point.
x && point.
x < box.getX() + box.getWidth() &&
107 box.getY() <= point.
y && point.
y < box.getY() + box.getHeight());
Contains jngl::Vec2 class.
Base class for drawable objects with a position and a rectangle size.
double getBottom() const
Returns the distance from the bottom of the screen.
virtual void draw() const =0
Called when drawing a frame.
double getTop() const
Returns the distance from the top of the screen.
void setWidth(float)
Override width (in screen coordinates)
virtual void setPos(double x, double y)
Sets the position of the top-left of the Drawable.
void setCenter(Vect c)
Centers the Sprite at c (e.g. jngl::Vec2)
bool contains(jngl::Vec2 point) const
Returns whether point is inside the bounding box.
void drawBoundingBox() const
Draws a red box around the Drawable.
virtual void step()=0
Advance object's state.
float getWidth() const
Returns the width in screen coordinates.
double getRight() const
Returns the distance from the right side of the screen.
jngl::Vec2 getCenter() const
Returns the position of the center of the Drawable.
float getHeight() const
Returns the height in screen coordinates.
Vec2 getSize() const
Returns {width, height} in screen coordinates.
virtual void setCenter(double x, double y)
Centers the Sprite at (x, y)
void setHeight(float)
Override height (in screen coordinates)
void setPos(Vect p)
Sets the position of the top-left of the Drawable.
double getLeft() const
Returns the distance from the left side of the screen.
Higher-level representation of an image.
Rectangle shaped text block.
bool contains(const Box &box, const Vec2 point)
Pass any class that implements getX(), getY(), getWidth() and getHeight()