Tetris: gradient stain on fixed pieces #421

This commit is contained in:
nick black 2020-03-25 22:27:23 -04:00
parent 5864b37d0a
commit d491d532bb
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC
2 changed files with 24 additions and 2 deletions

View File

@ -12,6 +12,7 @@ void DrawBackground(const std::string& s) {
if(backg_->render(0, 0, -1, -1) <= 0){ if(backg_->render(0, 0, -1, -1) <= 0){
throw TetrisNotcursesErr("render(): " + s); throw TetrisNotcursesErr("render(): " + s);
} }
backg_->get_plane()->greyscale();
} }
// draw the background on the standard plane, then create a new plane for the play area. // draw the background on the standard plane, then create a new plane for the play area.

View File

@ -8,13 +8,34 @@ bool MoveDown() {
return true; return true;
} }
curpiece_->mergedown(*board_); curpiece_->mergedown(*board_);
if(!board_->cursor_move(0, 1)){
throw TetrisNotcursesErr("cursor_move()");
}
int bdimy, bdimx;
board_->get_dim(&bdimy, &bdimx);
uint64_t tl, tr, bl, br;
tl = tr = bl = br = 0;
channels_set_bg_alpha(&tl, CELL_ALPHA_TRANSPARENT);
channels_set_bg_alpha(&tr, CELL_ALPHA_TRANSPARENT);
channels_set_bg_alpha(&bl, CELL_ALPHA_TRANSPARENT);
channels_set_bg_alpha(&br, CELL_ALPHA_TRANSPARENT);
channels_set_fg(&tl, 0xff0000);
channels_set_fg(&tr, 0x00ff00);
channels_set_fg(&bl, 0x0000ff);
channels_set_fg(&br, 0x00ffff);
if(!board_->stain(bdimy - 2, bdimx - 2, tl, tr, bl, br)){
throw TetrisNotcursesErr("stain()");
}
curpiece_ = NewPiece(); curpiece_ = NewPiece();
}else{ }else{
++y; ++y;
if(!curpiece_->move(y, x) || !nc_.render()){ if(!curpiece_->move(y, x)){
throw TetrisNotcursesErr("move() or render()"); throw TetrisNotcursesErr("move()");
} }
} }
if(!nc_.render()){
throw TetrisNotcursesErr("render()");
}
} }
return false; return false;
} }