void Player::Update() { Sphere::Update(); Map* map = (Map*)GetParent(); if (map) { int x,y; if (DOWN) { x = round(GetCenterX() / GetWidth()); y = (round((map->GetScreenHeight() - GetCenterY()) / GetWidth())) + 1; if ((x == 9) && (y == 8)) { } else { if (!map->IsBoundary(x, y) || !map->GetBoundary(x, y)->Contains(this)) { Score += map->CheckPlayerEatPellet(); m_transformation[1][3] -= MoveSpeed; LastMove = 2; } } } if (UP) { x = round(GetCenterX() / GetWidth()); y = round((map->GetScreenHeight() - GetCenterY()) / GetWidth()) - 1; if (!map->IsBoundary(x, y) || !map->GetBoundary(x, y)->Contains(this)) { Score += map->CheckPlayerEatPellet(); m_transformation[1][3] += MoveSpeed; LastMove = 0; } } if (LEFT) { x = round(GetCenterX() / GetWidth()) - 1; y = round((map->GetScreenHeight() - GetCenterY()) / GetWidth()); if (!map->IsBoundary(x, y) || !map->GetBoundary(x, y)->Contains(this)) { Score += map->CheckPlayerEatPellet(); m_transformation[0][3] -= MoveSpeed; LastMove = 3; if (m_transformation[0][3] <=0) { m_transformation[0][3] = map->GetWidth(); LastMove = 1; } } } if (RIGHT) { x = round(GetCenterX() / GetWidth()) + 1; y = round((map->GetScreenHeight() - GetCenterY()) / GetWidth()); if (!map->IsBoundary(x, y) || !map->GetBoundary(x, y)->Contains(this)) { Score += map->CheckPlayerEatPellet(); m_transformation[0][3] += MoveSpeed; LastMove = 2; if (m_transformation[0][3] > map->GetWidth() - GetRadius()) { m_transformation[0][3] = 0; LastMove = 3; } } } } }