Mario: add travelToPos function to blocks
This commit is contained in:
+28
-2
@@ -2,6 +2,7 @@
|
||||
#define BLOCKS_H
|
||||
|
||||
#include "../sdlpp/sdlpp_rectrenderer.hpp"
|
||||
#include <SDL2/SDL_rect.h>
|
||||
#include <memory>
|
||||
|
||||
struct LandType {
|
||||
@@ -18,6 +19,7 @@ public:
|
||||
void setTool( bool tool = true );
|
||||
void setTerrain( bool terrain = true );
|
||||
void bounce();
|
||||
void travelToPos(const SDLPP::Vec2D<double> &target);
|
||||
void custom_move( int ticks ) override;
|
||||
void setType( LandType::Value type );
|
||||
LandType::Value getType() const;
|
||||
@@ -33,14 +35,33 @@ public:
|
||||
bool hasMushroom();
|
||||
void removeCoin();
|
||||
void removeMushroom();
|
||||
void addMushroom();
|
||||
void setCoinCount( int coins );
|
||||
void setDestructible( bool destructible = true );
|
||||
void ensureCollision();
|
||||
bool isBouncing();
|
||||
bool isBouncing() const;
|
||||
bool isTraveling() const;
|
||||
void setBaseRect(SDL_Rect rect);
|
||||
|
||||
protected:
|
||||
double bounce_speed = 0.5;
|
||||
int bounce_ticks = 100;
|
||||
double travel_speed = bounce_speed;
|
||||
void gravity(int ticks);
|
||||
void setOnGround(bool on_ground = true) {
|
||||
_on_ground = on_ground;
|
||||
if(on_ground) {
|
||||
setMovement(getMovement().getX(), 0);
|
||||
}
|
||||
}
|
||||
bool isOnGround() const {
|
||||
return _on_ground;
|
||||
}
|
||||
void setGravityTicks(int ticks) {
|
||||
_base_gravity_ticks = ticks;
|
||||
}
|
||||
|
||||
virtual void setWorldTypeSrc( LandType::Value world );
|
||||
|
||||
private:
|
||||
bool _tool = false;
|
||||
@@ -48,6 +69,7 @@ private:
|
||||
bool _destructible = false;
|
||||
bool _can_be_destroyed = false;
|
||||
bool _bouncing = false;
|
||||
bool _traveling = false;
|
||||
int _coins = 0;
|
||||
bool _mushroom = false;
|
||||
bool _release_coin = false;
|
||||
@@ -55,8 +77,12 @@ private:
|
||||
SDLPP::Vec2D< double > og_pos = {};
|
||||
LandType::Value _type;
|
||||
SDL_Rect _base_src;
|
||||
SDLPP::Vec2D<double> _target = {0,0};
|
||||
|
||||
virtual void setWorldTypeSrc( LandType::Value world );
|
||||
bool _on_ground = true;
|
||||
int _base_gravity_ticks = 1000 / 60;
|
||||
int _ticks_till_gravity = 0;
|
||||
double _gravity_acceleration = 1.0/(64.0/7.0);
|
||||
};
|
||||
|
||||
extern const std::vector< uint64_t > possibleBlocks;
|
||||
|
||||
Reference in New Issue
Block a user