From 8abc6008880dd9ed0c16a68a126b49f0eb03caa2 Mon Sep 17 00:00:00 2001 From: heavydemon21 Date: Mon, 16 Dec 2024 20:52:43 +0100 Subject: fonting --- src/crepe/system/RenderSystem.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/crepe/system/RenderSystem.h') diff --git a/src/crepe/system/RenderSystem.h b/src/crepe/system/RenderSystem.h index fc7b46e..ae55404 100644 --- a/src/crepe/system/RenderSystem.h +++ b/src/crepe/system/RenderSystem.h @@ -27,6 +27,8 @@ public: void update() override; private: + + void render_text(); //! Clears the screen in preparation for rendering. void clear_screen(); -- cgit v1.2.3 From dff8c63a5af46fd3b0115e10efe9f0b67e9111b8 Mon Sep 17 00:00:00 2001 From: heavydemon21 Date: Tue, 17 Dec 2024 13:59:19 +0100 Subject: make format --- src/crepe/facade/Font.cpp | 1 - src/crepe/facade/SDLContext.cpp | 1 - src/crepe/system/RenderSystem.h | 1 - 3 files changed, 3 deletions(-) (limited to 'src/crepe/system/RenderSystem.h') diff --git a/src/crepe/facade/Font.cpp b/src/crepe/facade/Font.cpp index 81a9e7a..4694f7c 100644 --- a/src/crepe/facade/Font.cpp +++ b/src/crepe/facade/Font.cpp @@ -21,4 +21,3 @@ Font::Font(const Asset & src, Mediator & mediator) : Resource(src, mediator) { } TTF_Font * Font::get_font() const { return this->font.get(); } - diff --git a/src/crepe/facade/SDLContext.cpp b/src/crepe/facade/SDLContext.cpp index 27f2cb3..41c6d21 100644 --- a/src/crepe/facade/SDLContext.cpp +++ b/src/crepe/facade/SDLContext.cpp @@ -311,7 +311,6 @@ void SDLContext::draw_text(const RenderText & data) { * cam_aux_data.render_scale - size / 2 + cam_aux_data.bar_size; - SDL_FRect dstrect{ .x = screen_pos.x, .y = screen_pos.y, diff --git a/src/crepe/system/RenderSystem.h b/src/crepe/system/RenderSystem.h index 3476765..3aa846e 100644 --- a/src/crepe/system/RenderSystem.h +++ b/src/crepe/system/RenderSystem.h @@ -27,7 +27,6 @@ public: void update() override; private: - void render_text(); //! Clears the screen in preparation for rendering. void clear_screen(); -- cgit v1.2.3 From 68be6b67f79413cb4af0ca15262ca1547a7d0d41 Mon Sep 17 00:00:00 2001 From: heavydemon21 Date: Tue, 17 Dec 2024 14:16:47 +0100 Subject: finalized text rendering --- src/crepe/facade/SDLContext.cpp | 22 ++++++++++++++++------ src/crepe/facade/SDLContext.h | 5 +++++ src/crepe/system/RenderSystem.cpp | 26 +++++--------------------- src/crepe/system/RenderSystem.h | 8 ++------ 4 files changed, 28 insertions(+), 33 deletions(-) (limited to 'src/crepe/system/RenderSystem.h') diff --git a/src/crepe/facade/SDLContext.cpp b/src/crepe/facade/SDLContext.cpp index 41c6d21..c3c1b59 100644 --- a/src/crepe/facade/SDLContext.cpp +++ b/src/crepe/facade/SDLContext.cpp @@ -292,6 +292,8 @@ void SDLContext::draw_text(const RenderText & data) { const Text & text = data.text; const Font & font = data.font; const Transform & transform = data.transform; + std::unique_ptr> font_surface; + std::unique_ptr> font_texture; SDL_Color color{ .r = text.data.text_color.r, @@ -299,11 +301,20 @@ void SDLContext::draw_text(const RenderText & data) { .b = text.data.text_color.b, .a = text.data.text_color.a, }; - SDL_Surface * font_surface + SDL_Surface * tmp_font_surface = TTF_RenderText_Solid(font.get_font(), text.text.c_str(), color); - SDL_Texture * font_texture - = SDL_CreateTextureFromSurface(this->game_renderer.get(), font_surface); - SDL_FreeSurface(font_surface); + if (!tmp_font_surface) { + throw runtime_error(format("draw_text: font surface error: {}", SDL_GetError())); + } + font_surface = {tmp_font_surface, [](SDL_Surface * surface) { SDL_FreeSurface(surface); }}; + + SDL_Texture * tmp_font_texture + = SDL_CreateTextureFromSurface(this->game_renderer.get(), font_surface.get()); + if (!tmp_font_texture) { + throw runtime_error(format("draw_text: font texture error: {}", SDL_GetError())); + } + font_texture + = {tmp_font_texture, [](SDL_Texture * texture) { SDL_DestroyTexture(texture); }}; vec2 size = text.dimensions * cam_aux_data.render_scale; vec2 screen_pos = (transform.position + text.offset - cam_aux_data.cam_pos @@ -318,9 +329,8 @@ void SDLContext::draw_text(const RenderText & data) { .h = size.y, }; - SDL_RenderCopyExF(this->game_renderer.get(), font_texture, NULL, &dstrect, 0, NULL, + SDL_RenderCopyExF(this->game_renderer.get(), font_texture.get(), NULL, &dstrect, 0, NULL, SDL_FLIP_NONE); - SDL_DestroyTexture(font_texture); } void SDLContext::update_camera_view(const Camera & cam, const vec2 & new_pos) { diff --git a/src/crepe/facade/SDLContext.h b/src/crepe/facade/SDLContext.h index 066a881..aeace07 100644 --- a/src/crepe/facade/SDLContext.h +++ b/src/crepe/facade/SDLContext.h @@ -193,6 +193,11 @@ public: */ void draw(const RenderContext & ctx); + /** + * \brief draws a text to the screen + * + * \param data Reference to the rendering data needed to draw + */ void draw_text(const RenderText & data); //! Clears the screen, preparing for a new frame. diff --git a/src/crepe/system/RenderSystem.cpp b/src/crepe/system/RenderSystem.cpp index 2641435..42e4236 100644 --- a/src/crepe/system/RenderSystem.cpp +++ b/src/crepe/system/RenderSystem.cpp @@ -83,8 +83,11 @@ void RenderSystem::render_text() { RefVector texts = mgr.get_components_by_type(); - for (const Text & text : texts) { + for (Text & text : texts) { if (!text.active) continue; + if (!text.font.has_value()) text.font = ctx.get_font_from_name(text.font_family); + if (!text.font.has_value()) continue; + const Font & font = resource_manager.get(text.font.value()); const auto & transform = mgr.get_components_by_id(text.game_object_id).front().get(); @@ -149,11 +152,7 @@ void RenderSystem::render() { ResourceManager & resource_manager = this->mediator.resource_manager; RefVector sorted_sprites = this->sort(sprites); RefVector text_components = mgr.get_components_by_type(); - for (Text & text : text_components) { - const Transform & transform - = mgr.get_components_by_id(text.game_object_id).front().get(); - this->render_text(text, transform); - } + for (const Sprite & sprite : sorted_sprites) { if (!sprite.active) continue; const Transform & transform @@ -166,18 +165,3 @@ void RenderSystem::render() { this->render_normal(sprite, transform); } } -void RenderSystem::render_text(Text & text, const Transform & tm) { - SDLContext & ctx = this->mediator.sdl_context; - - if (!text.font.has_value()) { - text.font = ctx.get_font_from_name(text.font_family); - } - - ResourceManager & resource_manager = this->mediator.resource_manager; - - if (!text.font.has_value()) { - return; - } - const Asset & font_asset = text.font.value(); - const Font & res = resource_manager.get(font_asset); -} diff --git a/src/crepe/system/RenderSystem.h b/src/crepe/system/RenderSystem.h index 3aa846e..5fe24d7 100644 --- a/src/crepe/system/RenderSystem.h +++ b/src/crepe/system/RenderSystem.h @@ -27,7 +27,6 @@ public: void update() override; private: - void render_text(); //! Clears the screen in preparation for rendering. void clear_screen(); @@ -39,7 +38,7 @@ private: //! Renders the whole screen void render(); - + /** * \brief Renders all the particles on the screen from a given sprite. * @@ -53,11 +52,8 @@ private: bool render_particle(const Sprite & sprite, const double & scale); /** * \brief Renders all Text components - * - * \param text The text component to be rendered. - * \param tm the Transform component that holds the position,rotation and scale */ - void render_text(Text & text, const Transform & tm); + void render_text(); /** * \brief renders a sprite with a Transform component on the screen * -- cgit v1.2.3 From daff506e3b941a8bca8f6e785944fa5071a7130c Mon Sep 17 00:00:00 2001 From: heavydemon21 Date: Tue, 17 Dec 2024 14:19:41 +0100 Subject: adjusted comments --- src/crepe/system/RenderSystem.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/crepe/system/RenderSystem.h') diff --git a/src/crepe/system/RenderSystem.h b/src/crepe/system/RenderSystem.h index 5fe24d7..d5385eb 100644 --- a/src/crepe/system/RenderSystem.h +++ b/src/crepe/system/RenderSystem.h @@ -36,9 +36,13 @@ private: //! Updates the active camera used for rendering. void update_camera(); - //! Renders the whole screen + //! Renders all the sprites and particles void render(); - + + //! Renders all Text components + void render_text(); + +private: /** * \brief Renders all the particles on the screen from a given sprite. * @@ -50,10 +54,6 @@ private: * \return true if particles have been rendered */ bool render_particle(const Sprite & sprite, const double & scale); - /** - * \brief Renders all Text components - */ - void render_text(); /** * \brief renders a sprite with a Transform component on the screen * -- cgit v1.2.3 From d0286486b5fddcfb32dcd1f3010aef5368ee678e Mon Sep 17 00:00:00 2001 From: heavydemon21 Date: Wed, 18 Dec 2024 19:17:38 +0100 Subject: rendering met absoluut position util functie, particle ben ik nog jaro aan het overleggen dus er die werkt niet goed --- src/crepe/facade/SDLContext.cpp | 14 +++++++------- src/crepe/system/RenderSystem.cpp | 12 ++++++------ src/crepe/system/RenderSystem.h | 2 +- src/crepe/util/AbsoluutPosition.cpp | 20 ++++++++++++++++++++ src/crepe/util/AbsoluutPosition.h | 14 ++++++++++++++ src/crepe/util/CMakeLists.txt | 2 ++ src/example/rendering_particle.cpp | 27 ++++++++++++++++++++------- 7 files changed, 70 insertions(+), 21 deletions(-) create mode 100644 src/crepe/util/AbsoluutPosition.cpp create mode 100644 src/crepe/util/AbsoluutPosition.h (limited to 'src/crepe/system/RenderSystem.h') diff --git a/src/crepe/facade/SDLContext.cpp b/src/crepe/facade/SDLContext.cpp index f350250..d352adc 100644 --- a/src/crepe/facade/SDLContext.cpp +++ b/src/crepe/facade/SDLContext.cpp @@ -28,6 +28,7 @@ #include "SDLContext.h" #include "Texture.h" #include "types.h" +#include "util/AbsoluutPosition.h" using namespace crepe; using namespace std; @@ -148,8 +149,7 @@ SDL_FRect SDLContext::get_dst_rect(const DestinationRectangleData & ctx) const { } size *= cam_aux_data.render_scale * ctx.img_scale * data.scale_offset; - vec2 screen_pos = (ctx.pos + data.position_offset - cam_aux_data.cam_pos - + (cam_aux_data.zoomed_viewport) / 2) + vec2 screen_pos = (ctx.pos - cam_aux_data.cam_pos + (cam_aux_data.zoomed_viewport) / 2) * cam_aux_data.render_scale - size / 2 + cam_aux_data.bar_size; @@ -195,7 +195,7 @@ void SDLContext::draw_text(const RenderText & data) { const Text & text = data.text; const Font & font = data.font; - const Transform & transform = data.transform; + vec2 absoluut_pos = AbsoluutPosition::get_position(data.transform, data.text.offset); std::unique_ptr> font_surface; std::unique_ptr> font_texture; @@ -220,8 +220,8 @@ void SDLContext::draw_text(const RenderText & data) { font_texture = {tmp_font_texture, [](SDL_Texture * texture) { SDL_DestroyTexture(texture); }}; - vec2 size = text.dimensions * cam_aux_data.render_scale * transform.scale; - vec2 screen_pos = (transform.position + text.offset - cam_aux_data.cam_pos + vec2 size = text.dimensions * cam_aux_data.render_scale * data.transform.scale; + vec2 screen_pos = (absoluut_pos + text.offset - cam_aux_data.cam_pos + (cam_aux_data.zoomed_viewport) / 2) * cam_aux_data.render_scale - size / 2 + cam_aux_data.bar_size; @@ -233,8 +233,8 @@ void SDLContext::draw_text(const RenderText & data) { .h = size.y, }; - SDL_RenderCopyExF(this->game_renderer.get(), font_texture.get(), NULL, &dstrect, transform.rotation, NULL, - SDL_FLIP_NONE); + SDL_RenderCopyExF(this->game_renderer.get(), font_texture.get(), NULL, &dstrect, + data.transform.rotation, NULL, SDL_FLIP_NONE); } void SDLContext::update_camera_view(const Camera & cam, const vec2 & new_pos) { diff --git a/src/crepe/system/RenderSystem.cpp b/src/crepe/system/RenderSystem.cpp index bf2bfd3..ba09530 100644 --- a/src/crepe/system/RenderSystem.cpp +++ b/src/crepe/system/RenderSystem.cpp @@ -21,6 +21,7 @@ #include "RenderSystem.h" #include "types.h" +#include "util/AbsoluutPosition.h" using namespace crepe; using namespace std; @@ -99,8 +100,7 @@ void RenderSystem::render_text() { } } -bool RenderSystem::render_particle(const Sprite & sprite, const double & scale) { - +bool RenderSystem::render_particle(const Sprite & sprite, const Transform & tm){ ComponentManager & mgr = this->mediator.component_manager; SDLContext & ctx = this->mediator.sdl_context; ResourceManager & resource_manager = this->mediator.resource_manager; @@ -122,9 +122,9 @@ bool RenderSystem::render_particle(const Sprite & sprite, const double & scale) ctx.draw(SDLContext::RenderContext{ .sprite = sprite, .texture = res, - .pos = p.position, + .pos = AbsoluutPosition::get_position(tm, em.data.offset + sprite.data.position_offset), .angle = p.angle, - .scale = scale, + .scale = tm.scale, }); } } @@ -138,7 +138,7 @@ void RenderSystem::render_normal(const Sprite & sprite, const Transform & tm) { ctx.draw(SDLContext::RenderContext{ .sprite = sprite, .texture = res, - .pos = tm.position, + .pos = AbsoluutPosition::get_position(tm, sprite.data.position_offset), .angle = tm.rotation, .scale = tm.scale, }); @@ -158,7 +158,7 @@ void RenderSystem::render() { const Transform & transform = mgr.get_components_by_id(sprite.game_object_id).front().get(); - bool rendered_particles = this->render_particle(sprite, transform.scale); + bool rendered_particles = this->render_particle(sprite, transform); if (rendered_particles) continue; diff --git a/src/crepe/system/RenderSystem.h b/src/crepe/system/RenderSystem.h index d5385eb..762b11f 100644 --- a/src/crepe/system/RenderSystem.h +++ b/src/crepe/system/RenderSystem.h @@ -53,7 +53,7 @@ private: * constructor is now protected i cannot make tmp inside * \return true if particles have been rendered */ - bool render_particle(const Sprite & sprite, const double & scale); + bool render_particle(const Sprite & sprite, const Transform & tm); /** * \brief renders a sprite with a Transform component on the screen * diff --git a/src/crepe/util/AbsoluutPosition.cpp b/src/crepe/util/AbsoluutPosition.cpp new file mode 100644 index 0000000..296cc09 --- /dev/null +++ b/src/crepe/util/AbsoluutPosition.cpp @@ -0,0 +1,20 @@ +#include "AbsoluutPosition.h" + +using namespace crepe; + +vec2 AbsoluutPosition::get_position(const Transform & transform, const vec2 & offset) { + // Get the rotation in radians + float radians1 = transform.rotation * (M_PI / 180.0); + + // Calculate total offset with scale + vec2 total_offset = offset * transform.scale; + + // Rotate + float rotated_total_offset_x1 + = total_offset.x * cos(radians1) - total_offset.y * sin(radians1); + float rotated_total_offset_y1 + = total_offset.x * sin(radians1) + total_offset.y * cos(radians1); + + // Final positions considering scaling and rotation + return (transform.position + vec2(rotated_total_offset_x1, rotated_total_offset_y1)); +} diff --git a/src/crepe/util/AbsoluutPosition.h b/src/crepe/util/AbsoluutPosition.h new file mode 100644 index 0000000..30a7f93 --- /dev/null +++ b/src/crepe/util/AbsoluutPosition.h @@ -0,0 +1,14 @@ +#pragma once + +#include "api/Transform.h" + +#include "types.h" + +namespace crepe { + +class AbsoluutPosition { +public: + static vec2 get_position(const Transform & transform, const vec2 & offset); +}; + +} // namespace crepe diff --git a/src/crepe/util/CMakeLists.txt b/src/crepe/util/CMakeLists.txt index 94ed906..b4b9221 100644 --- a/src/crepe/util/CMakeLists.txt +++ b/src/crepe/util/CMakeLists.txt @@ -1,6 +1,7 @@ target_sources(crepe PUBLIC LogColor.cpp Log.cpp + AbsoluutPosition.cpp ) target_sources(crepe PUBLIC FILE_SET HEADERS FILES @@ -11,5 +12,6 @@ target_sources(crepe PUBLIC FILE_SET HEADERS FILES Proxy.hpp OptionalRef.h OptionalRef.hpp + AbsoluutPosition.h ) diff --git a/src/example/rendering_particle.cpp b/src/example/rendering_particle.cpp index 4430d75..9cf25d7 100644 --- a/src/example/rendering_particle.cpp +++ b/src/example/rendering_particle.cpp @@ -23,11 +23,11 @@ using namespace std; class TestScene : public Scene { public: void load_scene() { - GameObject game_object = new_object("", "", vec2{0, 0}, 0, 1); + GameObject game_object = new_object("", "", vec2{0, 0}, 45, 1); Color color(255, 255, 255, 255); - Asset img{"asset/spritesheet/spritesheet_test.png"}; + Asset img{"asset/texture/square.png"}; Sprite & test_sprite = game_object.add_component( img, Sprite::Data{ @@ -35,17 +35,30 @@ public: .flip = Sprite::FlipSettings{false, false}, .sorting_in_layer = 2, .order_in_layer = 2, - .size = {0, 0}, + .size = {1, 1}, .angle_offset = 0, - .position_offset = {0, 0}, + .position_offset = {0, 1}, }); - auto & cam = game_object.add_component(ivec2{1280, 720}, vec2{4000, 4000}, + Sprite & test_sprite1 + = game_object.add_component(img, Sprite::Data{ + .color = color, + .size = {1, 1}, + .position_offset = {0, -1}, + }); + + auto & cam = game_object.add_component(ivec2{1280, 720}, vec2{5, 5}, Camera::Data{ .bg_color = Color::WHITE, }); - game_object.add_component(vec2{4000, 400}, vec2{0, 0}, "ComicSansMS", - Text::Data{.text_color = Color::RED}, "TEST test"); + + /* + game_object.add_component(vec2{1, 1}, vec2{0, -0.5}, "ComicSansMS", + Text::Data{.text_color = Color::RED}, "test TEST"); + + game_object.add_component(vec2{1, 1}, vec2{0, 0.5}, "ComicSansMS", + Text::Data{.text_color = Color::BLACK}, "TEST test"); + */ } string get_name() const { return "TestScene"; }; -- cgit v1.2.3 From 26c6d4ade7e6748fe65d3ba8d9d267053d3cba2a Mon Sep 17 00:00:00 2001 From: heavydemon21 Date: Thu, 19 Dec 2024 14:07:52 +0100 Subject: adjusted tm naming --> transform and adjusted doxygen comments --- src/crepe/system/RenderSystem.cpp | 14 +++++++------- src/crepe/system/RenderSystem.h | 16 ++++------------ 2 files changed, 11 insertions(+), 19 deletions(-) (limited to 'src/crepe/system/RenderSystem.h') diff --git a/src/crepe/system/RenderSystem.cpp b/src/crepe/system/RenderSystem.cpp index e311604..e8339c3 100644 --- a/src/crepe/system/RenderSystem.cpp +++ b/src/crepe/system/RenderSystem.cpp @@ -99,7 +99,7 @@ void RenderSystem::render_text() { } } -bool RenderSystem::render_particle(const Sprite & sprite, const Transform & tm) { +bool RenderSystem::render_particle(const Sprite & sprite, const Transform & transform) { ComponentManager & mgr = this->mediator.component_manager; SDLContext & ctx = this->mediator.sdl_context; ResourceManager & resource_manager = this->mediator.resource_manager; @@ -123,14 +123,14 @@ bool RenderSystem::render_particle(const Sprite & sprite, const Transform & tm) .sprite = sprite, .texture = res, .pos = p.position, - .angle = p.angle + tm.rotation, - .scale = tm.scale, + .angle = p.angle + transform.rotation, + .scale = transform.scale, }); } } return rendering_particles; } -void RenderSystem::render_normal(const Sprite & sprite, const Transform & tm) { +void RenderSystem::render_normal(const Sprite & sprite, const Transform & transform) { SDLContext & ctx = this->mediator.sdl_context; ResourceManager & resource_manager = this->mediator.resource_manager; const Texture & res = resource_manager.get(sprite.source); @@ -138,9 +138,9 @@ void RenderSystem::render_normal(const Sprite & sprite, const Transform & tm) { ctx.draw(SDLContext::RenderContext{ .sprite = sprite, .texture = res, - .pos = tm.position, - .angle = tm.rotation, - .scale = tm.scale, + .pos = transform.position, + .angle = transform.rotation, + .scale = transform.scale, }); } diff --git a/src/crepe/system/RenderSystem.h b/src/crepe/system/RenderSystem.h index 762b11f..ed55dd5 100644 --- a/src/crepe/system/RenderSystem.h +++ b/src/crepe/system/RenderSystem.h @@ -47,20 +47,17 @@ private: * \brief Renders all the particles on the screen from a given sprite. * * \param sprite renders the particles with given texture - * \param tm the Transform component for scale. This is not a const reference because each - * particle has a position and rotation that needs to overwrite the transform position and - * rotation without overwriting the current transform. and because the transform - * constructor is now protected i cannot make tmp inside + * \param transform the component that holds the position, rotation, and scale. * \return true if particles have been rendered */ - bool render_particle(const Sprite & sprite, const Transform & tm); + bool render_particle(const Sprite & sprite, const Transform & transform); /** * \brief renders a sprite with a Transform component on the screen * * \param sprite the sprite component that holds all the data - * \param tm the Transform component that holds the position,rotation and scale + * \param transform the Transform component that holds the position,rotation and scale */ - void render_normal(const Sprite & sprite, const Transform & tm); + void render_normal(const Sprite & sprite, const Transform & transform); /** * \brief sort a vector sprite objects with @@ -70,11 +67,6 @@ private: */ RefVector sort(RefVector & objs) const; - /** - * \todo Add text rendering using SDL_ttf for text components. - * \todo Implement a text component and a button component. - * \todo Consider adding text input functionality. - */ }; } // namespace crepe -- cgit v1.2.3 From 7c8c94663fdedb212e993eec232e6d40290cb67e Mon Sep 17 00:00:00 2001 From: heavydemon21 Date: Thu, 19 Dec 2024 15:51:59 +0100 Subject: make format --- src/crepe/facade/SDLContext.cpp | 8 ++++---- src/crepe/facade/SDLContext.h | 2 +- src/crepe/system/RenderSystem.h | 1 - src/example/rendering_particle.cpp | 7 +++---- 4 files changed, 8 insertions(+), 10 deletions(-) (limited to 'src/crepe/system/RenderSystem.h') diff --git a/src/crepe/facade/SDLContext.cpp b/src/crepe/facade/SDLContext.cpp index dc3f362..6fb312b 100644 --- a/src/crepe/facade/SDLContext.cpp +++ b/src/crepe/facade/SDLContext.cpp @@ -153,13 +153,13 @@ SDL_FRect SDLContext::get_dst_rect(const DestinationRectangleData & ctx) const { size *= cam_aux_data.render_scale * ctx.img_scale * data.scale_offset; if (ctx.sprite.data.world_space) { - screen_pos = (screen_pos - cam_aux_data.cam_pos - + cam_aux_data.zoomed_viewport / 2) + screen_pos = (screen_pos - cam_aux_data.cam_pos + cam_aux_data.zoomed_viewport / 2) * cam_aux_data.render_scale - size / 2 + cam_aux_data.bar_size; } else { - screen_pos = (screen_pos + cam_aux_data.zoomed_viewport / 2) * cam_aux_data.render_scale - - size / 2 + cam_aux_data.bar_size; + screen_pos + = (screen_pos + cam_aux_data.zoomed_viewport / 2) * cam_aux_data.render_scale + - size / 2 + cam_aux_data.bar_size; } cout << "HALLO" << endl; diff --git a/src/crepe/facade/SDLContext.h b/src/crepe/facade/SDLContext.h index 7f07d34..e570073 100644 --- a/src/crepe/facade/SDLContext.h +++ b/src/crepe/facade/SDLContext.h @@ -19,9 +19,9 @@ #include "api/Sprite.h" #include "api/Transform.h" -#include "types.h" #include "EventData.h" #include "FontFacade.h" +#include "types.h" namespace crepe { class Texture; diff --git a/src/crepe/system/RenderSystem.h b/src/crepe/system/RenderSystem.h index ed55dd5..14e5c2d 100644 --- a/src/crepe/system/RenderSystem.h +++ b/src/crepe/system/RenderSystem.h @@ -66,7 +66,6 @@ private: * \return returns a sorted reference vector */ RefVector sort(RefVector & objs) const; - }; } // namespace crepe diff --git a/src/example/rendering_particle.cpp b/src/example/rendering_particle.cpp index b623596..5440fdd 100644 --- a/src/example/rendering_particle.cpp +++ b/src/example/rendering_particle.cpp @@ -38,7 +38,7 @@ public: .size = {1, 1}, .angle_offset = 0, .position_offset = {0, 1}, - .world_space = false, + .world_space = false, }); //auto & emitter = game_object.add_component(test_sprite, ParticleEmitter::Data{}); @@ -47,16 +47,15 @@ public: .color = color, .size = {1, 1}, .position_offset = {0, -1}, - .world_space = false, + .world_space = false, }); auto & cam = game_object.add_component(ivec2{1280, 720}, vec2{5, 5}, Camera::Data{ .bg_color = Color::WHITE, - .postion_offset = {1000,1000}, + .postion_offset = {1000, 1000}, }); - /* game_object.add_component(vec2{1, 1}, vec2{0, -0.5}, "ComicSansMS", Text::Data{.text_color = Color::RED}, "test TEST"); -- cgit v1.2.3