资源简介
用VC开发的七巧板,可以用于C,C++,MFC,人工智能等的大作业

代码片段和文件信息
// Chip.cpp: implementation of the CChip class.
//
//////////////////////////////////////////////////////////////////////
#include “stdafx.h“
#include “My.h“
#include “Chip.h“
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
IMPLEMENT_SERIAL(CChip Cobject 1)
// 设置拼图块参数
void CChip::SetChip(int type POINT *ppointlist int count)
{
m_nType = type;
m_nPointCount = count;
for(int i=0; i m_pointList[i] = ppointlist[i];
}
// 绘出拼图块
void CChip::DrawChip(CDC *pDC)
{
CPen penNew *ppenOld;
CBrush brushNew *pbrushOld;
switch(m_nType)
{
case 1:
brushNew.CreateSolidBrush(RGB(127 127 127));
break;
case 2:
brushNew.CreateSolidBrush(RGB(255 0 0));
break;
case 3:
brushNew.CreateSolidBrush(RGB(0 255 0));
break;
case 4:
brushNew.CreateSolidBrush(RGB(0 0 255));
break;
case 5:
brushNew.CreateSolidBrush(RGB(127 127 0));
break;
case 6:
brushNew.CreateSolidBrush(RGB(127 0 127));
break;
case 7:
brushNew.CreateSolidBrush(RGB(0 127 127));
break;
}
penNew.CreatePen(PS_SOLID 1 RGB(0 0 0));
ppenOld = pDC->Selectobject(&penNew);
pbrushOld = pDC->Selectobject(&brushNew);
pDC->Polygon(m_pointList m_nPointCount);
pDC->Selectobject(ppenOld);
pDC->Selectobject(pbrushOld);
}
// 检测一点是否在拼图块中
BOOL CChip::PtInChip(POINT point)
{
CRgn rgn;
int x=rgn.CreatePolygonRgn(m_pointList m_nPointCount ALTERNATE);
return rgn.PtInRegion(point);
}
// 取拼图块的包含矩形
LPCRECT CChip::GetRect()
{
static RECT rect;
CRgn rgn;
rgn.CreatePolygonRgn(m_pointList m_nPointCount ALTERNATE);
rgn.GetRgnBox(&rect);
rect.right++;
rect.bottom++;
return ▭
}
// 旋转拼图块
void CChip::Rotation()
{
CRect rect;
CRgn rgn;
rgn.CreatePolygonRgn(m_pointList m_nPointCount ALTERNATE);
rgn.GetRgnBox(&rect);
double x = rect.left+rect.Width()/2; // 计算旋转中心
double y = rect.top+rect.Height()/2;
double dx dy;
for(int i=0; i {
dx = m_pointList[i].x-x;
dy = m_pointList[i].y-y;
m_pointList[i].x = (int)(x+dx*0.7071-dy*0.7071);
m_pointList[i].y = (int)(y+dx*0.7071+dy*0.7071);
}
}
// 移动拼图块
void CChip::MoveTo(CSize offset)
{
for(int i=0; i m_pointList[i] = m_pointList[i]+offset;
}
// 序列化
void CChip::Serialize(CArchive &ar)
{
if(ar.IsStoring())
{
ar << m_nType;
ar << m_nPointCount;
for(int i=0; i ar << m_pointList[i];
}
else
{
ar >> m_nType;
ar >> m_nPointCount;
for(int i=0; i ar >> m_pointList[i];
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 2880 2003-09-05 13:32 七巧板\Chip.cpp
文件 916 2003-09-05 13:32 七巧板\Chip.h
文件 2503 2003-09-05 13:32 七巧板\MainFrm.cpp
文件 1581 2003-09-05 13:32 七巧板\MainFrm.h
文件 29372 2006-11-14 01:06 七巧板\My.aps
文件 2205 2003-09-05 13:32 七巧板\My.clw
文件 4146 2003-09-05 13:32 七巧板\My.cpp
文件 4591 2003-09-05 13:32 七巧板\My.dsp
文件 527 2003-09-05 13:32 七巧板\My.dsw
文件 1312 2003-09-05 13:32 七巧板\My.h
文件 54784 2003-09-05 13:32 七巧板\My.opt
文件 1072 2003-09-05 13:32 七巧板\My.plg
文件 10485 2003-09-05 13:32 七巧板\My.rc
文件 868 2010-10-27 10:41 七巧板\My.sln
..A..H. 7680 2010-10-27 10:41 七巧板\My.suo
文件 3906 2003-09-05 13:32 七巧板\MyDoc.cpp
文件 1549 2003-09-05 13:32 七巧板\MyDoc.h
文件 4355 2003-09-05 13:32 七巧板\MyView.cpp
文件 2007 2003-09-05 13:32 七巧板\MyView.h
文件 4215 2003-09-05 13:32 七巧板\ReadMe.txt
文件 486 2003-09-05 13:32 七巧板\Resource.h
文件 204 2003-09-05 13:32 七巧板\StdAfx.cpp
文件 1054 2003-09-05 13:32 七巧板\StdAfx.h
目录 0 2013-07-20 14:20 七巧板
----------- --------- ---------- ----- ----
142698 24
相关资源
- VC++ 多线程文件读写操作
- 移木块游戏,可以自编自玩,vc6.0编写
- MFC数字钟(基于VC6.0)
- 安科瑞智能电能表MODBUS通讯程序 VC6
- VC++MFC小游戏实例教程(实例)+MFC类库
- VC6LineNumberAddin.dll
- 用VC6.0实现多边形扫描线填充算法
- VC++实现CMD命令执行与获得返回信息
- VC助手 VC6.0助手
- VC++基于OpenGL模拟的一个3维空间模型
- 基于VC++的SolidWorks二次开发SolidWorks
- VC6 USB开发源码
- VC操作SQLSERVER数据库
- aes加解密(vc源程序)
- vc_串口通讯
- 吕鑫vc6c++数据结构视频源码
- 派克变换VC++源码(附文档)
- 基于opencv漫水填充算法综合
- VC++ 串口
- VC++ 大富翁4_大富翁游戏源码
- MFC的异步网络通讯应用程序
- VC++ 摄像头视频采集与回放源程序
- 转 VC++ 实现电子邮件(Email)发送
- 基于MFC的VC++仿QQ浏览器源码(雏形)
- VC++ 服务程序编写及安装与卸载
- VC++6.0番茄西红柿VAXvirsual assist X完美破
- VC编程助手2010破解版(原名VA_X_10.6.
- 基于改进的fcm算法的图像分割vc++
- VC++6.0 绿色版,免安装,非常好用。
- Microsoft Visual C++ 2005 Redistributable Pack
评论
共有 条评论