aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/facade
diff options
context:
space:
mode:
authorheavydemon21 <nielsstunnebrink1@gmail.com>2024-12-18 11:31:54 +0100
committerheavydemon21 <nielsstunnebrink1@gmail.com>2024-12-18 11:31:54 +0100
commitea5e62b4ca8fbe214605abdab486bf6dcc1cc540 (patch)
treedb8eaad14aad977e8b5d82ff8ae1c6f4a757430e /src/crepe/facade
parent81404db80bbf9463c3d535ae389e7fbb753a902c (diff)
added particle begin lifespan rendering, added world_space to sprite so that coordinates are in camera_space or world_sapce
Diffstat (limited to 'src/crepe/facade')
-rw-r--r--src/crepe/facade/SDLContext.cpp17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/crepe/facade/SDLContext.cpp b/src/crepe/facade/SDLContext.cpp
index fffbe34..35f82d8 100644
--- a/src/crepe/facade/SDLContext.cpp
+++ b/src/crepe/facade/SDLContext.cpp
@@ -13,6 +13,7 @@
#include <cstddef>
#include <cstdint>
#include <functional>
+#include <iostream>
#include <memory>
#include <stdexcept>
@@ -137,6 +138,9 @@ SDL_FRect SDLContext::get_dst_rect(const DestinationRectangleData & ctx) const {
= (ctx.sprite.aspect_ratio == 0) ? ctx.texture.get_ratio() : ctx.sprite.aspect_ratio;
vec2 size = data.size;
+ vec2 screen_pos = ctx.pos + data.position_offset;
+
+
if (data.size.x == 0 && data.size.y != 0) {
size.x = data.size.y * aspect_ratio;
}
@@ -145,10 +149,15 @@ 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)
- * cam_aux_data.render_scale
- - size / 2 + cam_aux_data.bar_size;
+ if (ctx.sprite.data.world_space) {
+ cout << "world_space" << endl;
+ vec2 multiplier = cam_aux_data.cam_pos + (cam_aux_data.zoomed_viewport / 2) * cam_aux_data.render_scale - size / 2 + cam_aux_data.bar_size;
+ screen_pos += multiplier;
+ } else {
+ cout << "camera space" << endl;
+ vec2 multiplier = (cam_aux_data.zoomed_viewport / 2) * cam_aux_data.render_scale - size / 2 + cam_aux_data.bar_size;
+ screen_pos += multiplier;
+ }
return SDL_FRect{
.x = screen_pos.x,