game/mario/visitors/bounce_visitor.hpp

35 lines
714 B
C++
Raw Normal View History

#ifndef BOUNCE_VISITOR_HPP
#define BOUNCE_VISITOR_HPP
#include "../../sdlpp/sdlpp_visitor.hpp"
#include "../../sdlpp/sdlpp_geometry.hpp"
class BounceVisitor : public SDLPP::Visitor {
public:
2021-08-07 10:13:23 +00:00
BounceVisitor() = default;
2021-10-18 08:10:43 +00:00
void visit(const SDLPP::RenderObject &obj) override;
void setFromId(uint64_t id) override {
from = id;
}
2021-08-07 10:13:23 +00:00
uint64_t getFromId() const override {
return from;
}
2021-10-18 08:10:43 +00:00
void setVisitorType(uint64_t type) override {
_type = type;
}
2021-08-07 10:13:23 +00:00
uint64_t getVisitorType() const override {
return _type;
}
2021-08-07 10:13:23 +00:00
bool canBounce() const {
return hits < 2;
}
private:
int hits = 0;
2021-08-07 10:13:23 +00:00
uint64_t from{};
uint64_t _type{};
};
#endif