CARROTE
This commit is contained in:
parent
adcd6146ed
commit
f30a490593
8 changed files with 93 additions and 4 deletions
39
SimpleGame/src/Source/Carrot.cpp
Normal file
39
SimpleGame/src/Source/Carrot.cpp
Normal 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; };
|
Loading…
Add table
Add a link
Reference in a new issue