shorten is_playing to playing

This commit is contained in:
frank 2021-09-08 23:56:06 -04:00
parent 3b6b946560
commit e2f5126d0a
6 changed files with 12 additions and 14 deletions

View File

@ -8,7 +8,7 @@ Animation::Animation()
void Animation::play(float delay, bool play_once)
{
this->delay = delay;
playing = true;
play_state = true;
paused = false;
previous_step_time = timer.ms_elapsed();
overflow = 0;
@ -44,19 +44,19 @@ void Animation::unpause()
void Animation::reset()
{
timer.toggle(false);
playing = false;
play_state = false;
timer.reset();
}
bool Animation::is_playing(bool include_delay)
bool Animation::playing(bool include_delay) const
{
return playing && !paused && (include_delay || delay <= 0);
return play_state && !paused && (include_delay || delay <= 0);
}
void Animation::update()
{
timer.update();
if (playing && !paused && containing_object->is_active())
if (playing() && containing_object->is_active())
{
if (delay > 0)
{

View File

@ -15,7 +15,7 @@ class Animation
private:
bool playing = false, ending = false, paused = false;
bool play_state = false, ending = false, paused = false;
int previous_step_time = 0;
float delay = 0, overflow = 0, frame_length = 0;
callback step = nullptr;
@ -52,7 +52,7 @@ public:
void pause();
void unpause();
void reset();
bool is_playing(bool = true);
bool playing(bool = true) const;
void update();
};

View File

@ -90,11 +90,11 @@ void SoundEffect::set_loop_forever()
loops = -1;
}
bool SoundEffect::is_playing(bool include_delay)
bool SoundEffect::playing(bool include_delay) const
{
if (include_delay)
{
if (play_animation.is_playing())
if (play_animation.playing())
{
return true;
}

View File

@ -46,7 +46,7 @@ struct SoundEffect : Node
void set_volume(float);
void set_loop_count(int);
void set_loop_forever();
bool is_playing(bool = false);
bool playing(bool = false) const;
void update();
~SoundEffect();

View File

@ -3,11 +3,9 @@
#include <string>
#include <iostream>
#include "glm/vec2.hpp"
#include "json/json.hpp"
#include "SDL.h"
#include "filesystem.hpp"
class Game;

View File

@ -862,13 +862,13 @@ void Sprite::update(const std::vector<Box>& subsections)
}
for (std::size_t box_ii = 0; box_ii < boxes.size(); box_ii++)
{
if (subsections.size() == 0 && !wipe_animation.is_playing(false))
if (subsections.size() == 0 && !wipe_animation.playing(false))
{
SDL_RenderCopyF(renderer, texture, nullptr, &boxes[box_ii]);
}
else
{
if (wipe_animation.is_playing(false))
if (wipe_animation.playing(false))
{
for (const Box& blind : get_current_wipe_blinds())
{