Tetris: always move in chunks of two columns #421

pull/426/head
nick black 5 years ago
parent 642741f2c9
commit b7c9746cf0
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

@ -20,16 +20,19 @@ void MoveLeft() {
} }
if(lx < curpiece_->get_dim_x()){ // otherwise, nothing on this row if(lx < curpiece_->get_dim_x()){ // otherwise, nothing on this row
ncpp::Cell b; ncpp::Cell b;
int cmpy = ly, cmpx = lx - 1; for(int xdelt = 1 ; xdelt < 3 ; ++xdelt){
curpiece_->translate(*board_, &cmpy, &cmpx); int cmpy = ly, cmpx = lx - xdelt;
if(board_->get_at(cmpy, cmpx, &b)){ curpiece_->translate(*board_, &cmpy, &cmpx);
if(b.get().gcluster && b.get().gcluster != ' '){ if(board_->get_at(cmpy, cmpx, &b)){
return; // move is blocked // 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? if(!curpiece_->move(y, x) || !nc_.render()){ // FIXME needs y?
throw TetrisNotcursesErr("move() or render()"); throw TetrisNotcursesErr("move() or render()");
} }

@ -20,16 +20,18 @@ void MoveRight() {
} }
if(lx >= 0){ // otherwise, nothing on this row if(lx >= 0){ // otherwise, nothing on this row
ncpp::Cell b; ncpp::Cell b;
int cmpy = ly, cmpx = lx + 1; for(int xdelt = 1 ; xdelt < 3 ; ++xdelt){
curpiece_->translate(*board_, &cmpy, &cmpx); int cmpy = ly, cmpx = lx + xdelt;
if(board_->get_at(cmpy, cmpx, &b)){ curpiece_->translate(*board_, &cmpy, &cmpx);
if(b.get().gcluster && b.get().gcluster != ' '){ if(board_->get_at(cmpy, cmpx, &b)){
return; // move is blocked if(b.get().gcluster && b.get().gcluster != ' '){
return; // move is blocked
}
} }
} }
} }
} }
++x; x += 2;
if(!curpiece_->move(y, x) || !nc_.render()){ // FIXME needs y? if(!curpiece_->move(y, x) || !nc_.render()){ // FIXME needs y?
throw TetrisNotcursesErr("move() or render()"); throw TetrisNotcursesErr("move() or render()");
} }

Loading…
Cancel
Save