aboutsummaryrefslogtreecommitdiff
path: root/src/crepe
diff options
context:
space:
mode:
authorheavydemon21 <nielsstunnebrink1@gmail.com>2024-11-08 12:16:41 +0100
committerheavydemon21 <nielsstunnebrink1@gmail.com>2024-11-08 12:16:41 +0100
commit2e0b75fc51c4ef025f6b74f7f1648d04039bb955 (patch)
tree8f77d29c65b5b4e99b17accc5aea48c1115e10e4 /src/crepe
parent9f029bf458d43492093507f9b59a67f4f22c283c (diff)
fixed the includes and const settings
Diffstat (limited to 'src/crepe')
-rw-r--r--src/crepe/api/Animator.cpp6
-rw-r--r--src/crepe/api/Animator.h3
-rw-r--r--src/crepe/api/Camera.cpp9
-rw-r--r--src/crepe/api/Camera.h3
-rw-r--r--src/crepe/api/Sprite.cpp9
-rw-r--r--src/crepe/api/Sprite.h6
-rw-r--r--src/crepe/api/Texture.cpp2
-rw-r--r--src/crepe/facade/SDLContext.cpp12
-rw-r--r--src/crepe/facade/SDLContext.h12
-rw-r--r--src/crepe/system/AnimatorSystem.cpp9
-rw-r--r--src/crepe/system/RenderSystem.cpp6
-rw-r--r--src/crepe/system/RenderSystem.h6
12 files changed, 43 insertions, 40 deletions
diff --git a/src/crepe/api/Animator.cpp b/src/crepe/api/Animator.cpp
index 3834e0b..0896bb0 100644
--- a/src/crepe/api/Animator.cpp
+++ b/src/crepe/api/Animator.cpp
@@ -1,11 +1,11 @@
+#include <cstdint>
-#include "Animator.h"
#include "Component.h"
#include "api/Sprite.h"
-
#include "util/log.h"
-#include <cstdint>
+
+#include "Animator.h"
using namespace crepe;
diff --git a/src/crepe/api/Animator.h b/src/crepe/api/Animator.h
index 3493623..ec29a7f 100644
--- a/src/crepe/api/Animator.h
+++ b/src/crepe/api/Animator.h
@@ -1,8 +1,9 @@
#pragma once
+#include <cstdint>
+
#include "Component.h"
#include "api/Sprite.h"
-#include <cstdint>
namespace crepe {
class AnimatorSystem;
diff --git a/src/crepe/api/Camera.cpp b/src/crepe/api/Camera.cpp
index 46a56b2..d423131 100644
--- a/src/crepe/api/Camera.cpp
+++ b/src/crepe/api/Camera.cpp
@@ -1,14 +1,17 @@
+#include <cstdint>
-#include "Camera.h"
#include "Component.h"
#include "api/Color.h"
#include "util/log.h"
-#include <cstdint>
+
+#include "Camera.h"
using namespace crepe;
-Camera::Camera(uint32_t id, const Color& color) : Component(id), bg_color(color), aspect_width(640), aspect_height(480), zoom(1), x(0),y(0){
+Camera::Camera(uint32_t id, const Color & color)
+ : Component(id), bg_color(color), aspect_width(640), aspect_height(480),
+ zoom(1), x(0), y(0) {
dbg_trace();
}
diff --git a/src/crepe/api/Camera.h b/src/crepe/api/Camera.h
index 022496d..1ff9f37 100644
--- a/src/crepe/api/Camera.h
+++ b/src/crepe/api/Camera.h
@@ -1,8 +1,9 @@
#pragma once
+#include <cstdint>
+
#include "Component.h"
#include "api/Color.h"
-#include <cstdint>
namespace crepe {
diff --git a/src/crepe/api/Sprite.cpp b/src/crepe/api/Sprite.cpp
index 3db8f2b..42e1177 100644
--- a/src/crepe/api/Sprite.cpp
+++ b/src/crepe/api/Sprite.cpp
@@ -1,17 +1,16 @@
-#include <cstdint>
#include <memory>
-#include "../util/log.h"
-
#include "Component.h"
-#include "Sprite.h"
#include "Texture.h"
#include "facade/SDLContext.h"
+#include "../util/log.h"
+
+#include "Sprite.h"
using namespace std;
using namespace crepe;
-Sprite::Sprite(game_object_id_t id, shared_ptr<Texture> image,
+Sprite::Sprite(game_object_id_t id, const shared_ptr<Texture> image,
const Color & color, const FlipSettings & flip)
: Component(id), color(color), flip(flip), sprite_image(image) {
dbg_trace();
diff --git a/src/crepe/api/Sprite.h b/src/crepe/api/Sprite.h
index 2e8b52a..6f83ac8 100644
--- a/src/crepe/api/Sprite.h
+++ b/src/crepe/api/Sprite.h
@@ -5,9 +5,9 @@
#include "api/Color.h"
#include "api/Texture.h"
-
#include "Component.h"
+
namespace crepe {
/**
@@ -62,7 +62,7 @@ public:
* \param color Color tint applied to the sprite.
* \param flip Flip settings for horizontal and vertical orientation.
*/
- Sprite(game_object_id_t id, std::shared_ptr<Texture> image,
+ Sprite(game_object_id_t id, const std::shared_ptr<Texture> image,
const Color & color, const FlipSettings & flip);
/**
@@ -72,7 +72,7 @@ public:
//! Texture used for the sprite
- std::shared_ptr<Texture> sprite_image;
+ const std::shared_ptr<Texture> sprite_image;
//! Color tint of the sprite
Color color;
//! Flip settings for the sprite
diff --git a/src/crepe/api/Texture.cpp b/src/crepe/api/Texture.cpp
index 5519e5e..f052e4d 100644
--- a/src/crepe/api/Texture.cpp
+++ b/src/crepe/api/Texture.cpp
@@ -2,8 +2,8 @@
#include "../facade/SDLContext.h"
#include "../util/log.h"
-
#include "Asset.h"
+
#include "Texture.h"
using namespace crepe;
diff --git a/src/crepe/facade/SDLContext.cpp b/src/crepe/facade/SDLContext.cpp
index bbeb3a9..9a2d15a 100644
--- a/src/crepe/facade/SDLContext.cpp
+++ b/src/crepe/facade/SDLContext.cpp
@@ -98,11 +98,11 @@ void SDLContext::handle_events(bool & running) {
*/
}
-void SDLContext::clear_screen() { SDL_RenderClear(this->game_renderer); }
-void SDLContext::present_screen() { SDL_RenderPresent(this->game_renderer); }
+void SDLContext::clear_screen() const { SDL_RenderClear(this->game_renderer); }
+void SDLContext::present_screen() const { SDL_RenderPresent(this->game_renderer); }
void SDLContext::draw(const Sprite & sprite, const Transform & transform,
- const Camera & cam) {
+ const Camera & cam) const {
static SDL_RendererFlip render_flip
= (SDL_RendererFlip) ((SDL_FLIP_HORIZONTAL * sprite.flip.flip_x)
@@ -147,7 +147,7 @@ void SDLContext::camera(const Camera & cam) {
const uint64_t SDLContext::get_ticks() const { return SDL_GetTicks64(); }
-SDL_Texture * SDLContext::texture_from_path(const char * path) {
+SDL_Texture * SDLContext::texture_from_path(const char * path) const {
dbg_trace();
SDL_Surface * tmp = IMG_Load(path);
@@ -165,12 +165,12 @@ SDL_Texture * SDLContext::texture_from_path(const char * path) {
return created_texture;
}
-int SDLContext::get_width(const Texture & ctx) {
+int SDLContext::get_width(const Texture & ctx) const {
int w;
SDL_QueryTexture(ctx.texture, NULL, NULL, &w, NULL);
return w;
}
-int SDLContext::get_height(const Texture & ctx) {
+int SDLContext::get_height(const Texture & ctx) const {
int h;
SDL_QueryTexture(ctx.texture, NULL, NULL, NULL, &h);
return h;
diff --git a/src/crepe/facade/SDLContext.h b/src/crepe/facade/SDLContext.h
index a08d0d8..3396697 100644
--- a/src/crepe/facade/SDLContext.h
+++ b/src/crepe/facade/SDLContext.h
@@ -101,21 +101,21 @@ private:
* \param path Path to the image file.
* \return Pointer to the created SDL_Texture.
*/
- SDL_Texture * texture_from_path(const char * path);
+ SDL_Texture * texture_from_path(const char * path) const;
/**
* \brief Gets the width of a texture.
* \param texture Reference to the Texture object.
* \return Width of the texture as an integer.
*/
- int get_width(const Texture & );
+ int get_width(const Texture & ) const ;
/**
* \brief Gets the height of a texture.
* \param texture Reference to the Texture object.
* \return Height of the texture as an integer.
*/
- int get_height(const Texture &);
+ int get_height(const Texture &) const ;
private:
@@ -129,17 +129,17 @@ private:
* \param camera Reference to the Camera for view adjustments.
*/
void draw(const Sprite & sprite, const Transform & transform,
- const Camera & camera);
+ const Camera & camera) const;
/**
* \brief Clears the screen, preparing for a new frame.
*/
- void clear_screen();
+ void clear_screen() const ;
/**
* \brief Presents the rendered frame to the screen.
*/
- void present_screen();
+ void present_screen() const ;
/**
* \brief Sets the current camera for rendering.
diff --git a/src/crepe/system/AnimatorSystem.cpp b/src/crepe/system/AnimatorSystem.cpp
index 052d264..3d6c807 100644
--- a/src/crepe/system/AnimatorSystem.cpp
+++ b/src/crepe/system/AnimatorSystem.cpp
@@ -1,15 +1,14 @@
+#include <cstdint>
+#include <functional>
+#include <vector>
-#include "AnimatorSystem.h"
#include "ComponentManager.h"
#include "facade/SDLContext.h"
#include "util/log.h"
-
#include "api/Animator.h"
-#include <cstdint>
-#include <functional>
-#include <vector>
+#include "AnimatorSystem.h"
using namespace crepe;
diff --git a/src/crepe/system/RenderSystem.cpp b/src/crepe/system/RenderSystem.cpp
index 149af68..849d810 100644
--- a/src/crepe/system/RenderSystem.cpp
+++ b/src/crepe/system/RenderSystem.cpp
@@ -20,9 +20,9 @@ RenderSystem & RenderSystem::get_instance() {
return instance;
}
-void RenderSystem::clear_screen() { SDLContext::get_instance().clear_screen(); }
+void RenderSystem::clear_screen() const { SDLContext::get_instance().clear_screen(); }
-void RenderSystem::present_screen() {
+void RenderSystem::present_screen() const {
SDLContext::get_instance().present_screen();
}
void RenderSystem::update_camera() {
@@ -36,7 +36,7 @@ void RenderSystem::update_camera() {
this->curr_cam = &cam;
}
}
-void RenderSystem::render_sprites() {
+void RenderSystem::render_sprites() const {
ComponentManager & mgr = ComponentManager::get_instance();
diff --git a/src/crepe/system/RenderSystem.h b/src/crepe/system/RenderSystem.h
index 684776b..c5e674a 100644
--- a/src/crepe/system/RenderSystem.h
+++ b/src/crepe/system/RenderSystem.h
@@ -43,12 +43,12 @@ private:
/**
* \brief Clears the screen in preparation for rendering.
*/
- void clear_screen();
+ void clear_screen() const;
/**
* \brief Presents the rendered frame to the display.
*/
- void present_screen();
+ void present_screen() const;
/**
* \brief Updates the active camera used for rendering.
@@ -58,7 +58,7 @@ private:
/**
* \brief Renders all active sprites to the screen.
*/
- void render_sprites();
+ void render_sprites() const;
/**
* \todo Include color handling for sprites.