나는 OpenGL에서 Pacman 게임을 만들고 있고, 매트릭스로 표현 된 게임에서 팩맨을 움직이기를 원한다.어떻게 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
}
Pacman 그것은 지워지지 않았다. 다음에해야 할 일이 무엇인지 말해 줄 수 있습니까?
왜 팩맨을 옮길 때 팩맨을 삭제하는지 이해가 안됩니다. 반드시 같은 Pacman 객체에서 pacman-> setPacX() 및 pacman-> setPacY() 만 사용해야합니까? – Robinson
번역 할 수 없기 때문에 나는 그것을 삭제하려고했습니다 ... 번역 할 때 그는 간단하게 다른 팩맨을 만듭니다 ... – gn66