Skip to content

Commit

Permalink
Final Starter; cleanup rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
cmaughan committed Oct 12, 2016
1 parent d872c0c commit 261f81d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
3 changes: 2 additions & 1 deletion Connect4.CPP/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ SET(SOURCES
DrawWindow.h
json.hpp)


# Create the library
ADD_EXECUTABLE (${PROJECT_NAME} ${SOURCES})
INCLUDE_DIRECTORIES(Socket)
TARGET_LINK_LIBRARIES(
${PROJECT_NAME}
)

SOURCE_GROUP ("App" FILES ${SOURCES})
SOURCE_GROUP ("Connect4" FILES ${SOURCES})
16 changes: 12 additions & 4 deletions Connect4.CPP/DrawWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,15 @@ void SetGame(const Api::Game& game)
VOID OnPaint(HDC hdc)
{
std::lock_guard<std::mutex> lock(viewMutex);
Bitmap *pMemBitmap = new Bitmap(WinSize, WinSize + TextAreaSize);

Bitmap *pMemBitmap = new Bitmap(WinSize, WinSize + TextAreaSize, PixelFormat24bppRGB);

Graphics* pMemGraphics = Graphics::FromImage(pMemBitmap);

pMemGraphics->SetInterpolationMode(InterpolationMode::InterpolationModeHighQuality);
pMemGraphics->SetInterpolationMode(InterpolationMode::InterpolationModeHighQualityBicubic);
pMemGraphics->SetSmoothingMode(SmoothingMode::SmoothingModeAntiAlias);

Graphics graphics(hdc);
graphics.SetInterpolationMode(InterpolationMode::InterpolationModeHighQuality);

Font font(&FontFamily(L"Arial"), 12);
pMemGraphics->Clear(Color::Black);
Expand All @@ -46,6 +49,8 @@ VOID OnPaint(HDC hdc)
SolidBrush redBrush(Color::Red);
SolidBrush yellowBrush(Color::Yellow);
SolidBrush whiteBrush(Color::White);
Pen blueLightBrush(Color::CornflowerBlue);
blueLightBrush.SetWidth(4);

pMemGraphics->FillRectangle(&blueBrush, BoardOrigin, BoardOrigin, BoardWidth, BoardHeight);
for (int row = Api::Game::NUMBER_OF_ROWS - 1; row >= 0; row--)
Expand All @@ -60,12 +65,15 @@ VOID OnPaint(HDC hdc)
{
case Api::CellContent::Empty:
pMemGraphics->FillEllipse(&whiteBrush, circleX, circleY, circleSize, circleSize);
pMemGraphics->DrawEllipse(&blueLightBrush, circleX, circleY, circleSize, circleSize);
break;
case Api::CellContent::Red:
pMemGraphics->FillEllipse(&redBrush, circleX, circleY, circleSize, circleSize);
pMemGraphics->DrawEllipse(&blueLightBrush, circleX, circleY, circleSize, circleSize);
break;
case Api::CellContent::Yellow:
pMemGraphics->FillEllipse(&yellowBrush, circleX, circleY, circleSize, circleSize);
pMemGraphics->DrawEllipse(&blueLightBrush, circleX, circleY, circleSize, circleSize);
break;
}
}
Expand All @@ -74,7 +82,7 @@ VOID OnPaint(HDC hdc)
bool finished;
auto statusText = Api::GetStatusString(gameView, finished);
pMemGraphics->DrawString(std::wstring(statusText.begin(), statusText.end()).c_str(), statusText.length(), &font, PointF(REAL(BoardOrigin), REAL(BoardOrigin + BoardHeight)), &whiteBrush);
graphics.DrawImage(pMemBitmap, Rect(0, 0, WinSize, WinSize + TextAreaSize));
graphics.DrawImage(pMemBitmap, 0, 0);
delete pMemBitmap;
delete pMemGraphics;

Expand Down

0 comments on commit 261f81d

Please sign in to comment.