资源简介
Direct2D 五子棋Direct2D 五子棋Direct2D 五子棋Direct2D 五子棋Direct2D 五子棋Direct2D 五子棋Direct2D 五子棋 Direct2D 五子棋

代码片段和文件信息
#include “Five.h“
#include
// Recalculate drawing layout when the size of the window changes
void MainWindow::CalculateLayout()
{
if (pRenderTarget != NULL)
{
D2D1_SIZE_F size = pRenderTarget->GetSize();
m_CentreX = size.width / 2;
m_CentreY = size.height / 2;
m_GridLen = min(size.width size.height) / 16;
m_topX = size.width / 2 - 7 * m_GridLen;
m_topY = size.height / 2 - 7 * m_GridLen;
}
}
HRESULT MainWindow::CreateGraphicsResources()
{
HRESULT hr = S_OK;
if (pRenderTarget == NULL)
{
RECT rc;
GetClientRect(m_hwnd &rc);
D2D1_SIZE_U size = D2D1::SizeU(rc.right rc.bottom);
hr = pFactory->CreateHwndRenderTarget(
D2D1::RenderTargetProperties()
D2D1::HwndRenderTargetProperties(m_hwnd size)
&pRenderTarget);
if (SUCCEEDED(hr))
{
hr = pRenderTarget->CreateSolidColorBrush(D2D1::ColorF(D2D1::ColorF::White) &pBrush);
if (SUCCEEDED(hr))
{
CalculateLayout();
}
}
}
return hr;
}
void MainWindow::CreateFiveChessGrid()
{
//set background color
pRenderTarget->Clear(D2D1::ColorF(0.96f 0.79f 0.39f 1.0f));
pBrush->SetColor(D2D1::ColorF(D2D1::ColorF::Black));
float left = m_topX;
float top = m_topY;
float bottom = m_CentreY + 7 * m_GridLen;
float right = m_CentreX + 7 * m_GridLen;
//draw vert lines
for (float i = 0; i < 14 * m_GridLen + 1; i += m_GridLen)
{
pRenderTarget->DrawLine(D2D1::Point2F(left + i top) D2D1::Point2F(left + i bottom) pBrush);
}
//draw horiz lines
for (float i = 0; i < 14 * m_GridLen + 1; i += m_GridLen)
{
pRenderTarget->DrawLine(D2D1::Point2F(left top + i) D2D1::Point2F(right top + i) pBrush);
}
//draw special points
pRenderTarget->FillEllipse(D2D1::Ellipse(
D2D1::Point2F(m_CentreX m_CentreY) m_GridLen / 6 m_GridLen / 6) pBrush);
pRenderTarget->FillEllipse(D2D1::Ellipse(
D2D1::Point2F(m_CentreX - 4 * m_GridLen m_CentreY - 4 * m_GridLen) m_GridLen / 6 m_GridLen / 6) pBrush);
pRenderTarget->FillEllipse(D2D1::Ellipse(
D2D1::Point2F(m_CentreX + 4 * m_GridLen m_CentreY + 4 * m_GridLen) m_GridLen / 6 m_GridLen / 6) pBrush);
pRenderTarget->FillEllipse(D2D1::Ellipse(
D2D1::Point2F(m_CentreX + 4 * m_GridLen m_CentreY - 4 * m_GridLen) m_GridLen / 6 m_GridLen / 6) pBrush);
pRenderTarget->FillEllipse(D2D1::Ellipse(
D2D1::Point2F(m_CentreX - 4 * m_GridLen m_CentreY + 4 * m_GridLen) m_GridLen / 6 m_GridLen / 6) pBrush);
}
void MainWindow::RenderChess()
{
float left = m_CentreX - 7 * m_GridLen;
float top = m_CentreY - 7 * m_GridLen;
for (int i = 0; i < 15; ++i)
{
for (int j = 0; j < 15; ++j)
{
if (m_chess[i][j] == 0)
{
continue;
}
if (m_chess[i][j] == 1)
{
pBrush->SetColor(D2D1::ColorF(D2D1::ColorF::Black));
}
else
{
pBrush->SetColor(D2D1::ColorF(D2D1::ColorF::White));
}
pRenderTarget->FillEllipse(D2D1::Ellipse(
D2D1::Point2F(left + i*m_GridLen top + j*m_GridLen)
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2017-08-18 13:08 FiveChessD2D\
文件 1520 2017-07-31 18:33 FiveChessD2D\ba
目录 0 2017-08-18 13:08 FiveChessD2D\Debug\
文件 7795 2017-08-02 23:19 FiveChessD2D\Five.cpp
文件 1221 2017-07-30 23:49 FiveChessD2D\Five.h
文件 7152 2017-07-30 10:48 FiveChessD2D\FiveChessD2D.vcxproj
文件 1168 2017-07-30 10:48 FiveChessD2D\FiveChessD2D.vcxproj.filters
目录 0 2017-08-18 13:08 FiveChessD2D\x64\
目录 0 2017-08-18 13:08 FiveChessD2D\x64\Debug\
文件 829 2017-08-13 11:41 FiveChessD2D\x64\Debug\FiveChessD2D.Build.CppClean.log
文件 185 2017-08-08 12:12 FiveChessD2D\x64\Debug\FiveChessD2D.log
目录 0 2017-08-18 13:08 FiveChessD2D\x64\Debug\FiveChessD2D.tlog\
目录 0 2017-08-18 13:08 FiveChessD2D\x64\Release\
文件 951067 2017-07-31 21:50 FiveChessD2D\x64\Release\Five.obj
文件 356 2017-07-31 21:50 FiveChessD2D\x64\Release\FiveChessD2D.log
目录 0 2017-08-18 13:08 FiveChessD2D\x64\Release\FiveChessD2D.tlog\
文件 646 2017-07-31 21:50 FiveChessD2D\x64\Release\FiveChessD2D.tlog\CL.command.1.tlog
文件 36376 2017-07-31 21:50 FiveChessD2D\x64\Release\FiveChessD2D.tlog\CL.read.1.tlog
文件 336 2017-07-31 21:50 FiveChessD2D\x64\Release\FiveChessD2D.tlog\CL.write.1.tlog
文件 199 2017-07-31 21:50 FiveChessD2D\x64\Release\FiveChessD2D.tlog\FiveChessD2D.lastbuildstate
文件 3402 2017-07-31 21:50 FiveChessD2D\x64\Release\FiveChessD2D.tlog\FiveChessD2D.write.1u.tlog
文件 1238 2017-07-31 21:50 FiveChessD2D\x64\Release\FiveChessD2D.tlog\li
文件 4386 2017-07-31 21:50 FiveChessD2D\x64\Release\FiveChessD2D.tlog\li
文件 338 2017-07-31 21:50 FiveChessD2D\x64\Release\FiveChessD2D.tlog\li
文件 520192 2017-07-31 21:50 FiveChessD2D\x64\Release\vc141.pdb
相关资源
- The direction of synaptic plasticity mediated
- VisualStudioUninstaller vs卸载工具
- 组态王驱动开发包3.0.0.7(中文)
- 多窗口后台鼠标连点器
- 使用选择性重传协议实现UDP可靠通信
- VC 获得文件属性 获取文件的创建时
- 读者写者问题(读者优先,写者优先
- 用VC 编写的仿QQ聊天室程序源代码
- 外点法程序
- 外罚函数程序
- qt-电子点菜系统
- 推箱子及人工智能寻路C 源代码
- 自己写的航空订票系统c 版--数据结构
- 数据结构实验魔王语言
- MUSIC算法c 实现
- C 餐厅叫号系统(QT平)
- 国际象棋c 完整版
-
ob
jectARX给Auto CAD加工具条 - 画图程序MFC/VC/VC CRectTracker 串行化
- MFC网络编程实例
- c 课程设计 职工信息管理系统
- VC 游戏编程—附源代码
- DirectDraw 直接修改显存数据
- IpHlpApi.h&IpHlpApi.lib
- 清华大学 c 郑莉 ppt课件
- c 程序判断离散数学中命题公式
- 多项式求和(数据结构C 版)
- vc 6.0开发的流程图编辑器
- VC 天空盒(skyBox)实现(附源代码)
- c MFC 画多边形
评论
共有 条评论