资源简介
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
相关资源
- 用于录音 ,适用于语言识别,说话人
- 多线程获取kinect2.0 视频并保存身体点
- 平面坐标转换-四参数仿射变换源码
- QT实现的自定义窗口框架
- 实验一 绘图类及其对象程序设计
- 基于OpenGL的场景迷宫漫游可以碰撞检
- 考试系统中Word操作题自动阅卷的实现
- 利用OpenGL和ArcGIS处理得到的坐标数据
- Introduction to 3D Game Programming with Direc
- funcode——拍飞虫
- AP聚类算法代码
- windows下socket 可以传输图片,压缩包等
- 进程调度的设计与实现图形界面实现
- CameraDs.h CameraDs.cpp directshow文件夹
- Zbar库好不容易找到的有configure的源码
- 比较两篇纯英文文本的相似度
- inttypes.h
- 基于QT的方块消除游戏
- DirectX SDK
- 多项式相乘一元稀疏多项式简单计算
- QT录音
- 数据结构课程设计--校园最短路径
- 开源3D游戏引擎 HXEngine
- AUTO_CAD.rar
- windows平台抓屏源代码
- CSDN-TCP基于数据包通讯框架
- QRGenerator.zip
- STDLIB.H头文件
- Printer打印类
- 银行业务模拟
评论
共有 条评论