Now have a timer for animations that does ticks with deltatime...maybe it works.
This commit is contained in:
parent
c0f69ed026
commit
b7394f832d
5 changed files with 121 additions and 6 deletions
20
animate2.hpp
20
animate2.hpp
|
|
@ -7,6 +7,7 @@
|
|||
#include <SFML/System/Time.hpp>
|
||||
#include <functional>
|
||||
#include "ease2.hpp"
|
||||
#include <fmt/core.h>
|
||||
|
||||
namespace animate2 {
|
||||
struct Sheet {
|
||||
|
|
@ -16,13 +17,30 @@ namespace animate2 {
|
|||
int frame_height{0};
|
||||
};
|
||||
|
||||
struct Timer {
|
||||
double DELTA = 1.0/60.0;
|
||||
double accumulator = 0.0;
|
||||
double prev_time = 0.0;
|
||||
double current_time = 0.0;
|
||||
double frame_duration = 0.0;
|
||||
double alpha = 0.0;
|
||||
sf::Clock clock{};
|
||||
|
||||
void begin();
|
||||
std::pair<int, double> commit();
|
||||
void start();
|
||||
void reset();
|
||||
void restart();
|
||||
sf::Time getElapsedTime();
|
||||
};
|
||||
|
||||
struct Sequence {
|
||||
std::vector<int> frames{};
|
||||
std::vector<std::chrono::milliseconds> durations{};
|
||||
size_t current{0};
|
||||
int loop_count{0};
|
||||
size_t frame_count{frames.size()};
|
||||
sf::Clock timer{};
|
||||
Timer timer{};
|
||||
float subframe{0.0f};
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue