void GameManager::Render(Gdiplus::Graphics& canvas, const CRect& clientRect) { // Save the current transformation of the scene Gdiplus::Matrix transform; canvas.GetTransform(&transform); // tell all of the game objects to render for (GameObject* gameObjectPtr : Everything) { gameObjectPtr->Render(canvas, clientRect); gameObjectPtr->Render(canvas, clientRect); gameObjectPtr->Render(canvas, clientRect); gameObjectPtr->Render(canvas, clientRect); } // Restore the transformation of the scene canvas.SetTransform(&transform); }
void GameManager::Render(Gdiplus::Graphics& canvas, const CRect& clientRect) { //////////////////////////////////////////////////////////////////////////////// // Begin example code // Save the current transformation of the scene Gdiplus::Matrix transform; canvas.GetTransform(&transform); // Offset by the negative of the player direction canvas.TranslateTransform(-(Gdiplus::REAL)playerPtr->location.X, -(Gdiplus::REAL)playerPtr->location.Y); int numRows = clientRect.Height() / CellSize; int numCols = clientRect.Width() / CellSize; // draw horizontal lines for grid for (int row = 0; row < numRows; ++row) { Vector2i start = Vector2i(0, row * CellSize); Vector2i end = Vector2i(clientRect.Width(), row * CellSize); GameFrameworkInstance.DrawLine(canvas, start, end, Gdiplus::Color::White); } // draw vertical lines for grid for (int col = 0; col < numCols; ++col) { Vector2i start = Vector2i(col * CellSize, 0); Vector2i end = Vector2i(col * CellSize, clientRect.Height()); GameFrameworkInstance.DrawLine(canvas, start, end, Gdiplus::Color::White); } // Draw all of the objects for (GameObject* objectPtr : gameObjects) { objectPtr->Render(canvas); } // Render method demonstration (You can remove all of this code) GameFrameworkInstance.DrawLine(canvas, Vector2i(200, 200), Vector2i(400, 200), Gdiplus::Color::White); GameFrameworkInstance.DrawRectangle(canvas, AABBi(Vector2i(10, 110), Vector2i(100, 200)), false, Gdiplus::Color::White); GameFrameworkInstance.DrawRectangle(canvas, AABBi(Vector2i(200, 110), Vector2i(300, 200)), true, Gdiplus::Color::White); //// restore the transform //canvas.SetTransform(&transform); GameFrameworkInstance.DrawCircle(canvas, Vector2i(200, 200), 50, false, Gdiplus::Color::White); GameFrameworkInstance.DrawCircle(canvas, Vector2i(400, 200), 50, true, Gdiplus::Color::White); GameFrameworkInstance.DrawText(canvas, Vector2i(10, 300), 12, "Arial", "Hello World!", Gdiplus::Color::White); // Load the image file Untitled.png from the Images folder. Give it the unique name of Image1 ImageWrapper* image1 = GameFrameworkInstance.GetLoadedImage(Image1); GameFrameworkInstance.DrawImage(canvas, Vector2i(400, 400), image1); // Restore the transformation of the scene canvas.SetTransform(&transform); // End example code //////////////////////////////////////////////////////////////////////////////// // Build Menu Vector2i dimensions = GameManagerInstance.GetScreenDimensions(); Vector2i centrePoint = dimensions * 0.1f; GameFrameworkInstance.DrawRectangle(canvas, AABBi(Vector2i(0, 0) + centrePoint, Vector2i(150, 500) + centrePoint), true, Gdiplus::Color::Gray); GameFrameworkInstance.DrawText(canvas, Vector2i(10, 10) + centrePoint, 12, "Arial", "[1] Wall", Gdiplus::Color::White); GameFrameworkInstance.DrawText(canvas, Vector2i(10, 35) + centrePoint, 12, "Arial", "[2] Damage Zone", Gdiplus::Color::White); GameFrameworkInstance.DrawText(canvas, Vector2i(10, 60) + centrePoint, 12, "Arial", "[3] Healing Zone", Gdiplus::Color::White); }