game/mario/mario.hpp
zv0n 3437aa6b47
All checks were successful
continuous-integration/drone/push Build is passing
Mario: end of level logic
2022-09-23 16:46:50 +02:00

50 lines
1.4 KiB
C++

#ifndef MARIO_H
#define MARIO_H
#include "../sdlpp/sdlpp_rectrenderer.hpp"
#include "sprites.hpp"
#include "blocks.hpp"
class Mario : public MarioBlock {
public:
Mario(int x, int y, const std::shared_ptr<SDLPP::Renderer> &renderer);
Mario(const std::shared_ptr<SDLPP::Renderer> &renderer);
void walkLeft();
void walkRight();
void setStanding();
void handleVisitor(SDLPP::Visitor &visitor) override;
void jump();
void stopJump();
void custom_move(int ticks) override;
void visit(SDLPP::Visitor &visitor) override;
bool isDead() {
return _death;
}
private:
void setDeath(bool dead = true) {
_death = dead;
}
bool _death = false;
bool controllable = true;
bool faces_right = true;
double side_movement = 0.3;
double jump_movement = 1.0;
bool jumping = false;
bool stop_jump = false;
double max_jump = 0;
double min_jump = 0;
double slow_jump = 0;
bool on_ground = true;
int ticks_till_gravity = 0;
// gravity should be added every frame in 60fps game
const int base_gravity_ticks = 1000 / 60;
const double gravity_add_jumping = jump_movement / 32.0;
const double gravity_add_falling = jump_movement / (64.0 / 7.0);
std::shared_ptr<SDLPP::RectColider> top_collision = nullptr;
void setWorldTypeSrc(LandType::Value world) override;
void stopMovement();
};
#endif