Exploring raycasters and possibly make a little "doom like" game based on it.
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
#include "animator.hpp"
|
|
|
|
#include "constants.hpp"
|
|
|
|
#include <SFML/Audio.hpp>
|
|
|
|
#include "dbc.hpp"
|
|
|
|
|
|
|
|
void Animator::step(sf::Sprite& sprite, int rect_x, int rect_y, int rect_w, int rect_h) {
|
|
|
|
if(playing) {
|
|
|
|
count++;
|
|
|
|
frame = ((count / 4) % max_frames);
|
|
|
|
playing = frame != 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
sprite.setTextureRect(sf::IntRect({
|
|
|
|
{rect_x + frame * width, rect_y},
|
|
|
|
{rect_w, rect_h}}));
|
|
|
|
}
|
|
|
|
|
|
|
|
void Animator::play(bool sound_too) {
|
|
|
|
playing = true;
|
|
|
|
if(sound_too) sound.play();
|
|
|
|
}
|