TETRIS作成について
Posted: 2016年12月03日(土) 22:59
ホームページ(http://itouhiro.hatenablog.com/entry/20121119/tetris)を参考にしながらテトリスを作成しています。色々考えているのですが当たり判別のところをどのようなプロセスでやるのか思いつきません。助言をいただけると嬉しいです。
ブロックの置き方として、このようにおいています。 PutBlock関数としてこのような感じでvoid型で作成してみました。
ブロックの置き方として、このようにおいています。 PutBlock関数としてこのような感じでvoid型で作成してみました。
void PutBlock(Status s){
if (board[s.y][s.x] == 0){
for (int i = 0; i < 3; i++){
int dx = block[s.type].p[i].x;
int dy = block[s.type].p[i].y;
int r = s.rotate % block[s.type].rotate;
//回転時の変換
for (int j = 0; j < r; j++){
int nx = dx, ny = dy;
dx = ny; dy = -nx;
}
//当たり判定
if (board[s.y + dy][s.x + dx] != 0){
}
board[s.y][s.x] = s.type;
board[s.y + dy][s.x + dx] = s.type;
}
}
}