game/mario/visitors/turtle_visitor.hpp

87 lines
2.0 KiB
C++

#ifndef TURTLE_VISITOR_H
#define TURTLE_VISITOR_H
#include "../../sdlpp/sdlpp_visitor.hpp"
#include "../../sdlpp/sdlpp_geometry.hpp"
#include "../../sdlpp/sdlpp_scene.hpp"
#include "../blocks.hpp"
class TurtleVisitor : public SDLPP::Visitor {
public:
TurtleVisitor() = delete;
TurtleVisitor(const SDLPP::Vec2D<double> &pos) : turtle_pos(pos) {}
void visit(const SDLPP::RenderObject &obj) override;
bool isOnGround() const {
return onGround;
}
bool isDead() const {
return death;
}
bool instantDeath() const {
return instant_death;
}
void setFromId(uint64_t id) override {
from = id;
}
void setVisitorType(uint64_t type) override {
_type = type;
}
uint64_t getVisitorType() const override {
return _type;
}
uint64_t getFromId() const override {
return from;
}
bool canGoLeft() const {
return !left;
}
bool canGoRight() const {
return !right;
}
double getGroundY() const {
return groundY;
}
bool topBlock() const {
return top_hit;
}
const SDLPP::Vec2D<double> &getMovementBlockage() {
return movement_blockage;
}
double getValidXPos() const {
return validXPos;
}
bool switchMovement() const {
return switch_movement;
}
double getNextMovement() const {
return next_movement;
}
double getTurtleHitValidPos() const {
return valid_turtle_hit_pos;
}
bool shouldBounce() const {
return bounce;
}
private:
bool onGround = false;
double groundY = 0;
uint64_t _type{};
bool death = false;
bool instant_death = false;
uint64_t from = -1;
bool left = false;
bool right = false;
bool top_hit = false;
bool bounce = false;
SDLPP::Vec2D<double> movement_blockage;
double validXPos = 0;
const SDLPP::Vec2D<double> turtle_pos;
bool switch_movement = false;
double next_movement = 0;
double valid_turtle_hit_pos = 0;
};
#endif