TETRIS: separate into multiple files, add options
This commit is contained in:
@@ -432,14 +432,14 @@ protected:
|
||||
std::shared_ptr< Texture > texture;
|
||||
std::shared_ptr< Renderer > renderer;
|
||||
std::shared_ptr< CollisionPolygon > polygon;
|
||||
double movementSpeed;
|
||||
std::pair< int, int > movementDirection;
|
||||
double movementSpeed = 0;
|
||||
std::pair< int, int > movementDirection = {0,0};
|
||||
std::vector< std::shared_ptr< RenderObject > > colidedWith;
|
||||
uint64_t id;
|
||||
uint64_t id = -1;
|
||||
bool hidden = false;
|
||||
bool kill = false;
|
||||
std::tuple< int, int, int, int > colider_color = { 0x00, 0xFF, 0xFF, 0xFF };
|
||||
uint64_t scene_id;
|
||||
uint64_t scene_id = -1;
|
||||
bool permanent = false;
|
||||
bool is_static = true;
|
||||
|
||||
@@ -517,6 +517,15 @@ public:
|
||||
std::vector< std::shared_ptr< RenderObject > > getObjects() {
|
||||
return render_objects;
|
||||
}
|
||||
std::vector< std::shared_ptr< RenderObject > > getObjects(const std::unordered_set< int > &objectIDs) {
|
||||
std::vector< std::shared_ptr< RenderObject > > ret{};
|
||||
for ( const auto &x : render_objects ) {
|
||||
if ( objectIDs.find( x->getId() ) != objectIDs.end() ) {
|
||||
ret.push_back( x );
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
void movement() {
|
||||
checkKilled();
|
||||
render_mutex.lock();
|
||||
@@ -980,7 +989,6 @@ public:
|
||||
pixel_x2 = std::round(x2_ * dimension);
|
||||
pixel_y1 = std::round(y1_ * dimension);
|
||||
pixel_y2 = std::round(y2_ * dimension);
|
||||
std::cout << "x1: " << pixel_x1 << ", y1: " << pixel_y1 << ", x2: " << pixel_x2 << ", y2: " << pixel_y2 << std::endl;
|
||||
for ( auto &x : collisions ) {
|
||||
x->updateCollision( collisionPushX(), collisionPushY(),
|
||||
collisionWidth(), collisionHeight() );
|
||||
@@ -1245,9 +1253,21 @@ public:
|
||||
const std::string &color = "FFFFFF",
|
||||
const std::string &outline_color = "000000",
|
||||
int outline_size = -1 ) {
|
||||
setTexture( font, text, color, outline_color, outline_size );
|
||||
_text = text;
|
||||
setTextColor(font, color, outline_color, outline_size);
|
||||
}
|
||||
void setTextColor( Font &font, const std::string &color = "FFFFFF",
|
||||
const std::string &outline_color = "000000",
|
||||
int outline_size = -1) {
|
||||
std::cout << "TEXT: " << _text << ", COLOR: " << color << ", OUTLINE_COLOR: " << outline_color << ", OUTLINE_SIZE: " << outline_size << std::endl;
|
||||
setTexture( font, _text, color, outline_color, outline_size );
|
||||
updateDstRect();
|
||||
}
|
||||
void changeText( const std::string &text ) {
|
||||
std::cout << _text << std::endl;
|
||||
_text = text;
|
||||
std::cout << _text << std::endl;
|
||||
}
|
||||
void setFlags( int flags ) {
|
||||
position_flags = flags;
|
||||
updateDstRect();
|
||||
@@ -1315,6 +1335,7 @@ private:
|
||||
dst_rect.y = rect.y + rect.h - dst_rect.h;
|
||||
}
|
||||
}
|
||||
std::string _text{};
|
||||
int position_flags = 0;
|
||||
SDL_Rect dst_rect{};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user