// fivechessView.cpp : implementation of the CFivechessView class
//
#include "stdafx.h"
#include "fivechess.h"
#include "fivechessDoc.h"
#include "fivechessView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CFivechessView
IMPLEMENT_DYNCREATE(CFivechessView, CView)
BEGIN_MESSAGE_MAP(CFivechessView, CView)
//{{AFX_MSG_MAP(CFivechessView)
ON_COMMAND(ID_NEW_GAME, OnNewGame)
ON_WM_CREATE()
ON_WM_LBUTTONDOWN()
ON_COMMAND(IDC_REPLACE, OnReplace)
ON_COMMAND(ID_MAN, OnMan)
ON_COMMAND(ID_COMPUTER, OnComputer)
ON_UPDATE_COMMAND_UI(ID_MAN, OnUpdateMan)
ON_UPDATE_COMMAND_UI(ID_COMPUTER, OnUpdateComputer)
//}}AFX_MSG_MAP
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
ON_COMMAND_RANGE(IDC_EASY,IDC_HARD,CFivechessView::OnDegree)
ON_UPDATE_COMMAND_UI_RANGE(IDC_EASY,IDC_HARD,CFivechessView::OnUpdateDegree)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CFivechessView construction/destruction
CFivechessView::CFivechessView()
{
// TODO: add construction code here
degree=2;
m_pMemDC=new CDC;
m_pBitmap=new CBitmap;
man=1;
}
CFivechessView::~CFivechessView()
{
m_pMemDC->SelectObject(pOldBitmap);
delete m_pMemDC;
delete m_pBitmap;
}
BOOL CFivechessView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CFivechessView drawing
void CFivechessView::OnDraw(CDC* pDC)
{
CFivechessDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
// CBitmap* pOldBitmap=m_pMemDC->SelectObject(m_pBitmap);
pDC->BitBlt(0,0,m_nMaxX,m_nMaxY,m_pMemDC,0,0,SRCCOPY);
// m_pMemDC->SelectObject(pOldBitmap);
}
#ifdef _DEBUG
void CFivechessView::AssertValid() const
{
CView::AssertValid();
}
void CFivechessView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CFivechessDoc* CFivechessView::GetDocument()
// non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CFivechessDoc)));
return (CFivechessDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CFivechessView message handlers
void CFivechessView::OnDegree(UINT nID)
{ ASSERT(nID>=IDC_EASY && nID<=IDC_HARD);
degree=nID-IDC_EASY;
}
void CFivechessView::OnUpdateDegree(CCmdUI* pCmdUI)
{ int nID=pCmdUI->m_nID-IDC_EASY;
if(nID==degree)
pCmdUI->SetCheck(1);
else pCmdUI->SetCheck(0);
}
void CFivechessView::OnNewGame()
{
// TODO: Add your command handler code here
/* delete m_pMemDC;
m_pMemDC=new CDC;
CDC* pDC=GetDC();
m_pMemDC->CreateCompatibleDC(pDC);
CBitmap* pOldBitmap=m_pMemDC->SelectObject(m_pBitmap);*/
Showqp();
// ReleaseDC(pDC);
Invalidate(0);
//1为黑方,2为白方,0没有棋子
side=1;
//开始标志:1。0没开始或结束。
start=1;
begin=1;
for(int i=0;i<N;i++)
for(int j=0;j<N;j++)
{ qp[i][j]=0;
qp1[i][j]=0;
}
for(i=0;i<72;i++)
{p[i].x=0;
p[i].y=0;
}
for(i=0;i<324;i++)
{ p1[i].x=0;
p1[i].y=0;
}
record=-1;
if(man==2)
{side=2;
qp[8][9]=2;
CBrush brush1(RGB(250,250,250));
CPen pen(0,1,RGB(201,201,201));
CPen *OldPen= m_pMemDC->SelectObject(&pen);
CBrush *OldBrush=m_pMemDC->SelectObject(&brush1);
m_pMemDC->Ellipse(8*30+47,9*30+2,8*30+47+26,9*30+2+26);
m_pMemDC->FloodFill(8*30+60,9*30+15,RGB(201,201,201));
m_pMemDC->SelectObject(OldPen);
m_pMemDC->SelectObject(OldBrush);
record++;
p1[record].x=8;
p1[record].y=9;
Invalidate(0);
side=1;
}
return;
}
void CFivechessView::Showqp()
{
CPen pen1(0,4,RGB(0,0,0));
CPen pen2(0,2,RGB(0,0,0));
CBrush brush;
brush.CreateSolidBrush(RGB(150,80,50));
CBrush* pOldBrush=(CBrush*)m_pMemDC->SelectObject(&brush);
CPoint point1,point2;
point1.x=60;
point1.y=15;
point2.x=570;
point2.y=525;
CRect rect(point1,point2);
CBitmap* pOldBitmap=m_pMemDC->SelectObject(m_pBitmap);
CPen* pOldPen =m_pMemDC->SelectObject(&pen2);
m_pMemDC->Rectangle(40,0,590,550);
m_pMemDC->SelectObject(&pen1);
m_pMemDC->Rectangle(rect);
m_pMemDC->SelectObject(&pen2);
for(int i=90;i<=540;i+=30)
{m_pMemDC->MoveTo(i,15);
m_pMemDC->LineTo(i,525);
}
for(int j=45;j<=495;j+=30)
{m_pMemDC->MoveTo(60,j);
m_pMemDC->LineTo(570,j);
}
CBrush brush1(RGB(0,0,0));
m_pMemDC->SelectObject(&brush1);
m_pMemDC->Ellipse(206,161,214,169);
m_pMemDC->FloodFill(210,165,RGB(0,0,0));
m_pMemDC->Ellipse(416,161,424,169);
m_pMemDC->FloodFill(420,165,RGB(0,0,0));
m_pMemDC->Ellipse(206,371,214,379);
m_pMemDC->FloodFill(210,375,RGB(0,0,0));
m_pMemDC->Ellipse(416,371,424,379);
m_pMemDC->FloodFill(420,375,RGB(0,0,0));
// m_pMemDC->SelectObject(pOldBitmap);
m_pMemDC->SelectObject(pOldPen);
m_pMemDC->SelectObject(pOldBrush);
return;
}
int CFivechessView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CView::OnCreate(lpCreateStruct) == -1)
return -1;
// TODO: Add your specialized creation code here
m_nMaxX=GetSystemMetrics(SM_CXSCREEN);
m_nMaxY=GetSystemMetrics(SM_CYSCREEN);
CDC* pDC=GetDC();
m_pMemDC->CreateCompatibleDC(pDC);
m_pBitmap->CreateCompatibleBitmap(pDC,m_nMaxX,m_nMaxY);
pOldBitmap=m_pMemDC->SelectObject(m_pBitmap);
CBrush brush(RGB(60,150,250));
CRect rect(-1,-1,m_nMaxX,m_nMaxY);
m_pMemDC->FillRect(&rect,&brush);
// m_pMemDC->SetBkColor(RGB(50,80,250));
Invalidate(1);
ReleaseDC(pDC);
return 0;
}
void CFivechessView::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
int x=point.x;
int y=point.y;
int mm,nn;
if(x>=40&&x<=580&&y>=0&&y<=550)
{mm=(x-45)/30;
nn=(y-0)/30;
}
else return ;
if(side==1&&start==1&&qp[mm][nn]==0)
{
CBrush brush1(RGB(0,0,0));
CPen pen(0,1,RGB(1,1,1));
CPen* OldPen= m_pMemDC->SelectObject(&pen);
CBrush* OldBrush=m_pMemDC->SelectObject(&brush1);
m_pMemDC->Ellipse(mm*30+47,nn*30+2,mm*30+47+26,nn*30+2+26);
m_pMemDC->FloodFill(mm*30+60,nn*30+15,RGB(1,1,1));
m_pMemDC->SelectObject(OldPen);
m_pMemDC->SelectObject(OldBrush);
qp[mm][nn]=1;
record++;
p1[record].x=mm;
p1[record].y=nn;
Invalidate(0);
m=mm;
n=nn;
if(panduan())
{
AfxMessageBox("你赢了,从新开始!");
start=0;
CFivechessView::OnNewGame() ;
return;
}
side=2;
if(side==2&&start==1)
{
zhineng();
}
}
CView::OnLButtonDown(nFlags, point);
}
BOOL CFivechessView::panduan()
{
char i=1;
char j=1;
switch(0)
{case 0:
while(1)
{ if(m-i>=0&&qp[m-i][n]==1)
i++;
else break;
}
while(1)
{ if(m+j<18&&qp[m+j][n]==1)
{
i++;
j++;
}
else break;
}
if(i>=5)
return 1;
case 1: i=1;j=1;
while(1)
{ if(n-i>=0&&qp[m][n-i]==1)
i++;
else break;
}
while(1)
{ if(n+j<18&&qp[m][n+j]==1)
{
i++;
j++;
}
else break;
}
if(i>=5)
return 1;
case 2: i=1;j=1;
while(1)
{ if(m-i>=0&&n-i>=0&&qp[m-i][n-i]==1)
i++;
e
xiu_wei
- 粉丝: 0
- 资源: 6
最新资源
- 小数分频锁相环,环形振荡器结构,smic28nm,有版图,有很多设计原理ppt文档等
- langchain的详解与应用
- 基于VSG控制(同步发电机控制)的模块化多电平变流器MMC 通过设置可编程电源,模拟电网频率和电压改变, 观测MMC输出功率的变化情况 初步设定值电网线电压U=10kV;Pref=10e6;Qref=
- 永磁同步电机旋转高频信号注入法零低速无位置控制仿真,相比高频方波信号注入法,旋转高频信号注入法噪声更小损耗更低
- 在MySQL中使用查询扩展的全文搜索和全文搜索停用词.pdf
- simulink光伏并同步发电机,光伏减载,留出备用进行频率惯量支撑,减小对同步发电机的依赖 频率支撑效果好,波形效果好,非一般仿真 可以改变光强,温度以及减载率
- 机械设计PCB自动清洗线step非常好的设计图纸100%好用.zip
- Qt CPP实现的多列时间轴控件、可与多段字符串格式自由转、也可手动添加列表项、专门用来以时间轴作为事件线发展顺序的故事大纲 时间可输入任意内容,不限于时间,每一时间段允许多列,即多个文字节点,行与
- 类和对象资料学习文档备份
- 构网变流器功率控制控制(dq坐标系) 1)dq旋转坐标系下实现下垂控制; 2)无功下垂采用比例积分控制,能够实现功率准确、快速无静差跟踪; 3)采用电压电流双闭环、电压前馈实现准确电压跟踪
- 模型预测控制(MPC)+路径跟踪(PTC)+侧偏角软约束+主动前轮转向(AFS),目前的范例是72km h,附着系数0.3的单移线,附着系数0.85双移线 仿真使用的是MATLAB2020b版本和c
- 机械设计布料拉平裁切机sw18可编辑非常好的设计图纸100%好用.zip
- Python的安装及运行PDF
- 非线性七自由度车辆simulink模型,基于魔术公式,同时提供二,三自由度车辆模型,发整套 汽车操作稳定性模型,考虑四个车轮转动,考虑汽车侧向纵向运动 提供,参考lunwen 提供二自由度车辆动
- 无线充电仿真 simulink 磁耦合谐振 无线电能传输 MCR WPT lcc ss llc拓扑补偿 一共四套模型: 1.llc谐振器实现12 24V恒压输出 带调频控制 附参考文献和讲解视频
- 机械设计齿轮箱滚珠模块装配step非常好的设计图纸100%好用.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈