This commit is contained in:
Crizomb 2025-06-15 19:22:33 +02:00
parent adcd6146ed
commit f30a490593
8 changed files with 93 additions and 4 deletions

View file

@ -0,0 +1,39 @@
#include "Carrot.hpp"
#include <SFML/System/Vector2.hpp>
Carrot::Carrot(const std::vector<std::string> &angry_paths,
const std::vector<std::string> &neutral_paths,
const std::vector<std::string> &happy_paths)
: angryAnimation(angry_paths), neutralAnimation(neutral_paths),
happyAnimation(happy_paths), carrotState(Neutral) {}
void Carrot::draw(sf::RenderWindow &RenderWindow, float dtime) {
switch (carrotState) {
case Angry:
RenderWindow.draw(angryAnimation);
angryAnimation.update(dtime);
break;
case Neutral:
RenderWindow.draw(neutralAnimation);
neutralAnimation.update(dtime);
break;
case Happy:
RenderWindow.draw(happyAnimation);
happyAnimation.update(dtime);
break;
}
}
void Carrot::setPosition(sf::Vector2f new_pos) {
angryAnimation.setPosition(new_pos);
neutralAnimation.setPosition(new_pos);
happyAnimation.setPosition(new_pos);
}
void Carrot::setScale(sf::Vector2f new_scale) {
angryAnimation.setScale(new_scale);
neutralAnimation.setScale(new_scale);
happyAnimation.setScale(new_scale);
}
void Carrot::changeState(CarrotState new_state) { carrotState = new_state; };