Page MenuHomePhabricator (Chris)

bubble.cpp
No OneTemporary

Authored By
Unknown
Size
947 B
Referenced Files
None
Subscribers
None

bubble.cpp

#include <cmath>
#include <array>
#include "bubble.h"
Bubble::Bubble():
state(BubbleState::DICE),
timeCounter(0),
posY(0)
{
spritesBubbles = {{spriteDice, spriteFootSteps}};
if (!textureDice.loadFromFile("assets/img/bubble_dice.png"))
std::exit(1);
if (!textureFootSteps.loadFromFile("assets/img/bubble_footsteps.png"))
std::exit(1);
spritesBubbles[0].setTexture(textureDice);
spritesBubbles[1].setTexture(textureFootSteps);
}
void Bubble::setPosition(float x, float y) {
Transformable::setPosition(x, y);
posY = y;
}
void Bubble::draw(sf::RenderTarget& target, sf::RenderStates states) const {
states.transform *= getTransform();
target.draw(spritesBubbles[state], states);
}
void Bubble::update(sf::Time deltaTime)
{
timeCounter += deltaTime.asSeconds()*10;
float modifier = sin(timeCounter)*5;
Transformable::setPosition(getPosition().x, posY+modifier);
}

File Metadata

Mime Type
text/x-c
Expires
Sun, Aug 16, 8:41 AM (1 d, 21 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
77436
Default Alt Text
bubble.cpp (947 B)

Event Timeline