Trying to switch to more object-oriented

This commit is contained in:
2021-03-12 22:33:46 +01:00
parent fbe122a5b9
commit 258ce51cfe
32 changed files with 693 additions and 249 deletions
+6 -6
View File
@@ -27,19 +27,19 @@ void updateShadow( SDLPP::Scene &scene ) {
auto &invalid_objects = g_cur_object->getObjects();
for ( auto &x : g_cur_shadow->getObjects() ) {
auto block_pos = x->getPos();
if ( BOTTOM_BORDER - block_pos.second < shadow_drop )
shadow_drop = BOTTOM_BORDER - block_pos.second;
if ( BOTTOM_BORDER - block_pos.getY() < shadow_drop )
shadow_drop = BOTTOM_BORDER - block_pos.getY();
// set colider column's position to current block's X position
g_shadow_colider->setPos( block_pos.first, TOP_BORDER );
g_shadow_colider->setPos( block_pos.getX(), TOP_BORDER );
auto collisions =
scene.getCollisions( *g_shadow_colider, { BRICK_ID } );
auto curY = block_pos.second;
auto curY = block_pos.getY();
for ( auto &col : collisions ) {
// if collision with g_cur_object, ignore
if ( std::find( invalid_objects.begin(), invalid_objects.end(),
col ) != invalid_objects.end() )
continue;
auto possible_drop = col->getPos().second - curY;
auto possible_drop = col->getPos().getY() - curY;
if ( possible_drop < shadow_drop && possible_drop >= 0 )
shadow_drop = possible_drop;
}
@@ -47,7 +47,7 @@ void updateShadow( SDLPP::Scene &scene ) {
// we want the shadow to rest on top of the nearest floor
shadow_drop -= BLOCK_SIZE;
auto shadow_pos = g_cur_shadow->getPos();
g_cur_shadow->setPos( shadow_pos.first, shadow_pos.second + shadow_drop );
g_cur_shadow->setPos( shadow_pos.getX(), shadow_pos.getY() + shadow_drop );
}
void moveThem( std::shared_ptr< SDLPP::Scene > scene, int ticks ) {