2021-05-22 21:13:26 +00:00
|
|
|
#ifndef MARIO_H
|
|
|
|
#define MARIO_H
|
|
|
|
|
|
|
|
#include "../sdlpp/sdlpp_rectrenderer.hpp"
|
2021-05-23 21:32:15 +00:00
|
|
|
#include "sprites.hpp"
|
2021-07-22 22:08:05 +00:00
|
|
|
#include "blocks.hpp"
|
2021-05-22 21:13:26 +00:00
|
|
|
|
2021-07-22 22:08:05 +00:00
|
|
|
class Mario : public MarioBlock {
|
2021-05-22 21:13:26 +00:00
|
|
|
public:
|
2021-07-24 17:59:25 +00:00
|
|
|
Mario( int x, int y, const std::shared_ptr< SDLPP::Renderer > &renderer );
|
|
|
|
Mario( const std::shared_ptr< SDLPP::Renderer > &renderer );
|
2021-05-22 21:13:26 +00:00
|
|
|
void walkLeft();
|
|
|
|
void walkRight();
|
|
|
|
void setStanding();
|
2021-08-04 22:32:17 +00:00
|
|
|
void handleVisitor( SDLPP::Visitor &visitor ) override;
|
2021-05-22 21:54:01 +00:00
|
|
|
void jump();
|
|
|
|
void stopJump();
|
2021-08-04 22:32:17 +00:00
|
|
|
void custom_move( int ticks ) override;
|
2021-07-24 17:59:25 +00:00
|
|
|
void visit( SDLPP::Visitor &visitor ) override;
|
|
|
|
|
2021-05-22 21:13:26 +00:00
|
|
|
private:
|
|
|
|
bool faces_right = true;
|
2021-10-17 13:56:10 +00:00
|
|
|
double side_movement = 0.3;
|
2021-05-23 21:32:15 +00:00
|
|
|
double jump_movement = 1.0;
|
2021-05-22 21:54:01 +00:00
|
|
|
bool jumping = false;
|
|
|
|
bool stop_jump = false;
|
|
|
|
double max_jump = 0;
|
|
|
|
double min_jump = 0;
|
|
|
|
double slow_jump = 0;
|
|
|
|
bool on_ground = true;
|
2021-05-23 21:32:15 +00:00
|
|
|
int ticks_till_gravity = 0;
|
|
|
|
// gravity should be added every frame in 60fps game
|
2021-07-24 17:59:25 +00:00
|
|
|
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;
|
2021-08-04 22:32:17 +00:00
|
|
|
void setWorldTypeSrc( LandType::Value world ) override;
|
2021-05-22 21:13:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|