私はOpenGLでパックマンゲームを作っています。マトリックスで表されるゲームでパックマンを移動したいと思います。C++/OpenGLのオブジェクトを新しい場所に移動して古いオブジェクトを削除するには
マトリックスは16x16で、私は壁を描きたいときには4を、小さい球には3を、パックマンには2を入れます。
私のプロジェクトのメインクラスでは、キーボードからキーを読み、私はゲームを定義したクラスに情報を送ります。そのクラスでは、私はこの機能を持っています:
void boardGame::refreshPacman(int n, int m)
{
int x, y;
(* pacman).movePacman(n, m); // This is working, it send information to class Pacman. In there I store the n (x axe) and m(y axe), and i get the next coordinates where pacman should translate.
x = (* pacman).getPacX(); // get coordinate of the old pacman
y = (* pacman).getPacY(); // get coordinate of the old pacman
board[x][y] = 0; // delete old information of pacman in matrix
x += n; // set the coordinates of x axis for new pacman
y += m; // set the coordinates of y axis for new pacman
wall[x][y] = 2; // insert the information of new pacman in matrix
pac->redraw (x, y, 0.5); // construct the new pacman
}
パックマンそれはbeeingが消去されていません。私は次に何をする必要があるのか教えてください。間違っているのですか?
移動するときにパックマンを削除する理由がわかりません。もちろん、同じPacmanオブジェクト上で、pacman-> setPacX()とpacman-> setPacY()だけを使うべきでしょうか? – Robinson
私はそれを翻訳することができなかったので、私はそれを削除しようとしました...私はそれを翻訳すると、単純に別のパックマンを作成します... – gn66