TETRIS: lines
This commit is contained in:
+35
-15
@@ -483,19 +483,51 @@ void addStuff( SDLPP::Scene &scene, std::shared_ptr< SDLPP::Renderer > &r ) {
|
||||
"#222222", true );
|
||||
bg->setPermanent();
|
||||
scene.addObject( bg );
|
||||
|
||||
double posy = 1;
|
||||
for ( int i = 0; i < 20; i++ ) {
|
||||
posy -= BLOCK_SIZE;
|
||||
auto colider = std::make_shared< SDLPP::RectangleRender >(
|
||||
LEFT_BORDER, posy, RIGHT_BORDER - LEFT_BORDER, BLOCK_SIZE, r );
|
||||
colider->addCollision(SDLPP::Rect( 0.01, 0.1, 0.98, 0.8 ));
|
||||
colider->setId( COLIDER_ID );
|
||||
colider->setStatic();
|
||||
colider->centerX();
|
||||
line_coliders.push_back( colider );
|
||||
scene.addObject( colider );
|
||||
}
|
||||
|
||||
posy = 1;
|
||||
for ( int i = 0; i < 20; i++ ) {
|
||||
posy -= BLOCK_SIZE;
|
||||
auto line = std::make_shared< SDLPP::LineRenderer >( LEFT_BORDER, posy, RIGHT_BORDER, posy, r, "#AAAAAA" );
|
||||
line->setStatic();
|
||||
line->centerX();
|
||||
scene.addObject( line );
|
||||
}
|
||||
|
||||
auto posx = RIGHT_BORDER;
|
||||
for ( int i = 0; i < 9; i++ ) {
|
||||
posx -= BLOCK_SIZE;
|
||||
auto line = std::make_shared< SDLPP::LineRenderer >( posx, TOP_BORDER + BLOCK_SIZE, posx, BOTTOM_BORDER, r, "#AAAAAA" );
|
||||
line->setStatic();
|
||||
line->centerX();
|
||||
scene.addObject( line );
|
||||
}
|
||||
|
||||
auto left_barrier = std::make_shared< SDLPP::RectangleRender >(
|
||||
LEFT_BORDER - 0.02, 0, 0.02, BOTTOM_BORDER, r, "#FF000080", true );
|
||||
LEFT_BORDER - 0.02, 0, 0.02, BOTTOM_BORDER, r, "#AA0000", true );
|
||||
left_barrier->centerX();
|
||||
left_barrier->setStatic();
|
||||
scene.addObject( left_barrier );
|
||||
auto right_barrier = std::make_shared< SDLPP::RectangleRender >(
|
||||
RIGHT_BORDER, 0, 0.02, BOTTOM_BORDER, r, "#FF000080", true );
|
||||
RIGHT_BORDER, 0, 0.02, BOTTOM_BORDER, r, "#AA0000", true );
|
||||
right_barrier->centerX();
|
||||
right_barrier->setStatic();
|
||||
scene.addObject( right_barrier );
|
||||
auto bottom_barrier = std::make_shared< SDLPP::RectangleRender >(
|
||||
LEFT_BORDER - 0.02, BOTTOM_BORDER, RIGHT_BORDER - LEFT_BORDER + 0.04,
|
||||
0.02, r, "#FF000080", true );
|
||||
0.02, r, "#AA0000", true );
|
||||
bottom_barrier->centerX();
|
||||
bottom_barrier->setStatic();
|
||||
scene.addObject( bottom_barrier );
|
||||
@@ -510,7 +542,6 @@ void addStuff( SDLPP::Scene &scene, std::shared_ptr< SDLPP::Renderer > &r ) {
|
||||
next->centerX();
|
||||
next->setStatic();
|
||||
scene.addObject( next );
|
||||
double posy = 1;
|
||||
auto gameover = std::make_shared< SDLPP::RectangleRender >(
|
||||
0.5, 0, 0, TOP_BORDER + BLOCK_SIZE, r );
|
||||
auto gameover_collision = SDLPP::Rect( -1, 0, -1, 0.9 );
|
||||
@@ -533,17 +564,6 @@ void addStuff( SDLPP::Scene &scene, std::shared_ptr< SDLPP::Renderer > &r ) {
|
||||
score_texture->centerX();
|
||||
score_texture->setStatic();
|
||||
scene.addObject( score_texture );
|
||||
for ( int i = 0; i < 20; i++ ) {
|
||||
posy -= BLOCK_SIZE;
|
||||
auto colider = std::make_shared< SDLPP::RectangleRender >(
|
||||
LEFT_BORDER, posy, RIGHT_BORDER - LEFT_BORDER, BLOCK_SIZE, r );
|
||||
colider->addCollision(SDLPP::Rect( 0.01, 0.1, 0.98, 0.8 ));
|
||||
colider->setId( COLIDER_ID );
|
||||
colider->setStatic();
|
||||
colider->centerX();
|
||||
line_coliders.push_back( colider );
|
||||
scene.addObject( colider );
|
||||
}
|
||||
|
||||
auto shcol = std::make_shared< SDLPP::RectangleRender >( 0, TOP_BORDER, BLOCK_SIZE, BOTTOM_BORDER - TOP_BORDER, r );
|
||||
shcol->addCollision(SDLPP::Rect( 0.1, 0.01, 0.8, 0.98 ));
|
||||
|
||||
Reference in New Issue
Block a user