diff options
author | heavydemon21 <nielsstunnebrink1@gmail.com> | 2024-11-22 17:09:40 +0100 |
---|---|---|
committer | heavydemon21 <nielsstunnebrink1@gmail.com> | 2024-11-22 17:09:40 +0100 |
commit | aed904bdc2ddaf669940d922611229a171a1f220 (patch) | |
tree | 4067c75308b43f62bdcbd69af8d3c9a4e60abdc3 /src | |
parent | 8513b2dad0ec43678f17cca0510db4d1a938279a (diff) |
make format
Diffstat (limited to 'src')
-rw-r--r-- | src/crepe/api/Animator.cpp | 4 | ||||
-rw-r--r-- | src/crepe/api/Sprite.cpp | 3 | ||||
-rw-r--r-- | src/crepe/facade/SDLContext.cpp | 14 | ||||
-rw-r--r-- | src/crepe/facade/SDLContext.h | 10 | ||||
-rw-r--r-- | src/crepe/system/RenderSystem.cpp | 5 | ||||
-rw-r--r-- | src/crepe/system/RenderSystem.h | 6 | ||||
-rw-r--r-- | src/example/rendering_particle.cpp | 6 |
7 files changed, 27 insertions, 21 deletions
diff --git a/src/crepe/api/Animator.cpp b/src/crepe/api/Animator.cpp index 178b165..0043896 100644 --- a/src/crepe/api/Animator.cpp +++ b/src/crepe/api/Animator.cpp @@ -18,10 +18,10 @@ Animator::Animator(game_object_id_t id, Sprite & ss, int row, int col, int col_a animator_rect.h /= col; animator_rect.w /= row; animator_rect.x = 0; - animator_rect.y = col_animator * animator_rect.h; + animator_rect.y = col_animator * animator_rect.h; this->active = false; // need to do this for to get the aspect ratio for a single clipping in the spritesheet - this->spritesheet.aspect_ratio = (double)animator_rect.w / (double)animator_rect.h; + this->spritesheet.aspect_ratio = (double) animator_rect.w / (double) animator_rect.h; } Animator::~Animator() { dbg_trace(); } diff --git a/src/crepe/api/Sprite.cpp b/src/crepe/api/Sprite.cpp index 3853aab..c219dd0 100644 --- a/src/crepe/api/Sprite.cpp +++ b/src/crepe/api/Sprite.cpp @@ -16,8 +16,7 @@ Sprite::Sprite(game_object_id_t id, const shared_ptr<Texture> image, const Color color(color), flip(flip), sprite_image(image), - aspect_ratio(sprite_image->get_width() / sprite_image->get_height()) -{ + aspect_ratio(sprite_image->get_width() / sprite_image->get_height()) { dbg_trace(); this->sprite_rect.w = sprite_image->get_width(); diff --git a/src/crepe/facade/SDLContext.cpp b/src/crepe/facade/SDLContext.cpp index 29a8195..4619c46 100644 --- a/src/crepe/facade/SDLContext.cpp +++ b/src/crepe/facade/SDLContext.cpp @@ -107,8 +107,9 @@ SDL_Rect SDLContext::get_src_rect(const Sprite & sprite) const { .h = sprite.sprite_rect.h, }; } -SDL_Rect SDLContext::get_dst_rect(const Sprite & sprite, const Vector2 & pos, const Vector2 & cam_pos, - const double & img_scale, const Vector2 & cam_scale) const { +SDL_Rect SDLContext::get_dst_rect(const Sprite & sprite, const Vector2 & pos, + const Vector2 & cam_pos, const double & img_scale, + const Vector2 & cam_scale) const { int pixel_width, pixel_height; @@ -135,7 +136,8 @@ SDL_Rect SDLContext::get_dst_rect(const Sprite & sprite, const Vector2 & pos, co } void SDLContext::draw_particle(const Sprite & sprite, const Vector2 & pos, - const double & angle, const Vector2 & cam_pos, const double & img_scale, const Vector2 & cam_scale) { + const double & angle, const Vector2 & cam_pos, + const double & img_scale, const Vector2 & cam_scale) { SDL_RendererFlip render_flip = (SDL_RendererFlip) ((SDL_FLIP_HORIZONTAL * sprite.flip.flip_x) @@ -148,14 +150,16 @@ void SDLContext::draw_particle(const Sprite & sprite, const Vector2 & pos, &dstrect, angle, NULL, render_flip); } -void SDLContext::draw(const Sprite & sprite, const Transform & transform, const Vector2 & cam_pos, const Vector2 & cam_scale) { +void SDLContext::draw(const Sprite & sprite, const Transform & transform, + const Vector2 & cam_pos, const Vector2 & cam_scale) { SDL_RendererFlip render_flip = (SDL_RendererFlip) ((SDL_FLIP_HORIZONTAL * sprite.flip.flip_x) | (SDL_FLIP_VERTICAL * sprite.flip.flip_y)); SDL_Rect srcrect = this->get_src_rect(sprite); - SDL_Rect dstrect = this->get_dst_rect(sprite, transform.position, cam_pos, transform.scale, cam_scale); + SDL_Rect dstrect + = this->get_dst_rect(sprite, transform.position, cam_pos, transform.scale, cam_scale); SDL_RenderCopyEx(this->game_renderer.get(), sprite.sprite_image->texture.get(), &srcrect, &dstrect, transform.rotation, NULL, render_flip); diff --git a/src/crepe/facade/SDLContext.h b/src/crepe/facade/SDLContext.h index 04c60cc..4d97699 100644 --- a/src/crepe/facade/SDLContext.h +++ b/src/crepe/facade/SDLContext.h @@ -118,9 +118,12 @@ private: * \param transform Reference to the Transform for positioning. * \param camera Reference to the Camera for view adjustments. */ - void draw(const Sprite & sprite, const Transform & transform, const Vector2 & cam_pos, const Vector2 & cam_scale); + void draw(const Sprite & sprite, const Transform & transform, const Vector2 & cam_pos, + const Vector2 & cam_scale); - void draw_particle(const Sprite & sprite, const Vector2 & pos, const double & angle, const Vector2 & cam_pos, const double & img_scale, const Vector2 & cam_scale); + void draw_particle(const Sprite & sprite, const Vector2 & pos, const double & angle, + const Vector2 & cam_pos, const double & img_scale, + const Vector2 & cam_scale); //! Clears the screen, preparing for a new frame. void clear_screen(); @@ -152,7 +155,8 @@ private: * 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 Vector2 & cam_pos, const double & img_scale , const Vector2 & scale) const; + SDL_Rect get_dst_rect(const Sprite & sprite, const Vector2 & pos, const Vector2 & cam_pos, + const double & img_scale, const Vector2 & scale) const; private: //! sdl Window diff --git a/src/crepe/system/RenderSystem.cpp b/src/crepe/system/RenderSystem.cpp index 676ded6..1dd1699 100644 --- a/src/crepe/system/RenderSystem.cpp +++ b/src/crepe/system/RenderSystem.cpp @@ -72,13 +72,14 @@ bool RenderSystem::render_particle(const Sprite & sprite, const double & scale) for (const Particle & p : em.data.particles) { if (!p.active) continue; - this->context.draw_particle(sprite, p.position ,p.angle, this->curr_cam_ref->pos ,scale, this->scale); + this->context.draw_particle(sprite, p.position, p.angle, this->curr_cam_ref->pos, + scale, this->scale); } } return rendering_particles; } void RenderSystem::render_normal(const Sprite & sprite, const Transform & tm) { - this->context.draw(sprite, tm , this->curr_cam_ref->pos,this->scale); + this->context.draw(sprite, tm, this->curr_cam_ref->pos, this->scale); } void RenderSystem::render() { diff --git a/src/crepe/system/RenderSystem.h b/src/crepe/system/RenderSystem.h index 19edc02..f010a83 100644 --- a/src/crepe/system/RenderSystem.h +++ b/src/crepe/system/RenderSystem.h @@ -81,12 +81,10 @@ private: //! Pointer to the current active camera for rendering Camera * curr_cam_ref = nullptr; // TODO: needs a better solution - - Vector2 scale; - - SDLContext & context = SDLContext::get_instance(); + Vector2 scale; + SDLContext & context = SDLContext::get_instance(); }; } // namespace crepe diff --git a/src/example/rendering_particle.cpp b/src/example/rendering_particle.cpp index 6a91c19..fad174e 100644 --- a/src/example/rendering_particle.cpp +++ b/src/example/rendering_particle.cpp @@ -32,13 +32,13 @@ int main(int argc, char * argv[]) { Color color(255, 255, 255, 255); Sprite & test_sprite = game_object.add_component<Sprite>( - make_shared<Texture>("asset/spritesheet/spritesheet_test.png"), color, FlipSettings{true, true}); + make_shared<Texture>("asset/spritesheet/spritesheet_test.png"), color, + FlipSettings{true, true}); test_sprite.order_in_layer = 5; test_sprite.width = 1000; test_sprite.height = 500; - game_object.add_component<Animator>(test_sprite, 4,1,0).active = true; - + game_object.add_component<Animator>(test_sprite, 4, 1, 0).active = true; /* auto & test = game_object.add_component<ParticleEmitter>(ParticleEmitter::Data{ |