Tetris: always move in chunks of two columns #421

pull/426/head
nick black 4 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
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…
Cancel
Save