📄 petfazenda.c
字号:
{
if(pMe->login_num+1!=4)
pMe->login_num++;
draw_login(pMe);
print(pMe,"*");
return TRUE;
}
if(pMe->pTriangle_1.y0>=140)
break;
else
set_mouse_point(pMe,0,10);
// ISHELL_SetTimer(pMe->pIShell,2000,disappear_smallpet,pMe);
if(pMe->petmenu==1)
{
draw_petmenu(pMe);
draw_bci(pMe);
draw_pettest(pMe);
draw_mouse(pMe);
}
else
draw_all(pMe);
}return TRUE;
case AVK_LEFT:
{
pMe->up=0;pMe->down=0;pMe->left=1;pMe->right=0;
if(pMe->login!=1)
return TRUE;
if(pMe->pTriangle_1.x0-10<0)
{
if(pMe->back_x>10) //判断背景边界
{
pMe->back_x-=10;
pMe->mouse_x-=10;
}
else
{
pMe->limit_left=1;
pMe->limit_right=0;
}
set_mouse_point(pMe,0,0);
}
else
{
set_mouse_point(pMe,-10,0);
pMe->mouse_x-=10;
pMe->limit_left=pMe->limit_right=0;
}
// ISHELL_SetTimer(pMe->pIShell,2000,disappear_smallpet,pMe);
if(pMe->petmenu==1)
{
draw_petmenu(pMe);
draw_bci(pMe);
draw_pettest(pMe);
draw_mouse(pMe);
}
else
draw_all(pMe);
}return TRUE;
case AVK_RIGHT:
{
pMe->up=0;pMe->down=0;pMe->left=0;pMe->right=1;
if(pMe->login!=1)
return TRUE;
if(pMe->pTriangle_1.x0+20>130)
{
if(pMe->back_x<250)
{
pMe->back_x+=10;
pMe->mouse_x+=10;
}
else
{
pMe->limit_left=0;
pMe->limit_right=1;
}
set_mouse_point(pMe,0,0);
}
else
{
set_mouse_point(pMe,10,0);
pMe->mouse_x+=10;
pMe->limit_left=pMe->limit_right=0;
}
if(pMe->petmenu==1)
{
draw_petmenu(pMe);
draw_bci(pMe);
draw_pettest(pMe);
draw_mouse(pMe);
}
else
draw_all(pMe);
}return TRUE;
case AVK_POUND:
{
//ISHELL_CancelTimer(pMe->pIShell,fly,pMe);
pMe->login=0;
pMe->login_num=1;
IDISPLAY_ClearScreen(pMe->pIDisplay);
draw_login(pMe);
print(pMe,"*");
}return TRUE;
}
}return(TRUE);
// If nothing fits up to this point then we'll just break out
default:
break;
}
return FALSE;
}
// this function is called when your application is starting up
boolean PetFazenda_InitAppData(PetFazenda* pMe)
{
// Get the device information for this handset.
// Reference all the data by looking at the pMe->DeviceInfo structure
// Check the API reference guide for all the handy device info you can get
pMe->DeviceInfo.wStructSize = sizeof(pMe->DeviceInfo);
ISHELL_GetDeviceInfo(pMe->a.m_pIShell,&pMe->DeviceInfo);
// The display and shell interfaces are always created by
// default, so we'll asign them so that you can access
// them via the standard "pMe->" without the "a."
pMe->pIDisplay = pMe->a.m_pIDisplay;
pMe->pIShell = pMe->a.m_pIShell;
pMe->pImage_back=ISHELL_LoadImage(pMe->pIShell,"back.jpg");
pMe->pImage_login=ISHELL_LoadImage(pMe->pIShell,"login.jpg");
pMe->pImage_about=ISHELL_LoadImage(pMe->pIShell,"about.jpg");
pMe->pImage_petmenu=ISHELL_LoadImage(pMe->pIShell,"bg3.jpg");
pMe->pImage_petstar1=ISHELL_LoadImage(pMe->pIShell,"onestar.jpg");
pMe->pImage_petstar2=ISHELL_LoadImage(pMe->pIShell,"twostar.jpg");
pMe->pImage_petstar3=ISHELL_LoadImage(pMe->pIShell,"threestar.jpg");
pMe->pImage_petbci=ISHELL_LoadImage(pMe->pIShell,"bigpet.bci");
pMe->pImage_petbci1=ISHELL_LoadImage(pMe->pIShell,"petbci2.bci");
pMe->pImage_petbci2=ISHELL_LoadImage(pMe->pIShell,"petbci3.bci");
pMe->pImage_petbci3=ISHELL_LoadImage(pMe->pIShell,"petbci1.bci");
pMe->pImage_smallpet=ISHELL_LoadImage(pMe->pIShell,"smallpet.bci");
pMe->back_x=172;
pMe->back_y=0;
pMe->circle.r=9;
pMe->circle.cx=50;
pMe->circle.cy=50;
pMe->login=0;
pMe->login_num=1;
pMe->left=0;
pMe->right=0;
pMe->up=0;
pMe->down=0;
pMe->pTriangle_1.x0=50;
pMe->pTriangle_1.y0=50;
pMe->pTriangle_1.x1=pMe->pTriangle_1.x0;
pMe->pTriangle_1.y1=pMe->pTriangle_1.y0+12;
pMe->pTriangle_1.x2=pMe->pTriangle_1.x0+10;
pMe->pTriangle_1.y2=pMe->pTriangle_1.y0+6;
pMe->pTriangle_2.x0=pMe->pTriangle_1.x0;
pMe->pTriangle_2.y0=pMe->pTriangle_1.y0;
pMe->pTriangle_2.x1=pMe->pTriangle_1.x0+9;
pMe->pTriangle_2.y1=pMe->pTriangle_1.y0+12;
pMe->pTriangle_2.x2=pMe->pTriangle_1.x0+5;
pMe->pTriangle_2.y2=pMe->pTriangle_1.y0+14;
pMe->circle.r=8;
pMe->limit_left=0;
pMe->limit_right=0;
pMe->mouse_x=pMe->pTriangle_1.x0+pMe->back_x;
pMe->mouse_y=pMe->pTriangle_1.y0;
pMe->red=255;
pMe->green=0;
pMe->petmenu=pMe->s=pMe->t=0;
pMe->flag1=pMe->flag2=pMe->flag=pMe->flag3=0;
pMe->e=pMe->c=pMe->h=pMe->f=100;
pMe->sp_x=60;
pMe->sp_y=135;
// Insert your code here for initializing or allocating resources...
// if there have been no failures up to this point then return success
return TRUE;
}
// this function is called when your application is exiting
void PetFazenda_FreeAppData(PetFazenda* pMe)
{
// insert your code here for freeing any resources you have allocated...
// example to use for releasing each interface:
// if ( pMe->pIMenuCtl != NULL ) // check for NULL first
// {
// IMENUCTL_Release(pMe->pIMenuCtl) // release the interface
// pMe->pIMenuCtl = NULL; // set to NULL so no problems trying to free later
// }
//
IIMAGE_Release(pMe->pImage_back);
IIMAGE_Release(pMe->pImage_login);
IIMAGE_Release(pMe->pImage_about);
IIMAGE_Release(pMe->pImage_petmenu);
IIMAGE_Release(pMe->pImage_petstar1);
IIMAGE_Release(pMe->pImage_petstar2);
IIMAGE_Release(pMe->pImage_petstar3);
IIMAGE_Release(pMe->pImage_petbci);
IIMAGE_Release(pMe->pImage_petbci1);
IIMAGE_Release(pMe->pImage_petbci2);
IIMAGE_Release(pMe->pImage_petbci3);
IIMAGE_Release(pMe->pImage_smallpet);
ISHELL_Release(pMe->pIShell);
FREE(pMe->pszBuf);
}
//游戏背景
void draw_back(PetFazenda* pMe)
{
IIMAGE_GetInfo(pMe->pImage_back,&pMe->imageInfo);
IIMAGE_SetParm(pMe->pImage_back,IPARM_ROP,AEE_RO_TRANSPARENT,0);
IIMAGE_SetOffset(pMe->pImage_back,pMe->back_x,pMe->back_y);
IIMAGE_Draw(pMe->pImage_back,0,0);
draw_smallpet(pMe);
IDISPLAY_Update(pMe->pIDisplay);
pMe->petmenu=0;
}
//登陆界面
void draw_login(PetFazenda* pMe)
{
IIMAGE_GetInfo(pMe->pImage_login,&pMe->imageInfo);
IIMAGE_SetParm(pMe->pImage_login,IPARM_ROP,AEE_RO_TRANSPARENT,0);
//IIMAGE_SetOffset(pMe->pImage_login,pMe->back_x,pMe->back_y);
IIMAGE_Draw(pMe->pImage_login,0,0);
IDISPLAY_Update(pMe->pIDisplay);
}
//About us
void draw_about(PetFazenda* pMe)
{
IIMAGE_GetInfo(pMe->pImage_about,&pMe->imageInfo);
IIMAGE_SetParm(pMe->pImage_about,IPARM_ROP,AEE_RO_TRANSPARENT,0);
//IIMAGE_SetOffset(pMe->pImage_about,pMe->back_x,pMe->back_y);
IIMAGE_Draw(pMe->pImage_about,0,0);
IDISPLAY_Update(pMe->pIDisplay);
}
//画鼠标
void draw_mouse(PetFazenda* pMe)
{
ISHELL_CreateInstance(pMe->pIShell,AEECLSID_GRAPHICS,(void **)&pMe->pIGra);
if(pMe->petmenu==1)
draw_mouse_petmenu(pMe);
else
draw_mouse_house(pMe);//判断鼠标位置是否指向房屋 指向即变色
if(pMe->limit_left||pMe->limit_right)
{
draw_mouse_circle(pMe);
return;
}
ISHELL_CreateInstance(pMe->pIShell,AEECLSID_GRAPHICS,(void **)&pMe->pIGra);
IGRAPHICS_SetColor(pMe->pIGra,pMe->green,pMe->red,0,0);
IGRAPHICS_SetFillMode(pMe->pIGra,TRUE);
IGRAPHICS_SetFillColor(pMe->pIGra,pMe->green,pMe->red,0,0);
IGRAPHICS_DrawTriangle(pMe->pIGra,&pMe->pTriangle_2);
IGRAPHICS_DrawTriangle(pMe->pIGra,&pMe->pTriangle_1);
IGRAPHICS_SetStrokeStyle(pMe->pIGra,STROKE_DOTTED);
IGRAPHICS_Update(pMe->pIGra);
IGRAPHICS_Release(pMe->pIGra);
}
/*显示游戏界面
void fly(PetFazenda* pMe)
{
draw_back(pMe);
ISHELL_SetTimer(pMe->pIShell,50,fly,pMe);
draw_mouse(pMe);
}
*/
//打印字符窜
void print(PetFazenda* pMe,char* Score)
{
AECHAR buffer[16]={0};
SPRINTF(buffer,"%s",Score);
if ((pMe->pszBuf = (AECHAR *)MALLOC(20)) == NULL)
return;
STRTOWSTR((char *)buffer, pMe->pszBuf, 20);
IDISPLAY_SetColor(pMe->pIDisplay,CLR_USER_TEXT,MAKE_RGB(255,0,0));
IDISPLAY_SetColor(pMe->pIDisplay,CLR_USER_BACKGROUND,MAKE_RGB(100,150,255));
if(pMe->login_num==1)
IDISPLAY_DrawText(pMe->pIDisplay,AEE_FONT_NORMAL,pMe->pszBuf,-1,40,82,NULL,0);
else if(pMe->login_num==2)
IDISPLAY_DrawText(pMe->pIDisplay,AEE_FONT_NORMAL,pMe->pszBuf,-1,40,102,NULL,0);
else
IDISPLAY_DrawText(pMe->pIDisplay,AEE_FONT_NORMAL,pMe->pszBuf,-1,50,122,NULL,0);
IDISPLAY_Update(pMe->pIDisplay);
FREE(pMe->pszBuf);
}
void draw_all(PetFazenda* pMe)//画背景和鼠标
{
IDISPLAY_ClearScreen(pMe->pIDisplay);
draw_back(pMe);
draw_mouse(pMe);
}
//判断鼠标位置是否指向房屋 指向即变色
void draw_mouse_house(PetFazenda* pMe)
{
if(pMe->mouse_x<=95&&pMe->pTriangle_1.y0>=80&&pMe->pTriangle_1.y0<=100)
{
pMe->select_1=1;
pMe->green=255;
pMe->red=0;
}
else if(pMe->mouse_x>=200&&pMe->mouse_x<=314&&pMe->pTriangle_1.y0>=70&&pMe->pTriangle_1.y0<=110)
{
pMe->select_2=1;
pMe->green=255;
pMe->red=0;
}
else if(pMe->mouse_x>=320&&pMe->mouse_x<=390&&pMe->pTriangle_1.y0>=78&&pMe->pTriangle_1.y0<=100)
{
pMe->select_3=1;
pMe->green=255;
pMe->red=0;
}
else if(pMe->mouse_x>=150&&pMe->mouse_x<=300&&pMe->pTriangle_1.y0>130&&pMe->pTriangle_1.y0<=160)
{
pMe->select_4=1;
pMe->green=255;
pMe->red=0;
}
else
{
pMe->select_1=pMe->select_2=pMe->select_3=pMe->select_4=0;
pMe->green=0;
pMe->red=255;
}
}
//判断鼠标位置是否指向宠物菜单的相应功能 指向即变色
void draw_mouse_petmenu(PetFazenda* pMe)
{
if(pMe->pTriangle_1.x0>=10&&pMe->pTriangle_1.x0<=35&&pMe->pTriangle_1.y0>=106&&pMe->pTriangle_1.y0<=129)
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -