mirror of
https://github.com/dankamongmen/notcurses.git
synced 2024-11-02 09:40:15 +00:00
Tetris: always move in chunks of two columns #421
This commit is contained in:
parent
642741f2c9
commit
b7c9746cf0
@ -20,16 +20,19 @@ void MoveLeft() {
|
||||
}
|
||||
if(lx < curpiece_->get_dim_x()){ // otherwise, nothing on this row
|
||||
ncpp::Cell b;
|
||||
int cmpy = ly, cmpx = lx - 1;
|
||||
curpiece_->translate(*board_, &cmpy, &cmpx);
|
||||
if(board_->get_at(cmpy, cmpx, &b)){
|
||||
if(b.get().gcluster && b.get().gcluster != ' '){
|
||||
return; // move is blocked
|
||||
for(int xdelt = 1 ; xdelt < 3 ; ++xdelt){
|
||||
int cmpy = ly, cmpx = lx - xdelt;
|
||||
curpiece_->translate(*board_, &cmpy, &cmpx);
|
||||
if(board_->get_at(cmpy, cmpx, &b)){
|
||||
// FIXME deal with e.g. lower half sliding under upper half
|
||||
if(b.get().gcluster && b.get().gcluster != ' '){
|
||||
return; // move is blocked
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
--x;
|
||||
x -= 2;
|
||||
if(!curpiece_->move(y, x) || !nc_.render()){ // FIXME needs y?
|
||||
throw TetrisNotcursesErr("move() or render()");
|
||||
}
|
||||
|
@ -20,16 +20,18 @@ void MoveRight() {
|
||||
}
|
||||
if(lx >= 0){ // otherwise, nothing on this row
|
||||
ncpp::Cell b;
|
||||
int cmpy = ly, cmpx = lx + 1;
|
||||
curpiece_->translate(*board_, &cmpy, &cmpx);
|
||||
if(board_->get_at(cmpy, cmpx, &b)){
|
||||
if(b.get().gcluster && b.get().gcluster != ' '){
|
||||
return; // move is blocked
|
||||
for(int xdelt = 1 ; xdelt < 3 ; ++xdelt){
|
||||
int cmpy = ly, cmpx = lx + xdelt;
|
||||
curpiece_->translate(*board_, &cmpy, &cmpx);
|
||||
if(board_->get_at(cmpy, cmpx, &b)){
|
||||
if(b.get().gcluster && b.get().gcluster != ' '){
|
||||
return; // move is blocked
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
++x;
|
||||
x += 2;
|
||||
if(!curpiece_->move(y, x) || !nc_.render()){ // FIXME needs y?
|
||||
throw TetrisNotcursesErr("move() or render()");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user