From b4c07db977ab18302a0d953ef22a32a171e688f8 Mon Sep 17 00:00:00 2001 From: heavydemon21 Date: Tue, 26 Nov 2024 10:27:14 +0100 Subject: make format --- src/crepe/api/Config.h | 6 +++--- src/crepe/facade/SDLContext.cpp | 24 +++++++++++++----------- src/crepe/facade/SDLContext.h | 3 +-- src/example/rendering_particle.cpp | 4 ++-- 4 files changed, 19 insertions(+), 18 deletions(-) (limited to 'src') 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((pos.x - cam_pos.x + this->window.x / 2 - pixel_width / 2)); - int pixel_y = static_cast((pos.y - cam_pos.y + this->window.y / 2 - pixel_height / 2)); + int pixel_y + = static_cast((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(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 #include #include -#include #include +#include #include #include @@ -64,7 +64,7 @@ int main(int argc, char * argv[]) { auto & cam = game_object.add_component(Color::WHITE); cam.pos = {500, 200}; - cam.viewport = {2000,1000}; + cam.viewport = {2000, 1000}; /* game_object -- cgit v1.2.3