📄 games_fruit.c
字号:
/*==================================================================================================
FUNCTION: Rand_Create
DESCRIPTION:
Description of this specific function.
ARGUMENTS PASSED:
RETURN VALUE:
IMPORTANT NOTES:
================================================================================================*/
static OP_UINT16 Rand_Create(void)
{
OP_UINT16 randomnumber ;
OP_UINT16 temp_post = 7;
randomnumber=rand()%7;
if ((randomnumber >= 0)&&(randomnumber < 7))
{
temp_post = randomnumber + 1;
}
else
{
temp_post=7;
}
return temp_post ;
}
/*==================================================================================================
FUNCTION: CalculateScore
DESCRIPTION:
Description of this specific function.
ARGUMENTS PASSED:
RETURN VALUE:
IMPORTANT NOTES:
================================================================================================*/
static OP_UINT16 CalculateScore(OP_UINT16 thiscount, OP_UINT16 temp_type)
{
OP_UINT16 Calculated ;
OP_UINT16 Score_append ;
switch(temp_type)
{
case FRUITNEWGAME_GREEN_PUTAO:
Score_append=1;
break;
case FRUITNEWGAME_GREEN_YINGTAO:
Score_append=2;
break;
case FRUITNEWGAME_GREEN_JUZI:
Score_append=3;
break;
case FRUITNEWGAME_GREEN_LIZI:
Score_append=4;
break;
case FRUITNEWGAME_GREEN_XIGUA:
Score_append=5;
break;
case FRUITNEWGAME_GREEN_CHAOMEI:
Score_append=6;
break;
case FRUITNEWGAME_GREEN_APPLE:
Score_append=7;
break;
default:
Score_append=0;
}
Calculated = thiscount*thiscount+Score_append;
return Calculated;
}
/*==================================================================================================
FUNCTION: Fruitnewgame_hint
DESCRIPTION:
Return the position of the hint fruit with pointers.
ARGUMENTS PASSED:
RETURN VALUE:
IMPORTANT NOTES:
================================================================================================*/
static OP_UINT16 Fruitnewgame_hint(OP_UINT16 *hint_xi,OP_UINT16 *hint_yj)
{
OP_UINT16 temp;
OP_UINT16 i, j;
for(i = 0;i<FRUITNEWGAME_COLUMN_NUM; i++)
{
for(j=0;j<FRUITNEWGAME_LINE_NUM;j++)
{
if(((j+2)<FRUITNEWGAME_LINE_NUM)&&(fruitnewgame_position[i][j]==fruitnewgame_position[i][j+2]))
{
temp=fruitnewgame_position[i][j];
if(((j+3)<FRUITNEWGAME_LINE_NUM)&&(temp==fruitnewgame_position[i][j+3]))
{
*hint_xi=i;
*hint_yj=j;
return OP_TRUE;
}
else if(((i-1)>=0)&&((j+1)<FRUITNEWGAME_LINE_NUM)&&(temp==fruitnewgame_position[i-1][j+1]))
{
*hint_xi=i-1;
*hint_yj=j+1;
return OP_TRUE;
}
else if(((i+1)<FRUITNEWGAME_COLUMN_NUM)&&((j+1)<FRUITNEWGAME_LINE_NUM)&&(temp==fruitnewgame_position[i+1][j+1]))
{
*hint_xi=i+1;
*hint_yj=j+1;
return OP_TRUE;
}
}
if(((j+1)<FRUITNEWGAME_LINE_NUM)&&(fruitnewgame_position[i][j]==fruitnewgame_position[i][j+1]))
{
temp=fruitnewgame_position[i][j];
if(((j+3)<FRUITNEWGAME_LINE_NUM)&&(temp==fruitnewgame_position[i][j+3]))
{
*hint_xi=i;
*hint_yj=j+3;
return OP_TRUE;
}
else if(((i-1)>=0)&&((j+2)<FRUITNEWGAME_LINE_NUM)&&(temp==fruitnewgame_position[i-1][j+2]))
{
*hint_xi=i-1;
*hint_yj=j+2;
return OP_TRUE;
}
else if(((i+1)<FRUITNEWGAME_COLUMN_NUM)&&((j+2)<FRUITNEWGAME_LINE_NUM)&&(temp==fruitnewgame_position[i+1][j+2]))
{
*hint_xi=i+1;
*hint_yj=j+2;
return OP_TRUE;
}
else if(((i-1)>=0)&&((j-1)>=0)&&(temp==fruitnewgame_position[i-1][j-1]))
{
*hint_xi=i-1;
*hint_yj=j-1;
return OP_TRUE;
}
else if(((j-1)>=0)&&((i+1)<FRUITNEWGAME_COLUMN_NUM)&&(temp==fruitnewgame_position[i+1][j-1]))
{
*hint_xi=i+1;
*hint_yj=j-1;
return OP_TRUE;
}
}
else
{
temp=fruitnewgame_position[i][j+1];
}
}
}
for(j=0;j<FRUITNEWGAME_LINE_NUM;j++)
{
for(i = 0;i<FRUITNEWGAME_COLUMN_NUM; i++)
{
if(((i+2)<FRUITNEWGAME_COLUMN_NUM)&&(fruitnewgame_position[i][j]==fruitnewgame_position[i+2][j]))
{
temp=fruitnewgame_position[i][j];
if(((i+3)<FRUITNEWGAME_COLUMN_NUM)&&(temp==fruitnewgame_position[i+3][j]))
{
*hint_xi=i;
*hint_yj=j;
return OP_TRUE;
}
else if(((j-1)>=0)&&((i+1)<FRUITNEWGAME_COLUMN_NUM)&&(temp==fruitnewgame_position[i+1][j-1]))
{
*hint_xi=i+1;
*hint_yj=j-1;
return OP_TRUE;
}
else if(((i+1)<FRUITNEWGAME_COLUMN_NUM)&&((j+1)<FRUITNEWGAME_LINE_NUM)&&(temp==fruitnewgame_position[i+1][j+1]))
{
*hint_xi=i+1;
*hint_yj=j+1;
return OP_TRUE;
}
}
if(((i+1)<FRUITNEWGAME_COLUMN_NUM)&&(fruitnewgame_position[i][j]==fruitnewgame_position[i+1][j]))
{
temp=fruitnewgame_position[i][j];
if(((i+3)<FRUITNEWGAME_COLUMN_NUM)&&(temp==fruitnewgame_position[i+3][j]))
{
*hint_xi=i+3;
*hint_yj=j;
return OP_TRUE;
}
else if(((j-1)>=0)&&((i+2)<FRUITNEWGAME_COLUMN_NUM)&&(temp==fruitnewgame_position[i+2][j-1]))
{
*hint_xi=i+2;
*hint_yj=j-1;
return OP_TRUE;
}
else if(((i+2)<FRUITNEWGAME_COLUMN_NUM)&&((j+1)<FRUITNEWGAME_LINE_NUM)&&(temp==fruitnewgame_position[i+2][j+1]))
{
*hint_xi=i+2;
*hint_yj=j+1;
return OP_TRUE;
}
else if(((i-1)>=0)&&((j-1)>=0)&&(temp==fruitnewgame_position[i-1][j-1]))
{
*hint_xi=i-1;
*hint_yj=j-1;
return OP_TRUE;
}
else if(((i-1)>=0)&&((j+1)<FRUITNEWGAME_LINE_NUM)&&(temp==fruitnewgame_position[i-1][j+1]))
{
*hint_xi=i-1;
*hint_yj=j+1;
return OP_TRUE;
}
}
else
{
temp=fruitnewgame_position[i+1][j];
}
}
}
return OP_FALSE;
}
/*==================================================================================================
FUNCTION: drawDigit
DESCRIPTION:
Remain a blank for single digit,without blank for tens digit.
ARGUMENTS PASSED:
RETURN VALUE:
IMPORTANT NOTES:
================================================================================================*/
static void drawDigit(OP_INT16 wInteger,OP_UINT16 x, OP_UINT16 y)
{
OP_UINT8 buffer[8]={0};
OP_UINT8 strINT[16]={0};
if(wInteger < 10)
{
op_sprintf((char *)buffer, " %d", wInteger);
}
else
{
op_sprintf((char *)buffer, "%d", wInteger);
}
AtoU(strINT, buffer);
draw_text(AREAMASK_TEXT, x, y, LCD_MAX_X-1, strINT, FONT_SIZE_SMALL|FONT_OVERLAP, PMPT_SKEY_EMPTY, COLOR_LIGHT_VERDURE);
}
/*==================================================================================================
FUNCTION: DisplayScore
DESCRIPTION:
Description of this specific function.
ARGUMENTS PASSED:
RETURN VALUE:
IMPORTANT NOTES:
================================================================================================*/
static void DisplayScore(OP_INT16 wInteger,OP_UINT16 x, OP_UINT16 y)
{
OP_UINT8 buffer[8]={0};
OP_UINT8 strINT[16]={0};
OP_UINT16 final_score;
if(wInteger<0)
{
final_score=-wInteger;
if((final_score) < 10)
{
op_sprintf((char *)buffer, " -%d", final_score);
}
else if((final_score) < 100)
{
op_sprintf((char *)buffer, " -%d", final_score);
}
else if((final_score)<1000)
{
op_sprintf((char *)buffer, "-%d", final_score);
}
else
{
final_score=0;
ShowGameOver(final_score);
}
}
else
{
if(wInteger < 10)
{
op_sprintf((char *)buffer, " %d", wInteger);
}
else if(wInteger < 100)
{
op_sprintf((char *)buffer, " %d", wInteger);
}
else if(wInteger<1000)
{
op_sprintf((char *)buffer, " %d", wInteger);
}
else if(wInteger <10000)
{
op_sprintf((char *)buffer, "%d", wInteger);
}
else
{
wInteger=9999;
ShowGameOver(wInteger);
}
}
AtoU(strINT, buffer);
draw_text(AREAMASK_TEXT, x, y, LCD_MAX_X-1, strINT, FONT_SIZE_SMALL|FONT_OVERLAP, PMPT_SKEY_EMPTY, COLOR_LIGHT_VERDURE);
}
/*==================================================================================================
FUNCTION: End_fruitnewgame
DESCRIPTION:
Description of this specific function.
ARGUMENTS PASSED:
RETURN VALUE:
IMPORTANT NOTES:
================================================================================================*/
static OP_BOOLEAN End_fruitnewgame(void)
{
if(Fruitnewgame_hint(&st_hint_xi,&st_hint_yj)==OP_FALSE)
{
return OP_TRUE;
}
else
{
st_hint_flag = OP_TRUE;
return OP_FALSE;
}
}
/*==================================================================================================
FUNCTION: Fruit_TIMER
DESCRIPTION:
Description of this specific function.
ARGUMENTS PASSED:
RETURN VALUE:
IMPORTANT NOTES:
================================================================================================*/
static void Fruit_TIMER(void)
{
OP_UINT16 xi=0;
OP_UINT16 yj=0;
if(Fgame_state.Clearance_time>0)
{
Fgame_state.Clearance_time=Fgame_state.Clearance_time-1;
}
else if(Fgame_state.Clearance_time==0)
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -