Untitled
unknown
c_cpp
4 months ago
1.0 kB
5
Indexable
bool Grid::AddObjectToCell(GameObject * pNewObject) // think if any validation is needed { // Get the cell position of pNewObject CellPosition pos = pNewObject->GetPosition(); if (pos.IsValidCell()) // Check if valid position { // Get the previous GameObject of the Cell GameObject * pPrevObject = CellList[pos.VCell()][pos.HCell()]->GetGameObject(); if( pPrevObject) // the cell already contains a game object return false; // do NOT add and return false // Set the game object of the Cell with the new game object CellList[pos.VCell()][pos.HCell()]->SetGameObject(pNewObject); return true; // indicating that addition is done } return false; // if not a valid position } bool Grid::IsCellEmpty(const CellPosition& pos) const { GameObject* pObject = CellList[pos.VCell()][pos.HCell()]->GetGameObject(); //pObject should store the object if there is (copied it from the syntax/idea function above) return (pObject == nullptr); // Return true if the cell contains no object }
Editor is loading...
Leave a Comment