aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/facade/SDLContext.h
diff options
context:
space:
mode:
authorWBoerenkamps <wrj.boerenkamps@student.avans.nl>2024-11-24 22:12:31 +0100
committerWBoerenkamps <wrj.boerenkamps@student.avans.nl>2024-11-24 22:12:31 +0100
commit24e3f0ea7c5ce90af1276dca49644b5e1ac799f6 (patch)
tree465dd020c1700511a1697267268b3d975caefd48 /src/crepe/facade/SDLContext.h
parent6287d4e9068d8bd27a9e62643f54adb69e84befd (diff)
parentbe5ccbe24086d5d4fb407f268c649dcbc36eda6b (diff)
merge
Diffstat (limited to 'src/crepe/facade/SDLContext.h')
-rw-r--r--src/crepe/facade/SDLContext.h39
1 files changed, 29 insertions, 10 deletions
diff --git a/src/crepe/facade/SDLContext.h b/src/crepe/facade/SDLContext.h
index dcd7440..5b6b093 100644
--- a/src/crepe/facade/SDLContext.h
+++ b/src/crepe/facade/SDLContext.h
@@ -1,8 +1,10 @@
#pragma once
#include <SDL2/SDL.h>
#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>
@@ -14,17 +16,13 @@
#include "../api/Event.h"
#include "api/Camera.h"
-// FIXME: this needs to be removed
-const int SCREEN_WIDTH = 640;
-const int SCREEN_HEIGHT = 480;
+#include "types.h"
namespace crepe {
// TODO: SDL_Keycode is defined in a header not distributed with crepe, which means this
// typedef is unusable when crepe is packaged. Wouter will fix this later.
//typedef SDL_Keycode CREPE_KEYCODES;
-
-class Texture;
class LoopManager;
class InputSystem;
/**
@@ -119,9 +117,6 @@ private:
//! Will use the funtions: texture_from_path, get_width,get_height.
friend class Texture;
- //! Will use the funtions: texture_from_path, get_width,get_height.
- friend class Animator;
-
/**
* \brief Loads a texture from a file path.
* \param path Path to the image file.
@@ -155,6 +150,9 @@ private:
*/
void draw(const Sprite & sprite, const Transform & transform, const Camera & camera);
+ void draw_particle(const Sprite & sprite, const vec2 & pos, const double & angle,
+ const double & scale, const Camera & camera);
+
//! Clears the screen, preparing for a new frame.
void clear_screen();
@@ -162,10 +160,31 @@ private:
void present_screen();
/**
- * \brief Sets the current camera for rendering.
+ * \brief sets the background of the camera (will be adjusted in future PR)
* \param camera Reference to the Camera object.
*/
- void camera(const Camera & camera);
+ void set_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) const;
+ /**
+ * \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 vec2 & pos, const double & scale,
+ const Camera & cam) const;
private:
//! sdl Window