📄 games_fruit.c
字号:
blinkflag =OP_FALSE;
Fgame_state.Clearance_time = st_time;
if(Find_Hint_Fruit() == OP_FALSE)
{
if(Fruitnewgame_hint(&xi,&yj)==OP_FALSE)
{
ShowGameOver( fruitnewgame_Score);
return ;
}
else
{
fruitnewgame_position[xi][yj]=fruitnewgame_position[xi][yj]+10;
fruitnewgame_Score=fruitnewgame_Score-50;
Find_Firstpress_Fruit();
DrawSquare(xi, yj, fruitnewgame_position[xi][yj]);
}
}
else
fruitnewgame_Score=fruitnewgame_Score-50;
}
ShowScore();
}
/*==================================================================================================
FUNCTION: End_Hint
DESCRIPTION:
Description of this specific function.
ARGUMENTS PASSED:
RETURN VALUE:
IMPORTANT NOTES:
================================================================================================*/
static void End_Hint(void)
{
OP_UINT16 xi,yj;
for(yj=0;yj<FRUITNEWGAME_LINE_NUM;yj++)
{
for(xi=0;xi<FRUITNEWGAME_COLUMN_NUM;xi++)
{
if((fruitnewgame_position[xi][yj] >=FRUITNEWGAME_BLUE_PUTAO)&&(fruitnewgame_position[xi][yj]<=FRUITNEWGAME_BLUE_APPLE) )
{
fruitnewgame_position[xi][yj] = fruitnewgame_position[xi][yj] -10;
DrawSquare(xi,yj , fruitnewgame_position[xi][yj]);
ds_refresh();
return;
}
}
}
}
/*==================================================================================================
FUNCTION: Eliminate_Result
DESCRIPTION:
Eliminating the fruits in line will return 1,eliminating the fruits in column will return 2,
or else 3.
ARGUMENTS PASSED:
RETURN VALUE:
IMPORTANT NOTES:
================================================================================================*/
static OP_UINT16 Eliminate_Result(OP_UINT16 elim)
{
OP_UINT16 line_del_number;
OP_UINT16 column_del_number;
OP_UINT16 nn1,nn2,nn3,nn4,i,j;
OP_UINT16 eli_xi;
OP_UINT16 eli_yj;
if(elim==0)
{
eli_xi=exchange_xi[0];
eli_yj=exchange_yj[0];
}
else if(elim==1)
{
eli_xi=exchange_xi[1];
eli_yj=exchange_yj[1];
}
if(line_blinkflag==OP_TRUE)
{
nn1=eli_xi-exch_resu[3];
nn2=eli_xi+ exch_resu[2];
line_del_number= exch_resu[2]+exch_resu[3]+1;
for(i=nn1;i<=nn2;i++)
{
fruitnewgame_position[i][eli_yj]=9;
DrawSquare(i,eli_yj,9);
}
ds_refresh();
return ELIMINATE_LINE;
}
else if(column_blinkflag==OP_TRUE)
{
nn3=eli_yj-exch_resu[1];
nn4=eli_yj+exch_resu[0];
column_del_number= exch_resu[0]+exch_resu[1]+1;
for(j=nn3;j<=nn4;j++)
{
fruitnewgame_position[eli_xi][j]=9;
DrawSquare(eli_xi,j,9);
}
ds_refresh();
return ELIMINATE_COLUMN;
}
else
return NOTELIMINATE;
}
/*==================================================================================================
FUNCTION: Init_Eliminate
DESCRIPTION:
Description of this specific function.
ARGUMENTS PASSED:
RETURN VALUE:
IMPORTANT NOTES:
================================================================================================*/
static OP_BOOLEAN Init_Eliminate(void)
{
OP_UINT8 i,j,cx,cy;
OP_UINT8 count_column;
OP_UINT8 count_line;
OP_UINT16 temp;
for(i = 0;i<FRUITNEWGAME_COLUMN_NUM+1; i++)
{
count_column=1;
temp = fruitnewgame_position[i][0];
for(j=1;j<=FRUITNEWGAME_LINE_NUM;j++)
{
if(temp==fruitnewgame_position[i][j])
{
count_column++;
}
else
{
if(count_column>=3)
{
cx=i;
cy=j;
Rearrange_Col( cx,(OP_UINT8)(cy- count_column),(OP_UINT8)(cy-1));
return OP_TRUE;
}
temp=fruitnewgame_position[i][j];
count_column=1;
}
}
}
for(j=0;j<=FRUITNEWGAME_LINE_NUM;j++)
{
count_line=1;
temp = fruitnewgame_position[0][j];
for(i = 1;i<=FRUITNEWGAME_COLUMN_NUM; i++)
{
if(temp==fruitnewgame_position[i][j])
{
count_line++;
}
else
{
if(count_line>=3)
{
cx=i;
cy=j;
Rearrange_Line( cy,(OP_UINT8)(cx-count_line), (OP_UINT8)(cx-1));
return OP_TRUE;
}
temp=fruitnewgame_position[i][j];
count_line=1;
}
}
}
return OP_FALSE;
}
/*==================================================================================================
FUNCTION: Fruit_Timer_Pen
DESCRIPTION:
Description of this specific function.
ARGUMENTS PASSED:
RETURN VALUE:
IMPORTANT NOTES:
================================================================================================*/
static void Fruit_Timer_Pen(void)
{
static OP_UINT16 waitingCount=0;
static OP_UINT16 cx=0;
static OP_UINT16 cy=0;
static OP_UINT16 fruit_count=0;
static OP_UINT16 elim_num0 = 0;
static OP_UINT16 elim_num1 = 0;
OP_UINT16 fruitnewgame_position_middle;
OP_UINT16 mm1,mm2,mm3,mm4,mm5,mm6;
switch (timer_num)
{
case 1:
if (waitingCount == 0)
{
Exchange_Find(0);
elim_num0=Eliminate_Result(0);
}
break;
case 2:
if(elim_num0==1||elim_num0==2)
{
waitingCount++;
if(waitingCount<2)
{
timer_num--;
return;
}
else
{
waitingCount=0;
if(elim_num0==1)
{
mm1=exchange_xi[0]-exch_resu[3];
mm2=exchange_xi[0]+exch_resu[2];
mm5=exchange_yj[0];
Rearrange_Line(mm5,mm1,mm2);
}
if(elim_num0==2)
{
mm3=exchange_yj[0]-exch_resu[1];
mm4=exchange_yj[0]+exch_resu[0];
mm6=exchange_xi[0];
Rearrange_Col(mm6,mm3,mm4);
}
ds_refresh();
}
}
break;
case 3:
Exchange_Find(1);
elim_num1=Eliminate_Result(1);
waitingCount=0;
if((elim_num0==3)&&(elim_num1==3))
{
fruitnewgame_position_middle=fruitnewgame_position[exchange_xi[0]][exchange_yj[0]];
fruitnewgame_position[exchange_xi[0]][exchange_yj[0]]=fruitnewgame_position[exchange_xi[1]][exchange_yj[1]];
fruitnewgame_position[exchange_xi[1]][exchange_yj[1]]=fruitnewgame_position_middle;
DrawSquare( exchange_xi[0],exchange_yj[0], fruitnewgame_position[exchange_xi[0]][exchange_yj[0]]);
DrawSquare( exchange_xi[1],exchange_yj[1], fruitnewgame_position[exchange_xi[1]][exchange_yj[1]]);
ds_refresh();
OPUS_Stop_Timer(OPUS_TIMER_GAME_PEN);
OPUS_Start_Timer(OPUS_TIMER_GAME_TIMING, interval, 0, PERIODIC);
blinkflag=OP_FALSE;
second_press_flag=OP_FALSE;
elim_num0=0;
elim_num1=0;
}
break;
case 4:
if((elim_num1==1)||(elim_num1==2))
{
waitingCount++;
if(waitingCount<2)
{
timer_num--;
return;
}
else
{
waitingCount=0;
if(elim_num1==1)
{
mm1=exchange_xi[1]-exch_resu[3];
mm2=exchange_xi[1]+exch_resu[2];
mm5=exchange_yj[1];
Rearrange_Line(mm5,mm1,mm2);
elim_num1=0;
}
else if(elim_num1==2)
{
mm3=exchange_yj[1]-exch_resu[1];
mm4=exchange_yj[1]+exch_resu[0];
mm6=exchange_xi[1];
Rearrange_Col(mm6,mm3,mm4);
elim_num1=0;
}
ds_refresh();
}
}
waitingCount = 0;
break;
case 5:
if (waitingCount == 0)
{
Whole_Find( &cx, &cy,&fruit_count);
}
if (whole_find_flag==0)
{
blinkflag=OP_FALSE;
cx=0;
cy=0;
fruit_count=0;
waitingCount = 0;
second_press_flag=OP_FALSE;
OPUS_Stop_Timer(OPUS_TIMER_GAME_PEN);
OPUS_Start_Timer(OPUS_TIMER_GAME_TIMING, interval, 0, PERIODIC);
if(End_fruitnewgame()==OP_TRUE )
{
ShowGameOver( fruitnewgame_Score);
return;
}
return;
}
if (waitingCount <2)
{
waitingCount++;
timer_num--;
return;
}
if(whole_find_flag==1)
{
mm5=cy;
mm1=cx-fruit_count;
mm2=cx-1;
Rearrange_Line(mm5,mm1,mm2);
timer_num--;
waitingCount = 0;
whole_find_flag=0;
cx=0;
cy=0;
fruit_count=0;
}
else if(whole_find_flag==2)
{
mm6=cx;
mm3=cy- fruit_count;
mm4=cy-1;
Rearrange_Col(mm6,mm3,mm4);
timer_num--;
waitingCount = 0;
whole_find_flag=0;
cx=0;
cy=0;
fruit_count=0;
}
ds_refresh();
break;
default:
timer_num = 0;
break;
}
}
/*==================================================================================================
GLOBAL FUNCTIONS
==================================================================================================*/
/*================================================================================================*/
#endif
#ifdef __cplusplus
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -