void CZLLKView::OnMenuFirst()
{
// TODO: Add your command handler code here
int i,j;
int temprand;
CString str;
CRect rect;
//產生隨機序列
srand((unsigned)time(NULL));
for(i=1;i<=ROW_NUMBER;i++)
for(j=1;j<=LINE_NUMBER;j++)
{
while(1)
{
temprand=rand()%15; // 產生0-14的亂數
if(pic_number[temprand]<6)
{
pic_number[temprand]++;
llk_map[i][j].state=0;
llk_map[i][j].event=0;
llk_map[i][j].PicIndex=temprand+1; // 1-15
break;
}
}
}
//列出每幅圖片所有的位置
ListPicPlace();
//初始化事件
InitEvent();
g_userscore=0;
g_userlevel=1;
g_usergate=1;
//程式控制
bingame=true;
bfirst=true;
DrawRectangleHollow();
m_nUpper=0;
DrawProgress(m_nUpper); // 總共400個時間
m_nSpeed=2;
SetTimer(1,1200,0);
DrawInfo(120,20,"剩余時間");
DrawInfo(20,20,"重列:");
DrawInfo(20,40,"提示:");
DrawInfo(540,20,"分數:");
DrawInfo2(60,20,m_sortnumber);
DrawInfo2(60,40,m_tishinumber);
DrawInfo2(560,40,g_userscore);
DrawMap();
//音效
//if(m_soundeffect)
// PlaySound(MAKEINTRESOURCE(IDR_WAVE_NEWGAME),AfxGetResourceHandle(),SND_RESOURCE|SND_ASYNC);
}
void CZLLKView::DrawMap()
{
//輸出圖形
CDC *pDc;
pDc=GetDC();
CDC dcMemory;
dcMemory.CreateCompatibleDC(pDc);
dcMemory.SelectObject(&bitmap1);
int i,j;
for(i=1;i<=ROW_NUMBER;i++)
{
for(j=1; j<=LINE_NUMBER;j++)
{
if(llk_map[i][j].PicIndex>0)
{
if(llk_map[i][j].state==0)
pDc->BitBlt(tilex(j),tiley(i),
PIC_WIDTH,PIC_HEIGHT,&dcMemory,PIC_WIDTH*(llk_map[i][j].PicIndex-1),0 ,SRCCOPY);
}
}
}
}
void CZLLKView::OnMenuExit()
{
// TODO: Add your command handler code here
PostQuitMessage(0);
}
uj5u.com熱心網友回復:
這個不知道效果怎么樣轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/104335.html
標籤:基礎類
