aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorheavydemon21 <nielsstunnebrink1@gmail.com>2024-12-02 18:51:47 +0100
committerheavydemon21 <nielsstunnebrink1@gmail.com>2024-12-02 18:51:47 +0100
commit135af8b0e0eaf8a5a5b7e1a42bfb20bb14ec97e5 (patch)
treec82dfadea7af5874f274ad105e94f05af19a9860 /src
parent54ab44e3508d526be6275378e5979290ec188d6f (diff)
tmp commit
Diffstat (limited to 'src')
-rw-r--r--src/crepe/api/Animator.h2
-rw-r--r--src/crepe/api/Sprite.h4
-rw-r--r--src/crepe/system/AnimatorSystem.cpp9
-rw-r--r--src/example/rendering_particle.cpp11
4 files changed, 13 insertions, 13 deletions
diff --git a/src/crepe/api/Animator.h b/src/crepe/api/Animator.h
index 188f193..511d6ef 100644
--- a/src/crepe/api/Animator.h
+++ b/src/crepe/api/Animator.h
@@ -89,7 +89,7 @@ public:
~Animator(); // dbg_trace
-private:
+public:
//! A reference to the Sprite sheet containing.
Sprite & spritesheet;
diff --git a/src/crepe/api/Sprite.h b/src/crepe/api/Sprite.h
index 96b57e1..354f663 100644
--- a/src/crepe/api/Sprite.h
+++ b/src/crepe/api/Sprite.h
@@ -74,10 +74,10 @@ public:
vec2 size;
//! independent sprite angle. rotating clockwise direction in degrees
- double angle_offset;
+ double angle_offset = 0;
//! independent sprite scale multiplier
- double scale;
+ double scale = 1;
/**
* \aspect_ratio ratio of the img so that scaling will not become weird
diff --git a/src/crepe/system/AnimatorSystem.cpp b/src/crepe/system/AnimatorSystem.cpp
index ee00728..1650b3d 100644
--- a/src/crepe/system/AnimatorSystem.cpp
+++ b/src/crepe/system/AnimatorSystem.cpp
@@ -4,6 +4,7 @@
#include "AnimatorSystem.h"
#include "ComponentManager.h"
+#include <iostream>
using namespace crepe;
@@ -25,11 +26,11 @@ void AnimatorSystem::update() {
int curr_frame = static_cast<int>(elapsed_time / frame_duration) % total_frames;
a.curr_row = a.cycle_start + curr_frame;
- a.spritesheet.mask.x = std::clamp((a.curr_row * a.spritesheet.mask.w - a.offset_x), 0,
- a.spritesheet.mask.w);
+ a.spritesheet.mask.x = a.curr_row * a.spritesheet.mask.w;
a.spritesheet.mask.y = (a.curr_col * a.spritesheet.mask.h);
-
- if (!a.looping && curr_frame == total_frames) {
+
+ std::cout << curr_frame << " " << total_frames << std::endl;
+ if (!a.looping && curr_frame == 0) {
a.active = false;
}
}
diff --git a/src/example/rendering_particle.cpp b/src/example/rendering_particle.cpp
index 026c9ce..5a50d27 100644
--- a/src/example/rendering_particle.cpp
+++ b/src/example/rendering_particle.cpp
@@ -53,16 +53,15 @@ public:
Color color(255, 255, 255, 255);
- auto img = Texture("asset/spritesheet/spritesheet_test.png");
+ auto img = Texture("asset/spritesheet/pokemon_spritesheet.png");
Sprite & test_sprite = game_object.add_component<Sprite>(
- img, color, Sprite::FlipSettings{true, true}, 1, 1, vec2{1, 1});
+ img, color, Sprite::FlipSettings{false, false}, 1, 1, vec2{100, 100});
- //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 & anim = game_object.add_component<Animator>(test_sprite, 4, 4, 0);
- auto & cam = game_object.add_component<Camera>(Color::RED, ivec2{1280, 720},
- vec2{2.59, 1.95}, 2.0);
+ auto & cam = game_object.add_component<Camera>(Color::, ivec2{720, 1280},
+ vec2{400, 400}, 1.0);
}
string get_name() const { return "TestScene"; };