91 lines
2.7 KiB
C++
91 lines
2.7 KiB
C++
#ifndef BLOCKS_H
|
|
#define BLOCKS_H
|
|
|
|
#include "../sdlpp/sdlpp_rectrenderer.hpp"
|
|
#include <memory>
|
|
|
|
struct LandType {
|
|
enum Value { OVERWORLD = 0, UNDERWORLD = 1, WATER = 2, BOWSER = 4 };
|
|
};
|
|
|
|
class MarioBlock : public SDLPP::RectangleRender {
|
|
public:
|
|
MarioBlock( int x, int y,
|
|
const std::shared_ptr< SDLPP::Renderer > &renderer,
|
|
std::shared_ptr< SDLPP::Texture > texture, SDL_Rect src,
|
|
bool can_be_destroyed = false, bool destructible = false );
|
|
void visit( SDLPP::Visitor &visitor ) override;
|
|
void setTool( bool tool = true );
|
|
void setTerrain( bool terrain = true );
|
|
void bounce();
|
|
void custom_move( int ticks ) override;
|
|
void setType( LandType::Value type );
|
|
LandType::Value getType() const;
|
|
virtual void onScrollUp() {}
|
|
virtual void onScrollDown() {}
|
|
virtual uint8_t getData() {
|
|
return 0;
|
|
}
|
|
virtual void setData( uint8_t /*UNUSED*/ ) {}
|
|
// handle own visitor
|
|
virtual void handleVisitor(SDLPP::Visitor &visitor) {}
|
|
bool hasCoin();
|
|
bool hasMushroom();
|
|
void removeCoin();
|
|
void removeMushroom();
|
|
void setCoinCount( int coins );
|
|
void setDestructible( bool destructible = true );
|
|
void ensureCollision();
|
|
bool isBouncing();
|
|
|
|
protected:
|
|
double bounce_speed = 0.5;
|
|
int bounce_ticks = 100;
|
|
|
|
private:
|
|
bool _tool = false;
|
|
bool _terrain = true;
|
|
bool _destructible = false;
|
|
bool _can_be_destroyed = false;
|
|
bool _bouncing = false;
|
|
int _coins = 0;
|
|
bool _mushroom = false;
|
|
bool _release_coin = false;
|
|
int ticks_to_bounce = 0;
|
|
SDLPP::Vec2D< double > og_pos = {};
|
|
LandType::Value _type;
|
|
SDL_Rect _base_src;
|
|
|
|
virtual void setWorldTypeSrc( LandType::Value world );
|
|
};
|
|
|
|
extern const std::vector< uint64_t > possibleBlocks;
|
|
extern const std::vector< uint64_t > possibleMods;
|
|
extern const std::vector< uint64_t > possibleCharacters;
|
|
extern const std::vector< LandType::Value > possibleLands;
|
|
|
|
struct BlockRole {
|
|
enum Value {
|
|
TERRAIN,
|
|
MODIFIER,
|
|
CHARACTER,
|
|
MARIO,
|
|
};
|
|
};
|
|
|
|
std::shared_ptr< MarioBlock >
|
|
createTerrainBlock( uint64_t block_id, LandType::Value type,
|
|
std::shared_ptr< SDLPP::Renderer > &renderer,
|
|
bool destructible = false, bool editor = false );
|
|
std::shared_ptr< MarioBlock >
|
|
createTerrainBlock( uint64_t block_id, LandType::Value type,
|
|
std::shared_ptr< SDLPP::Renderer > &renderer, int x, int y,
|
|
bool destructible = false, bool editor = false );
|
|
std::shared_ptr< MarioBlock >
|
|
createMario( LandType::Value type, std::shared_ptr< SDLPP::Renderer > &renderer,
|
|
int x, int y, bool editor = false );
|
|
|
|
enum BlockRole::Value getBlockRole( uint64_t id );
|
|
|
|
#endif
|