📄 空当接龙dlg.cpp
字号:
thedc->StretchBlt((m_thegame->m_lies-10)*71+17,0+25,36,40,&jrdc,0,0,bmp.bmWidth,bmp.bmHeight,SRCCOPY);
ReleaseDC(thedc);
}
for(i=0;i<4;i++)//右上角
{
if(m_thegame->m_shoup[i].ds!=0)
{
CDC *thedc=GetDC();
CDC jrdc;
BITMAP bmp;
m_pai[0].GetBitmap(&bmp);
jrdc.CreateCompatibleDC(thedc);
jrdc.SelectObject(&m_pai[m_thegame->m_shoup[i].zb]);
thedc->StretchBlt(347+71*i,0,71,97,&jrdc,0,0,bmp.bmWidth,bmp.bmHeight,SRCCOPY);
ReleaseDC(thedc);
}
}
if(m_thegame->m_rlies!=-1||m_thegame->m_rhangs!=-1)
{
CDC *thedc=GetDC();
CDC jrdc;
BITMAP bmp;
m_pai[0].GetBitmap(&bmp);
jrdc.CreateCompatibleDC(thedc);
jrdc.SelectObject(&m_pai[m_thegame->m_gamep[m_thegame->m_rlies][m_thegame->m_rhangs].zb]);
thedc->StretchBlt(m_thegame->m_rlies*77+10,m_thegame->m_rhangs*18+100,71,97,&jrdc,0,0,bmp.bmWidth,bmp.bmHeight,SRCCOPY);
ReleaseDC(thedc);
}
CWindowDC dc(this);//输出还剩几张牌
char sc[10];
if(m_thegame->m_sps>=10)
{
sprintf(sc,"剩余纸牌:%d",m_thegame->m_sps);
dc.TextOut(550,30,sc,strlen(sc));
}
if(m_thegame->m_sps<10)
{
sprintf(sc,"剩余纸牌:%d",m_thegame->m_sps);
dc.TextOut(557,30,sc,strlen(sc));
}
}//if(m_ynks==true)
if(m_xsdh==true&&m_ynks==false)
{
for(int i=347,j=0;i>0;i-=5,j+=4)
{
CDC *thedc=GetDC();
CDC jrdc;
BITMAP bmp;
m_pai[0].GetBitmap(&bmp);
jrdc.CreateCompatibleDC(thedc);
jrdc.SelectObject(&m_pai[12]);
thedc->StretchBlt(i,j,71,97,&jrdc,0,0,bmp.bmWidth,bmp.bmHeight,SRCCOPY);
ReleaseDC(thedc);
Sleep(1);
}
for(i=418,j=0;i>71;i-=5,j+=4)
{
CDC *thedc=GetDC();
CDC jrdc;
BITMAP bmp;
m_pai[0].GetBitmap(&bmp);
jrdc.CreateCompatibleDC(thedc);
jrdc.SelectObject(&m_pai[25]);
thedc->StretchBlt(i,j,71,97,&jrdc,0,0,bmp.bmWidth,bmp.bmHeight,SRCCOPY);
ReleaseDC(thedc);
Sleep(1);
}
for(i=489,j=0;i>142;i-=5,j+=4)
{
CDC *thedc=GetDC();
CDC jrdc;
BITMAP bmp;
m_pai[0].GetBitmap(&bmp);
jrdc.CreateCompatibleDC(thedc);
jrdc.SelectObject(&m_pai[38]);
thedc->StretchBlt(i,j,71,97,&jrdc,0,0,bmp.bmWidth,bmp.bmHeight,SRCCOPY);
ReleaseDC(thedc);
Sleep(1);
}
for(i=560,j=0;i>213;i-=5,j+=4)
{
CDC *thedc=GetDC();
CDC jrdc;
BITMAP bmp;
m_pai[0].GetBitmap(&bmp);
jrdc.CreateCompatibleDC(thedc);
jrdc.SelectObject(&m_pai[51]);
thedc->StretchBlt(i,j,71,97,&jrdc,0,0,bmp.bmWidth,bmp.bmHeight,SRCCOPY);
ReleaseDC(thedc);
Sleep(1);
}
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CMyDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
HBRUSH CMyDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
CBitmap bitmap;
bitmap.LoadBitmap(IDB_GAMEBAK);
static CBrush backbursh(&bitmap);
// TODO: Change any attributes of the DC here
return backbursh;
// TODO: Return a different brush if the default is not desired
//return hbr;
}
void CMyDlg::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
//char aa[10];
//sprintf(aa,"%d %d",point.x,point.y);
//MessageBox(aa);
int lies;//鼠标单击在第几列
lies=(point.x-10)/77;
if(point.x>=lies*77+10&&point.x<=lies*77+10+70&&point.y>=100&&point.y<=m_thegame->m_pshu[lies]*18+100+97-18)//如果单击中了某列的最下面一张牌
{
if(m_thegame->m_pshu[lies]==0&&m_thegame->m_xuanp[0].zb!=-1&&m_thegame->m_lies!=lies&&m_thegame->m_lies<10&&m_thegame->m_xzps>1)
{
if(IDYES==MessageBox("移动整列?",NULL,MB_ICONQUESTION|MB_YESNO))
{
m_thegame->m_ynzl=true;
}
}
m_thegame->ynxuan(lies);
if(m_thegame->m_ynnp==1)
{
CRect rect(lies*77+10+17,lies*18+100+25,lies*77+10+17+36,lies*18+100+25+40);
InvalidateRect(&rect);
CRect rect1(m_thegame->m_oldlies*77+10,m_thegame->m_pshu[m_thegame->m_oldlies]*18+100-18,m_thegame->m_oldlies*77+10+70,m_thegame->m_pshu[m_thegame->m_oldlies]*18+100-18+18*m_thegame->m_npws+100);
InvalidateRect(&rect1);
//
}
if(m_thegame->m_ynnp==0)
{
MessageBox("不能这样挪牌!",NULL,MB_ICONASTERISK&MB_ICONINFORMATION);
}
if(m_thegame->m_ynnp==2)
{
MessageBox("挪牌位置不够!",NULL,MB_ICONASTERISK&MB_ICONINFORMATION);
}
if(m_thegame->m_ynnp==3)
{
CRect rect((m_thegame->m_oldlies-10)*71,0,(m_thegame->m_oldlies-10)*71+71,97);
InvalidateRect(&rect);
}
}
if(point.x<=71*4&&point.y<=97)//鼠标在左上角有牌的筐内点击
{
lies=point.x/71;
m_thegame->ynxuan(10+lies);
CRect rect(lies*71+17,25,lies*71+17+36,25+40);
InvalidateRect(&rect);
}
/*if(m_thegame->ynsp()==false)
{
MessageBox("牌死了请重新开始",NULL,MB_ICONASTERISK&MB_ICONINFORMATION);
}*/
CDialog::OnLButtonDown(nFlags, point);
}
void CMyDlg::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
if(point.y<=95&&point.y>=0)
{
if(point.x>=0&&point.x<=284&&m_txnb==2)
{
m_txnb=1;
CRect rect(297,17,335,55);
InvalidateRect(&rect);
}
if(point.x>=347&&point.x<=628&&m_txnb==1)
{
m_txnb=2;
CRect rect(297,17,335,55);
InvalidateRect(&rect);
}
}
CDialog::OnMouseMove(nFlags, point);
}
void CMyDlg::Onbegin()
{
// TODO: Add your command handler code here
if(m_ynks==true&&m_thegame->m_sps!=0)
{
if(IDYES==MessageBox("确认放弃本局?",NULL,MB_ICONQUESTION|MB_YESNO))
{
m_ynks=false;
}
}
if(m_ynks==false)
{
m_thegame->xipai();
m_ynks=true;
m_xsdh=false;
Invalidate();
}
}
void CMyDlg::OnLButtonDblClk(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
if(point.x>=10&&point.x<=549+70&&point.y>=100)
{
int lies;//鼠标双击在第几列
lies=(point.x-10)/77;
if(point.x>=lies*77+10&&point.x<=lies*77+10+70&&point.y>=m_thegame->m_pshu[lies]*18+100-18&&point.y<=m_thegame->m_pshu[lies]*18+100+97-18)//如果双击中了某列的最下面一张牌
{
if(!m_thegame->ynshoup(lies))
{
if(m_thegame->cunp(lies))//如果挪动成功
{
CRect rect(lies*77+10,m_thegame->m_pshu[lies]*18+100,lies*77+10+70,m_thegame->m_pshu[lies]*18+100+97);
InvalidateRect(&rect);
}
else
;
}
else
{
CRect rect(lies*77+10,m_thegame->m_pshu[lies]*18+100,lies*77+10+70,m_thegame->m_pshu[lies]*18+100+97);
InvalidateRect(&rect);
}
}
}
if(point.x<=71*4&&point.y<=97)//鼠标在左上角有牌的筐内点击
{
int lies=point.x/71;
if(m_thegame->ynshoup(lies+10))
{
CRect rect(71*lies,0,71*lies+71,97);
InvalidateRect(&rect);
}
}
m_thegame->zdsp();
Invalidate();
if(m_thegame->m_sps==0)
{
Invalidate();
MessageBox("你赢了",NULL,MB_ICONASTERISK&MB_ICONINFORMATION);
m_xsdh=true;
m_ynks=false;
Invalidate();
}
CDialog::OnLButtonDblClk(nFlags, point);
}
void CMyDlg::OnRButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
if(point.x>=10&&point.x<=549+70&&point.y>=100)
{
int lies;//鼠标右击在第几列
lies=(point.x-10)/77;
if(point.x>=lies*77+10&&point.x<lies*77+10+70&&point.y>=100&&point.y<m_thegame->m_pshu[lies]*18-18+97)
{
m_thegame->m_rlies=lies;
m_thegame->m_rhangs=(point.y-100)/18;
CRect rect(77*lies+10,m_thegame->m_rhangs*18+100,77*lies+10+70,m_thegame->m_rhangs*18+100+97);
InvalidateRect(&rect);
}
}
CDialog::OnRButtonDown(nFlags, point);
}
void CMyDlg::OnRButtonUp(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
int lies=m_thegame->m_rlies;
int hangs=m_thegame->m_rhangs;
m_thegame->m_rlies=-1;
m_thegame->m_rhangs=-1;
CRect rect(77*lies+10,hangs*18+100,77*lies+10+70,hangs*18+100+97);
InvalidateRect(&rect);
CDialog::OnRButtonUp(nFlags, point);
}
void CMyDlg::OnMove(int x, int y)
{
CDialog::OnMove(x, y);
// TODO: Add your message handler code here
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -