Left_Button_Caption_8[]=\ char Right_Button_Caption_8[]=\ char Down_Button_Caption_8[]=\\ char Rotate_Button_Caption_8[]=\\ char MainDraw_Wnd_Caption_8[]=\ char PieceDraw_Wnd_Caption_8[]=\ char ScoreDraw_Wnd_Caption_8[]=\ char Score_Caption_8[]=\ U16 Score_Caption_16[10]; U16
NewGame_Button_Caption_16[10]; U16
Pause_Button_Caption_16[10]; U16
Left_Button_Caption_16[10]; U16
Right_Button_Caption_16[10]; U16 Rotate_Button_Caption_16[10]; U16
Down_Button_Caption_16[10]; U16
MainDraw_Wnd_Caption_16[20]; U16
PieceDraw_Wnd_Caption_16[20]; U16
ScoreDraw_Wnd_Caption_16[20];
pTouch_Position =&Touch_Position; pNewGame_Button =&NewGame_Button; pPause_Button =&Pause_Button; pLeft_Button =&Left_Button; pRight_Button =&Right_Button; pDown_Button =&Down_Button; pRotate_Button =&Rotate_Button; pMainDraw_Wnd =&MainDraw_Wnd; pPieceDraw_Wnd =&PieceDraw_Wnd; pScoreDraw_Wnd =&ScoreDraw_Wnd; pNewGame_Button_RECT =&NewGame_Button_RECT; pPause_Button_RECT =&Pause_Button_RECT; pLeft_Button_RECT =&Left_Button_RECT; pRight_Button_RECT =&Right_Button_RECT; pDown_Button_RECT =&Down_Button_RECT; pRotate_Button_RECT =&Rotate_Button_RECT; pMainDraw_Wnd_RECT =&MainDraw_Wnd_RECT; pPieceDraw_Wnd_RECT =&PieceDraw_Wnd_RECT; pScoreDraw_Wnd_RECT =&ScoreDraw_Wnd_RECT; strChar2Unicode(NewGame_Button_Caption_16,NewGame_Button_Caption_8);
- 16 -
strChar2Unicode(Pause_Button
_Caption_16,Pause_Button_Caption_8); strChar2Unicode(Left_Button_90; Caption_16,Left_Button_Caption_8); strChar2Unicode(Right_Button; _Caption_16,Right_Button_Caption_8); strChar2Unicode(Down_Button _Caption_16,Down_Button_Caption_8); strChar2Unicode(Rotate_Butto28; n_Caption_16,Rotate_Button_Caption_8); strChar2Unicode(MainDraw_ Wnd_Caption_16,MainDraw_Wnd_Captio; n_8); strChar2Unicode(PieceDraw_ Wnd_Caption_16,PieceDraw_Wnd_Captio n_8); 190; strChar2Unicode(ScoreDraw_ Wnd_Caption_16,ScoreDraw_Wnd_Captio n_8); 0; strChar2Unicode(Score_Captio n_16,Score_Caption_8);
NewGame_Button_RECT.bottom=219; m=40; NewGame_Button_RECT.left=; 180; NewGame_Button_RECT.right129; =230; NewGame_Button_RECT.top=; 10;
Pause_Button_RECT.bottom=4=149; 0; Pause_Button_RECT.left=240; 0; Pause_Button_RECT.right=290 ; 289; Pause_Button_RECT.top=10; ; Left_Button_RECT.bottom=19 0;
Left_Button_RECT.left=180; m=79; Left_Button_RECT.right=210; Left_Button_RECT.top=160;
80;
- 17 -
Right_Button_RECT.bottom=1Right_Button_RECT.left=260; Right_Button_RECT.right=290Right_Button_RECT.top=160;
Down_Button_RECT.bottom=2Down_Button_RECT.left=220; Down_Button_RECT.right=250Down_Button_RECT.top=198;
Rotate_Button_RECT.bottom=Rotate_Button_RECT.left=220; Rotate_Button_RECT.right=25Rotate_Button_RECT.top=160;
MainDraw_Wnd_RECT.bottoMainDraw_Wnd_RECT.left=10MainDraw_Wnd_RECT.right=MainDraw_Wnd_RECT.top=10
PieceDraw_Wnd_RECT.bottomPieceDraw_Wnd_RECT.left=18PieceDraw_Wnd_RECT.right=PieceDraw_Wnd_RECT.top=90
ScoreDraw_Wnd_RECT.bottoScoreDraw_Wnd_RECT.left=1
ScoreDraw_Wnd_RECT.right=289; ScoreDraw_Wnd_RECT.top=50; pNewGame_Button=CreateButton( NewGame_Button_ID,pNewGame_Button_RECT, FONTSIZE_SMALL,CTRL_STYLE_3DDOWNFRAME, NewGame_Button_Caption_16,NULL); pPause_Button=CreateButton( Pause_Button_ID,pPause_Button_RECT, FONTSIZE_SMALL,CTRL_STYLE_3DDOWNFRAME, Pause_Button_Caption_16,NULL); pLeft_Button=CreateButton( Left_Button_ID,pLeft_Button_RECT, FONTSIZE_SMALL,CTRL_STYLE_3DDOWNFRAME, Left_Button_Caption_16,NULL); pRight_Button=CreateButton( Right_Button_ID,pRight_Button_RECT,
FONTSIZE_SMALL,CTRL_STYLE_3DDOWNFRAME, Right_Button_Caption_16,NULL); pDown_Button=CreateButton( Down_Button_ID,pDown_Button_RECT, FONTSIZE_SMALL,CTRL_STYLE_3DDOWNFRAME, Down_Button_Caption_16,NULL); pRotate_Button=CreateButton( Rotate_Button_ID,pRotate_Button_RECT, FONTSIZE_SMALL,CTRL_STYLE_3DDOWNFRAME, Rotate_Button_Caption_16,NULL); pMainDraw_Wnd=CreateWindow( MainDraw_Wnd_ID,pMainDraw_Wnd_RECT, FONTSIZE_SMALL,WND_STYLE_MODE, MainDraw_Wnd_Caption_16,NULL); pPieceDraw_Wnd=CreateWindow( PieceDraw_Wnd_ID,pPieceDraw_Wnd_RECT,
- 18 -
FONTSIZE_SMALL,WND_STYLE_MODE, PieceDraw_Wnd_Caption_16,NULL); pScoreDraw_Wnd=CreateWindow( ScoreDraw_Wnd_ID,pScoreDraw_Wnd_RECT, FONTSIZE_SMALL,WND_STYLE_MODE, ScoreDraw_Wnd_Caption_16,NULL); DrawButton(pNewGame_Button); DrawButton(pPause_Button); DrawButton(pLeft_Button); DrawButton(pRight_Button); DrawButton(pDown_Button); DrawButton(pRotate_Button); DrawWindow(pMainDraw_Wnd); DrawWindow(pPieceDraw_Wnd); DrawWindow(pScoreDraw_Wnd); pdc=CreateDC(); pdc->DrawRect=ScoreDraw_Wnd_RECT; TextOut(pdc,190,60,Score_Caption_16,TRUE,FONTSIZE_SMALL); SetScoreText(pdc); pdc->DrawRect=MainDraw_Wnd_RECT; DrawMainFrame(pdc);
for(;;)
{ pMsg=WaitMessage(0); switch(pMsg->Message) { case OSM_TOUCH_SCREEN: Touch_Position.x=pMsg->WParam&0xffff; Touch_Position.y=pMsg->WParam>>16; if(IsInRect2(pNewGame_Button_RECT,pTouch_Position)) { newGame(); }else
if(IsInRect2(pPause_Button_RECT,pTouch_Position)) { pause(); }else
if(IsInRect2(pLeft_Button_RECT,pTouch_Position)) { moveLeft(); }else
if(IsInRect2(pRight_Button_RECT,pTouch_Position)) { moveRight(); }else
if(IsInRect2(pDown_Button_RECT,pTouch_Position)) { drop(); }else
if(IsInRect2(pRotate_Button_RECT,pTouch_Position)) { rotateClockwise(); } case OSM_KEY:
- 19 -
onKey(pMsg->WParam,pMsg->LParam); break; } DeleteMessage(pMsg); OSTimeDly(100); } DestroyDC(pdc); }
/*方块下落任务:自动下落、检测满行并消去*/
void AutoDrop_Task(void *Id) { int i; while(StillRunning) { OSTimeDly(delay); if(!StillRunning)break; if(boardinitialized) { if(Paused) continue; if(CurrentBlockColour==0) { Chose_Color=Rand_Color(); if(NextBlockColour==0)makeNewPiece(); CurrentBlockColour=NextBlockColour; CurrentBlockX=NextBlockX; CurrentBlockY=NextBlockY; CurrentBlockShape=NextBlockShape; CurrentBlockAngle=NextBlockAngle; makeNewPiece();
}else
{ i=-1; while(i++<3) if(CurrentBlockY+BlockInfo[CurrentBlockShape][CurrentBlockAngle][i][1]>=(ROWCOUNT-1) ||BoardArray[CurrentBlockX+BlockInfo[CurrentBlockShape][CurrentBlockAngle][i][0]][ CurrentBlockY+1+BlockInfo[CurrentBlockShape][CurrentBlockAngle][i][1]]!=0) { i=-1; while(i++<3) { BoardArray[CurrentBlockX+BlockInfo[CurrentBlockShape][CurrentBlockAngle][i][0]] [CurrentBlockY+BlockInfo[CurrentBlockShape][CurrentBlockAngle][i][1]]=CurrentBlockColour; COLOR[CurrentBlockX+BlockInfo[CurrentBlockShape][CurrentBlockAngle][i][0]] [CurrentBlockY+BlockInfo[CurrentBlockShape][CurrentBlockAngle][i][1]]=Chose_Color; if(CurrentBlockY+BlockInfo[CurrentBlockShape][CurrentBlockAngle][i][1]<3) { Paused=TRUE;
- 20 -