📄 games_cargador.c
字号:
gamesApp_data.popupwin=ds_popup_message(OP_NULL, promptstr, DS_POPUP_DEFAULT_MSG_TIME);
}
else
{
current_level=select_level-1;
APP_Cargador_Init();
}
op_debug(DEBUG_LOW,"CAR:level_data_process\n");
}
/*==================================================================================================
FUNCTION: MoveTo
DESCRIPTION:
Description of this specific function.
ARGUMENTS PASSED:
RETURN VALUE:
IMPORTANT NOTES:
==================================================================================================*/
static OP_BOOLEAN MoveTo(OP_INT8 xStep,OP_INT8 yStep)
{
OP_BOOLEAN hasMoved=OP_FALSE;
OP_BOOLEAN canMove=OP_FALSE;
if(xStep<0)
state=LEFT;
else if (xStep>0)
state=RIGHT;
else if (yStep<0)
state=UP;
else if (yStep>0)
state=DOWN;
if((xStep!=0 && yStep!=0)||
(xStep==0 && yStep ==0))
return OP_FALSE;
/* to judge whether the guy can move at this direction */
if((MX+xStep)>=0 && (MX+xStep) < current_width &&
(MY+yStep)>=0 && (MY+yStep)<current_height &&
Current_Box[MY+yStep][MX+xStep]<=2)
canMove = OP_TRUE;
else if ((MX + 2*xStep)>=0 && (MX + 2*xStep) < current_width &&
(MY + 2*yStep)>=0 && (MY+ 2*yStep) < current_height &&
(Current_Box[MY+yStep][MX+xStep]+Current_Box[MY+2 * yStep][MX+2*xStep]<8
||Current_Box[MY+yStep][MX+xStep]+Current_Box[MY+2 * yStep][MX+2*xStep]==8 &&
(Current_Box[MY+2*yStep][MX+2*xStep]==2)))
canMove = OP_TRUE;
if(canMove)
{
/*if(Current_Box[MY+yStep][MX+xStep]<=2) // just walk to the new position, without pushing any box
{
Current_Box[MY+yStep][MX+xStep]+=1;
Current_Box[MY][MX]-=1;
MY+=yStep;
MX+=xStep;
hasMoved=OP_TRUE;
canRollBack=OP_TRUE;
}
else if(Current_Box[MY+yStep][MX+xStep]<=6) // push a box
{
Current_Box[MY+2*yStep][MX+2*xStep]+=4;
Current_Box[MY+yStep][MX+xStep]-=4;
Current_Box[MY+yStep][MX+xStep]+=1;
Current_Box[MY][MX]-=1;
MY+=yStep;
MX+=xStep;
hasMoved=OP_TRUE;
canRollBack=OP_TRUE;
SP_Audio_play_request(sound_list[1], gamesApp_data.volume, OP_FALSE);
} */
if(Current_Box[MY+yStep][MX+xStep]>3) // push a box
{
Current_Box[MY+2*yStep][MX+2*xStep]+=4;
Current_Box[MY+yStep][MX+xStep]-=4;
if (gamesApp_data.audio_on == OP_TRUE)
{
SP_Audio_play_request(sound_list[1], gamesApp_data.volume, OP_FALSE);
}
}
Current_Box[MY+yStep][MX+xStep]+=1;
Current_Box[MY][MX]-=1;
MY+=yStep;
MX+=xStep;
hasMoved=OP_TRUE;
canRollBack=OP_TRUE;
}
if(hasMoved)
{
RePaint();
}
else
{
switch(state)
{
case UP :
DrawSquare(MX,MY,BMP_CARGADOR_PUSHU);
break;
case RIGHT :
DrawSquare(MX,MY,BMP_CARGADOR_PUSHR);
break;
case DOWN :
DrawSquare(MX,MY,BMP_CARGADOR_PUSHD);
break;
case LEFT:
DrawSquare(MX,MY,BMP_CARGADOR_PUSHL);
break;
}
if (gamesApp_data.audio_on == OP_TRUE)
{
SP_Audio_play_request(sound_list[2], gamesApp_data.volume, OP_FALSE);
}
OPUS_Start_Timer(OPUS_TIMER_GAME_TIMING, 500, 0, PERIODIC);
}
op_debug(DEBUG_LOW,"CAR:MoveTo\n");
return hasMoved;
}
/*==================================================================================================
FUNCTION: DrawSquare
DESCRIPTION:
Description of this specific function.
ARGUMENTS PASSED:
RETURN VALUE:
IMPORTANT NOTES:
==================================================================================================*/
static void DrawSquare(OP_INT8 col,OP_INT8 row, RM_RESOURCE_ID_T bitmapid)
{
OP_INT16 x,y;
x = xoffset+col*RECTWIDTH;
y = yoffset+row*RECTHEIGHT;
ds_draw_bitmap_image_rm(x,y,bitmapid);
op_debug(DEBUG_LOW,"CAR:DrawSquare\n");
}
/*==================================================================================================
FUNCTION: RePaint
DESCRIPTION:
Description of this specific function.
ARGUMENTS PASSED:
RETURN VALUE:
IMPORTANT NOTES:
==================================================================================================*/
static void RePaint(void)
{
OP_INT8 i, j;
OP_INT16 x, y;
for(i=0;i<current_height;i++)
for(j=0;j<current_width;j++)
{
switch(Current_Box[i][j])
{
case 0:
DrawSquare(j,i,BMP_CARGADOR_FLOOR);
break;
case 3:
case 1:
switch(state)
{
case UP :
DrawSquare(MX,MY,BMP_CARGADOR_PUSHU);
break;
case RIGHT :
DrawSquare(MX,MY,BMP_CARGADOR_PUSHR);
break;
case DOWN :
DrawSquare(MX,MY,BMP_CARGADOR_PUSHD);
break;
case LEFT:
DrawSquare(MX,MY,BMP_CARGADOR_PUSHL);
break;
}
break;
case 2:
DrawSquare(j,i,BMP_CARGADOR_DEST);
break;
case 4:
DrawSquare(j,i,BMP_CARGADOR_BALL);
break;
case 6:
DrawSquare(j,i,BMP_CARGADOR_BALLOVER);
break;
case 8:
DrawSquare(j,i,BMP_CARGADOR_WALL);
break;
case 9:
DrawSquare(j,i,BMP_CARGADOR_BLANK);
break;
}
}
/*
* fill the blank area with BMP_CARGADOR_BLANK
*/
x=xoffset;
j=0;
while(x>0)
{
j--;
i = yoffset / RECTHEIGHT+ 1;
i *= -1;
while (i<rowNum)
{
DrawSquare(j,i,BMP_CARGADOR_BLANK);
DrawSquare((OP_INT8)(current_width-j-1),i,BMP_CARGADOR_BLANK);
i++;
}
x -= RECTWIDTH;
}
y=yoffset;
i=0;
while(y>0)
{
i--;
j = xoffset / RECTWIDTH+ 1;
j *= -1;
while (j<colNum)
{
DrawSquare(j, i, BMP_CARGADOR_BLANK);
DrawSquare(j, (OP_INT8)(current_height-i-1), BMP_CARGADOR_BLANK);
j++;
}
y -= RECTHEIGHT;
}
ds_refresh();
if (guy_moved_count < MAX_MOVEMENT_COUNT && gamePause == OP_FALSE)
{
OPUS_Start_Timer(OPUS_TIMER_GAME_TIMING, 500, 0, PERIODIC);
}
op_debug(DEBUG_LOW,"CAR:RePaint\n");
}
/*==================================================================================================
FUNCTION: Rollback
DESCRIPTION:
Description of this specific function.
ARGUMENTS PASSED:
RETURN VALUE:
IMPORTANT NOTES:
==================================================================================================*/
static void Rollback(void)
{
OP_UINT8 i,j;
if (canRollBack)
{
canRollBack=OP_FALSE;
MX = Old_MX;
MY = Old_MY;
state = Old_State;
for(i=0;i<current_height;i++)
for(j=0;j<current_width;j++)
Current_Box[i][j] = Old_Box[i][j];
RePaint();
}
op_debug(DEBUG_LOW,"CAR:Rollback\n");
return;
}
/*==================================================================================================
FUNCTION: ShowLevelPassed
DESCRIPTION:
Description of this specific function.
ARGUMENTS PASSED:
RETURN VALUE:
IMPORTANT NOTES:
==================================================================================================*/
static void ShowLevelPassed(void)
{
OP_UINT8 promptstr[MAX_STRING_LENGTH];
OP_UINT8 tmpstr[MAX_STRING_LENGTH];
char ss[4];
inGame=OP_FALSE;
if (gamesApp_data.audio_on == OP_TRUE)
{
SP_Audio_play_request(sound_list[3], gamesApp_data.volume, OP_FALSE);
}
op_memset((void*)promptstr, 0, MAX_STRING_LENGTH);
op_memset((void*)tmpstr, 0, MAX_STRING_LENGTH);
util_get_text_from_res_w_max_len(PMPT_TEXT_CONGRATULATION,promptstr,MAX_STRING_LENGTH);
current_level++;
if (current_level<MAX_LEVEL)
{
util_get_text_from_res_w_max_len(PMPT_TEXT_NEXT_LEVEL,tmpstr,MAX_STRING_LENGTH);
Ustrcat(promptstr,tmpstr);
op_sprintf(ss,"%d",current_level+1);
AtoU(tmpstr,(OP_UINT8 *)ss);
Ustrcat(promptstr,tmpstr);
}
else
{
current_level=0;
gamesApp_data.app.cur_state=APP_GAMES_CARGADOR_RESUME;
util_get_text_from_res_w_max_len(PMPT_TEXT_LAST_LEVEL,tmpstr,MAX_STRING_LENGTH);
Ustrcat(promptstr,tmpstr);
}
gamesApp_data.popupwin=ds_popup_message(OP_NULL, promptstr, DS_POPUP_DEFAULT_MSG_TIME);
op_debug(DEBUG_LOW,"CAR:ShowLevelPassed\n");
}
/*==================================================================================================
GLOBAL FUNCTIONS
==================================================================================================*/
/*================================================================================================*/
#endif
#ifdef __cplusplus
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -