2021-04-25 20:42:55 +00:00
|
|
|
#ifndef MARIO_VISITOR_H
|
|
|
|
#define MARIO_VISITOR_H
|
|
|
|
|
|
|
|
#include "../sdlpp/sdlpp_visitor.hpp"
|
2021-04-26 19:59:21 +00:00
|
|
|
#include "../sdlpp/sdlpp_geometry.hpp"
|
2021-04-25 20:42:55 +00:00
|
|
|
|
|
|
|
class MarioVisitor : public SDLPP::Visitor {
|
|
|
|
public:
|
2021-05-25 10:26:04 +00:00
|
|
|
MarioVisitor(bool is_jumping) : jumping(is_jumping) {}
|
2021-04-26 19:59:21 +00:00
|
|
|
virtual void visit( const SDLPP::RenderObject &obj ) override;
|
2021-04-25 20:42:55 +00:00
|
|
|
bool isOnGround() {
|
|
|
|
return onGround;
|
|
|
|
}
|
|
|
|
bool isDead() {
|
|
|
|
return death;
|
|
|
|
}
|
2021-04-26 19:59:21 +00:00
|
|
|
bool isStopped() {
|
|
|
|
return stop;
|
|
|
|
}
|
|
|
|
double newXPos() {
|
|
|
|
return newX;
|
|
|
|
}
|
2021-05-02 12:14:11 +00:00
|
|
|
virtual void setFromId( uint64_t id ) override {
|
2021-04-26 19:59:21 +00:00
|
|
|
from = id;
|
|
|
|
}
|
2021-05-02 12:14:11 +00:00
|
|
|
virtual uint64_t getFromId() override {
|
|
|
|
return from;
|
|
|
|
}
|
|
|
|
virtual void setVisitorType( uint64_t type ) override {
|
|
|
|
_type = type;
|
|
|
|
}
|
|
|
|
virtual uint64_t getVisitorType() override {
|
|
|
|
return _type;
|
|
|
|
}
|
2021-04-29 10:33:31 +00:00
|
|
|
bool canGoLeft() {
|
|
|
|
return !left;
|
|
|
|
}
|
|
|
|
bool canGoRight() {
|
|
|
|
return !right;
|
|
|
|
}
|
2021-05-22 20:36:53 +00:00
|
|
|
double getGroundY() {
|
|
|
|
return groundY;
|
|
|
|
}
|
2021-05-23 21:57:29 +00:00
|
|
|
bool topBlock() {
|
|
|
|
return top_hit;
|
|
|
|
}
|
2021-05-25 10:26:04 +00:00
|
|
|
bool moveTop() {
|
|
|
|
return top_left_right;
|
|
|
|
}
|
|
|
|
const SDLPP::Vec2D<double> &getRightLeftPos() {
|
|
|
|
return rightleftpos;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool canDestroy() {
|
|
|
|
return jumping && !top_hit;
|
|
|
|
}
|
2021-04-26 19:59:21 +00:00
|
|
|
|
2021-04-25 20:42:55 +00:00
|
|
|
private:
|
|
|
|
bool onGround = false;
|
2021-05-22 20:36:53 +00:00
|
|
|
double groundY = 0;
|
2021-04-25 20:42:55 +00:00
|
|
|
bool death = false;
|
2021-04-26 19:59:21 +00:00
|
|
|
bool stop = false;
|
|
|
|
double newX;
|
|
|
|
uint64_t from = -1;
|
2021-04-29 10:33:31 +00:00
|
|
|
bool left = false;
|
|
|
|
bool right = false;
|
2021-05-02 12:14:11 +00:00
|
|
|
uint64_t _type = 0;
|
2021-05-23 21:57:29 +00:00
|
|
|
bool top_hit = false;
|
2021-05-25 10:26:04 +00:00
|
|
|
SDLPP::Vec2D<double> rightleftpos;
|
|
|
|
bool top_left_right = false;
|
|
|
|
bool jumping;
|
2021-04-25 20:42:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|