Who knows
This commit is contained in:
parent
eaf5a55d18
commit
32e50969b4
45 changed files with 38346 additions and 38306 deletions
29
Rider.h
Normal file
29
Rider.h
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
//
|
||||
// Created by Benjamin on 4/29/2021.
|
||||
//
|
||||
|
||||
#ifndef SFML_TEMPLATE_RIDER_H
|
||||
#define SFML_TEMPLATE_RIDER_H
|
||||
|
||||
|
||||
class Rider : public GameSprite {
|
||||
private:
|
||||
GameSprite *mount;
|
||||
sf::Vector2f relativeLoc;
|
||||
public:
|
||||
Rider(const sf::Texture &texture, float scale, GameSprite *_mount, sf::Vector2f worldCoord) : GameSprite(texture, scale) {
|
||||
mount = _mount;
|
||||
relativeLoc = sf::Vector2f(worldCoord.x - mount->getPosition().x, worldCoord.y - mount->getPosition().y);
|
||||
relativeLoc = mount->getInverseTransform().transformPoint(relativeLoc);
|
||||
}
|
||||
|
||||
void update() override {
|
||||
sf::Vector2f newLoc = mount->getTransform().transformPoint(relativeLoc);
|
||||
setPosition(newLoc);
|
||||
|
||||
GameSprite::update();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#endif //SFML_TEMPLATE_RIDER_H
|
||||
Loading…
Add table
Add a link
Reference in a new issue