talking carrot + super arguments
This commit is contained in:
parent
c8787846c3
commit
8b664a26ef
6 changed files with 98 additions and 7 deletions
|
@ -1,11 +1,19 @@
|
|||
#include "Carrot.hpp"
|
||||
#include "Arguments.hpp"
|
||||
#include <SFML/Graphics/Font.hpp>
|
||||
#include <SFML/Graphics/RenderWindow.hpp>
|
||||
#include <SFML/System/Vector2.hpp>
|
||||
#include <cstdlib>
|
||||
|
||||
Carrot::Carrot(const std::vector<std::string> &angry_paths,
|
||||
const std::vector<std::string> &neutral_paths,
|
||||
const std::vector<std::string> &happy_paths)
|
||||
const std::vector<std::string> &happy_paths, sf::Font &mFont)
|
||||
: angryAnimation(angry_paths), neutralAnimation(neutral_paths),
|
||||
happyAnimation(happy_paths), carrotState(Neutral) {}
|
||||
happyAnimation(happy_paths), carrotState(Angry), carrotText(mFont) {
|
||||
goodArguments = GOOD_ARGUMENTS;
|
||||
neutralArguments = NEUTRAL_ARGUMENTS;
|
||||
badArguments = BAD_ARGUMENTS;
|
||||
}
|
||||
|
||||
void Carrot::draw(sf::RenderWindow &RenderWindow, float dtime) {
|
||||
switch (carrotState) {
|
||||
|
@ -24,6 +32,27 @@ void Carrot::draw(sf::RenderWindow &RenderWindow, float dtime) {
|
|||
}
|
||||
}
|
||||
|
||||
void Carrot::handleText(sf::RenderWindow &renderWindow, float dtime) {
|
||||
renderWindow.draw(carrotText);
|
||||
timeBuffer += dtime;
|
||||
if (timeBuffer < timePerText)
|
||||
return;
|
||||
timeBuffer = 0;
|
||||
|
||||
int random = rand();
|
||||
switch (carrotState) {
|
||||
case Angry:
|
||||
carrotText.setString(badArguments[random % badArguments.size()]);
|
||||
break;
|
||||
case Neutral:
|
||||
carrotText.setString(neutralArguments[random % neutralArguments.size()]);
|
||||
break;
|
||||
case Happy:
|
||||
carrotText.setString(goodArguments[random % goodArguments.size()]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Carrot::setPosition(sf::Vector2f new_pos) {
|
||||
angryAnimation.setPosition(new_pos);
|
||||
neutralAnimation.setPosition(new_pos);
|
||||
|
|
|
@ -20,7 +20,7 @@ sf::Texture bgTexture;
|
|||
|
||||
Game::Game()
|
||||
: backGround(PLACE_HOLDER_TEXTURE),
|
||||
carrot(ANGRY_PATHS, NEUTRAL_PATHS, HAPPY_PATHS) {
|
||||
carrot(ANGRY_PATHS, NEUTRAL_PATHS, HAPPY_PATHS, mFont) {
|
||||
assert(mFont.openFromFile("media/Sansation.ttf"));
|
||||
mStatisticsText.setPosition({5.f, 5.f});
|
||||
mStatisticsText.setCharacterSize(10);
|
||||
|
@ -57,6 +57,10 @@ Game::Game()
|
|||
|
||||
carrot.setPosition(CARROT_POS);
|
||||
carrot.setScale(sf::Vector2f(5, 5));
|
||||
|
||||
carrot.setTextPosition(CARROT_TEXT_POS);
|
||||
carrot.setTextCharacterSize(30);
|
||||
carrot.setTextFillColor(sf::Color::Black);
|
||||
}
|
||||
|
||||
void generateTilePatternAndMusic(AudioEmitter &audio_emitter) {
|
||||
|
@ -129,7 +133,10 @@ void Game::render() {
|
|||
mWindow.draw(leftPressZone);
|
||||
mWindow.draw(middlePressZone);
|
||||
mWindow.draw(rightPressZone);
|
||||
|
||||
carrot.draw(mWindow, TimePerFrame.asSeconds());
|
||||
carrot.handleText(mWindow, TimePerFrame.asSeconds());
|
||||
|
||||
if (!NoteTile::update(TimePerFrame.asSeconds(), mWindow))
|
||||
update_scores(false);
|
||||
mWindow.draw(mStatisticsText);
|
||||
|
@ -158,9 +165,9 @@ void Game::update_scores(bool good_action) {
|
|||
ScoreMultiplierText.setString(
|
||||
std::format("ScoreMultiplier = {}", score_multiplier));
|
||||
|
||||
if (score_multiplier < 5) {
|
||||
if (score_multiplier < 15) {
|
||||
carrot.changeState(Angry);
|
||||
} else if (score_multiplier < 10) {
|
||||
} else if (score_multiplier < 35) {
|
||||
carrot.changeState(Neutral);
|
||||
} else {
|
||||
carrot.changeState(Happy);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue