tetris: increase gravity with level #421

This commit is contained in:
nick black 2020-03-27 00:17:16 -04:00
parent 4a02d7ed80
commit 5bcd643a68
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC
2 changed files with 8 additions and 7 deletions

View File

@ -4,10 +4,10 @@ void StainBoard(int dimy, int dimx){
}
int high = 0xff - level_ * 16, low = level_ * 16; // rgb calculation limits us to 16 levels (0--15)
uint64_t tl = 0, tr = 0, bl = 0, br = 0;
channels_set_fg_rgb(&tl, high, 0, low); channels_set_bg_alpha(&tl, CELL_ALPHA_TRANSPARENT);
channels_set_fg_rgb(&tr, low, high, 0); channels_set_bg_alpha(&tr, CELL_ALPHA_TRANSPARENT);
channels_set_fg_rgb(&bl, 0, low, high); channels_set_bg_alpha(&bl, CELL_ALPHA_TRANSPARENT);
channels_set_fg_rgb(&br, 0, high, low); channels_set_bg_alpha(&br, CELL_ALPHA_TRANSPARENT);
channels_set_fg_rgb(&tl, high, 0xff, low); channels_set_bg_alpha(&tl, CELL_ALPHA_TRANSPARENT);
channels_set_fg_rgb(&tr, low, high, 0xff); channels_set_bg_alpha(&tr, CELL_ALPHA_TRANSPARENT);
channels_set_fg_rgb(&bl, 0xff, low, high); channels_set_bg_alpha(&bl, CELL_ALPHA_TRANSPARENT);
channels_set_fg_rgb(&br, 0xff, high, low); channels_set_bg_alpha(&br, CELL_ALPHA_TRANSPARENT);
if(!board_->stain(dimy - 2, dimx - 2, tl, tr, bl, br)){
throw TetrisNotcursesErr("stain()");
}
@ -49,6 +49,7 @@ void LockPiece(){
static constexpr int points[] = {50, 150, 350, 1000};
score_ += (level_ + 1) * points[cleared - 1];
level_ = linescleared_ / 10;
msdelay_ = std::chrono::milliseconds(Gravity(level_));
StainBoard(bdimy, bdimx);
UpdateScore();
}

View File

@ -17,9 +17,9 @@ bool MoveDown() {
curpiece_ = NewPiece();
}else{
++y;
if(!nc_.render()){
throw TetrisNotcursesErr("render()");
}
}
if(!nc_.render()){
throw TetrisNotcursesErr("render()");
}
}
return false;