aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorheavydemon21 <nielsstunnebrink1@gmail.com>2024-11-26 10:27:14 +0100
committerheavydemon21 <nielsstunnebrink1@gmail.com>2024-11-26 10:27:14 +0100
commitb4c07db977ab18302a0d953ef22a32a171e688f8 (patch)
tree72625d76c88324b01c0abf882576832b2294349b
parent60a9879f268977d57b460eec830a3f8b5b24e1a2 (diff)
make format
-rw-r--r--src/crepe/api/Config.h6
-rw-r--r--src/crepe/facade/SDLContext.cpp24
-rw-r--r--src/crepe/facade/SDLContext.h3
-rw-r--r--src/example/rendering_particle.cpp4
4 files changed, 19 insertions, 18 deletions
diff --git a/src/crepe/api/Config.h b/src/crepe/api/Config.h
index e1aef7d..6de93f0 100644
--- a/src/crepe/api/Config.h
+++ b/src/crepe/api/Config.h
@@ -65,9 +65,9 @@ public:
//! default window settings
struct {
- //TODO make this constexpr because this will never change
- vec2 def_size = {1080,720};
- vec2 pos = {0,0};
+ //TODO make this constexpr because this will never change
+ vec2 def_size = {1080, 720};
+ vec2 pos = {0, 0};
float zoom = 1.0f;
} win_set;
diff --git a/src/crepe/facade/SDLContext.cpp b/src/crepe/facade/SDLContext.cpp
index 8b29f8a..ac6b089 100644
--- a/src/crepe/facade/SDLContext.cpp
+++ b/src/crepe/facade/SDLContext.cpp
@@ -17,8 +17,8 @@
#include "../api/Transform.h"
#include "../util/Log.h"
-#include "types.h"
#include "SDLContext.h"
+#include "types.h"
using namespace crepe;
using namespace std;
@@ -123,7 +123,8 @@ SDL_Rect SDLContext::get_dst_rect(const Sprite & sprite, const vec2 & pos,
pixel_height *= img_scale;
int pixel_x = static_cast<int>((pos.x - cam_pos.x + this->window.x / 2 - pixel_width / 2));
- int pixel_y = static_cast<int>((pos.y - cam_pos.y + this->window.y / 2 - pixel_height / 2));
+ int pixel_y
+ = static_cast<int>((pos.y - cam_pos.y + this->window.y / 2 - pixel_height / 2));
return SDL_Rect{
.x = pixel_x,
@@ -133,9 +134,9 @@ SDL_Rect SDLContext::get_dst_rect(const Sprite & sprite, const vec2 & pos,
};
}
-void SDLContext::draw_particle(const Sprite & sprite, const vec2 & pos,
- const double & angle, const vec2 & cam_pos,
- const double & img_scale, const vec2 & cam_scale) {
+void SDLContext::draw_particle(const Sprite & sprite, const vec2 & pos, const double & angle,
+ const vec2 & cam_pos, const double & img_scale,
+ const vec2 & cam_scale) {
SDL_RendererFlip render_flip
= (SDL_RendererFlip) ((SDL_FLIP_HORIZONTAL * sprite.flip.flip_x)
@@ -148,8 +149,8 @@ void SDLContext::draw_particle(const Sprite & sprite, const vec2 & pos,
&dstrect, angle, NULL, render_flip);
}
-void SDLContext::draw(const Sprite & sprite, const Transform & transform,
- const vec2 & cam_pos, const vec2 & cam_scale) {
+void SDLContext::draw(const Sprite & sprite, const Transform & transform, const vec2 & cam_pos,
+ const vec2 & cam_scale) {
SDL_RendererFlip render_flip
= (SDL_RendererFlip) ((SDL_FLIP_HORIZONTAL * sprite.flip.flip_x)
@@ -166,19 +167,20 @@ void SDLContext::draw(const Sprite & sprite, const Transform & transform,
void SDLContext::set_camera(const Camera & cam, vec2 & scale) {
// resize window
- if ((int)this->window.x != (int) cam.screen.x || (int)this->window.y != (int) cam.screen.y) {
+ if ((int) this->window.x != (int) cam.screen.x
+ || (int) this->window.y != (int) cam.screen.y) {
SDL_SetWindowSize(this->game_window.get(), (int) cam.screen.x, (int) cam.screen.y);
this->window = cam.screen;
}
double screen_aspect = cam.screen.x / cam.screen.y;
double viewport_aspect = cam.viewport.x / cam.viewport.y;
-
+
// decide scaling factor for world to screen
scale = cam.screen / cam.viewport * cam.zoom;
SDL_Rect view;
-
+
// calculate black bars
if (screen_aspect > viewport_aspect) {
// lettorboxing
@@ -192,7 +194,7 @@ void SDLContext::set_camera(const Camera & cam, vec2 & scale) {
view.x = 0;
view.y = static_cast<int>(cam.screen.y - view.h) / 2;
}
- // set drawing area
+ // set drawing area
SDL_RenderSetViewport(this->game_renderer.get(), &view);
SDL_RenderSetLogicalSize(this->game_renderer.get(), cam.viewport.x, cam.viewport.y);
diff --git a/src/crepe/facade/SDLContext.h b/src/crepe/facade/SDLContext.h
index f72eecb..542a8bf 100644
--- a/src/crepe/facade/SDLContext.h
+++ b/src/crepe/facade/SDLContext.h
@@ -135,8 +135,7 @@ private:
* \param cam_scale camera scalar for world to screen
*/
void draw_particle(const Sprite & sprite, const vec2 & pos, const double & angle,
- const vec2 & cam_pos, const double & img_scale,
- const vec2 & cam_scale);
+ const vec2 & cam_pos, const double & img_scale, const vec2 & cam_scale);
//! Clears the screen, preparing for a new frame.
void clear_screen();
diff --git a/src/example/rendering_particle.cpp b/src/example/rendering_particle.cpp
index 54a90b5..c70e1af 100644
--- a/src/example/rendering_particle.cpp
+++ b/src/example/rendering_particle.cpp
@@ -13,8 +13,8 @@
#include <crepe/api/Sprite.h>
#include <crepe/api/Texture.h>
#include <crepe/api/Transform.h>
-#include <crepe/types.h>
#include <crepe/system/RenderSystem.h>
+#include <crepe/types.h>
#include <chrono>
#include <memory>
@@ -64,7 +64,7 @@ int main(int argc, char * argv[]) {
auto & cam = game_object.add_component<Camera>(Color::WHITE);
cam.pos = {500, 200};
- cam.viewport = {2000,1000};
+ cam.viewport = {2000, 1000};
/*
game_object