aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/facade/SDLContext.h
diff options
context:
space:
mode:
authorheavydemon21 <nielsstunnebrink1@gmail.com>2024-11-20 11:35:25 +0100
committerheavydemon21 <nielsstunnebrink1@gmail.com>2024-11-20 11:35:25 +0100
commit52e84ca0a81210cd1dc61e096c228586649c9bfc (patch)
tree6442c070d225b4e348a3bc4603a52ad23f090da0 /src/crepe/facade/SDLContext.h
parent193e837fce92dcc169f995f670c9261f853ea1c3 (diff)
updated adjsuted rendering based on feedback
Diffstat (limited to 'src/crepe/facade/SDLContext.h')
-rw-r--r--src/crepe/facade/SDLContext.h26
1 files changed, 24 insertions, 2 deletions
diff --git a/src/crepe/facade/SDLContext.h b/src/crepe/facade/SDLContext.h
index 78ac56b..fb09015 100644
--- a/src/crepe/facade/SDLContext.h
+++ b/src/crepe/facade/SDLContext.h
@@ -1,8 +1,10 @@
#pragma once
#include <SDL2/SDL_keycode.h>
+#include <SDL2/SDL_rect.h>
#include <SDL2/SDL_render.h>
#include <SDL2/SDL_video.h>
+#include <cmath>
#include <functional>
#include <memory>
#include <string>
@@ -10,6 +12,7 @@
#include "../api/Sprite.h"
#include "../api/Transform.h"
#include "api/Camera.h"
+#include "api/Vector2.h"
namespace crepe {
@@ -122,8 +125,7 @@ private:
* \param camera Reference to the Camera for view adjustments.
*/
void draw(const Sprite & sprite, const Transform & transform, const Camera & camera);
-
- void draw_particle(const Vector2 & pos, const Camera & camera);
+ void draw_particle(const Sprite & sprite, const Vector2 & pos, const double & angle, const double & scale, const Camera & camera);
//! Clears the screen, preparing for a new frame.
void clear_screen();
@@ -138,6 +140,26 @@ private:
void camera(const Camera & camera);
private:
+ /**
+ * \brief calculates the sqaure size of the image
+ *
+ * \param sprite Reference to the sprite to calculate the rectangle
+ * \return sdl rectangle to draw a src image
+ */
+ SDL_Rect get_src_rect(const Sprite & sprite);
+ /**
+ * \brief calculates the sqaure size of the image for an destination
+ *
+ * \param sprite Reference to the sprite to calculate the rectangle
+ * \param pos the pos in pixel positions
+ * \param scale the multiplier to increase of decrease for the specified sprite
+ * \param cam Reference to the current camera in the scene to calculate the position based
+ * on the camera
+ * \return sdl rectangle to draw a dst image to draw on the screen
+ */
+ SDL_Rect get_dst_rect(const Sprite & sprite, const Vector2 & pos, const double & scale, const Camera & cam);
+
+private:
//! sdl Window
std::unique_ptr<SDL_Window, std::function<void(SDL_Window *)>> game_window;