mirror of
https://github.com/dankamongmen/notcurses.git
synced 2024-11-02 09:40:15 +00:00
tetris: increase gravity with level #421
This commit is contained in:
parent
4a02d7ed80
commit
5bcd643a68
@ -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();
|
||||
}
|
||||
|
@ -17,9 +17,9 @@ bool MoveDown() {
|
||||
curpiece_ = NewPiece();
|
||||
}else{
|
||||
++y;
|
||||
if(!nc_.render()){
|
||||
throw TetrisNotcursesErr("render()");
|
||||
}
|
||||
}
|
||||
if(!nc_.render()){
|
||||
throw TetrisNotcursesErr("render()");
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
Loading…
Reference in New Issue
Block a user