game/mario/blocks.hpp
2021-05-25 22:05:50 +02:00

69 lines
2.4 KiB
C++

#ifndef BLOCKS_H
#define BLOCKS_H
#include "../sdlpp/sdlpp_rectrenderer.hpp"
#include <memory>
class MarioBlock : public SDLPP::RectangleRender {
public:
MarioBlock( int x, int y, std::shared_ptr< SDLPP::Renderer > renderer,
std::shared_ptr< SDLPP::Texture > texture, SDL_Rect src, bool destructible = false );
void visit( SDLPP::Visitor &visitor ) override;
void setTool( bool tool = true );
void setTerrain( bool terrain = true );
void bounce();
virtual void custom_move(int ticks) override;
private:
bool _tool = false;
bool _terrain = true;
bool _destructible = false;
bool _bouncing = false;
const int bounce_ticks = 100;
int ticks_to_bounce = bounce_ticks;
SDLPP::Vec2D<double> og_pos = {};
};
extern const std::vector< uint64_t > possibleBlocks;
struct LandType {
enum Value { OVERWORLD = 0, UNDERWORLD = 1, WATER = 2, BOWSER = 4 };
};
struct BlockRole {
enum Value {
TERRAIN,
MODIFIER,
CHARACTER,
MARIO,
};
};
std::shared_ptr< SDLPP::RectangleRender >
createTerrainBlock( uint64_t block_id, LandType::Value type,
std::shared_ptr< SDLPP::Renderer > &renderer,
bool collision = false, bool destructible = false );
std::shared_ptr< SDLPP::RectangleRender >
createTerrainBlock( uint64_t block_id, LandType::Value type,
std::shared_ptr< SDLPP::Renderer > &renderer, int x, int y,
bool collision = false, bool destructible = false );
std::shared_ptr< SDLPP::RectangleRender >
createTerrainBlock( uint64_t block_id, LandType::Value type,
std::shared_ptr< SDLPP::Renderer > &renderer,
std::shared_ptr< SDLPP::Texture > texture,
bool collision = false, bool destructible = false );
std::shared_ptr< SDLPP::RectangleRender >
createTerrainBlock( uint64_t block_id, LandType::Value type,
std::shared_ptr< SDLPP::Renderer > &renderer, int x, int y,
std::shared_ptr< SDLPP::Texture > texture,
bool collision = false, bool destructible = false );
std::shared_ptr< SDLPP::RectangleRender >
createMario( LandType::Value type, std::shared_ptr< SDLPP::Renderer > &renderer,
int x, int y );
SDL_Rect getSourceRectByID( uint64_t id, LandType::Value type );
enum BlockRole::Value getBlockRole( uint64_t id );
#endif