2021-08-04 22:32:17 +00:00
|
|
|
#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;
|
|
|
|
void visit( const SDLPP::RenderObject &obj ) override;
|
|
|
|
void setFromId( uint64_t id ) override {
|
2021-08-04 22:32:17 +00:00
|
|
|
from = id;
|
|
|
|
}
|
2021-08-07 10:13:23 +00:00
|
|
|
uint64_t getFromId() const override {
|
2021-08-04 22:32:17 +00:00
|
|
|
return from;
|
|
|
|
}
|
2021-08-07 10:13:23 +00:00
|
|
|
void setVisitorType( uint64_t type ) override {
|
2021-08-04 22:32:17 +00:00
|
|
|
_type = type;
|
|
|
|
}
|
2021-08-07 10:13:23 +00:00
|
|
|
uint64_t getVisitorType() const override {
|
2021-08-04 22:32:17 +00:00
|
|
|
return _type;
|
|
|
|
}
|
|
|
|
|
2021-08-07 10:13:23 +00:00
|
|
|
bool canBounce() const {
|
2021-08-04 22:32:17 +00:00
|
|
|
return hits < 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
int hits = 0;
|
2021-08-07 10:13:23 +00:00
|
|
|
uint64_t from{};
|
|
|
|
uint64_t _type{};
|
2021-08-04 22:32:17 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|