网页资讯视频图片知道文库贴吧地图采购
进入贴吧全吧搜索

 
 
 
日一二三四五六
       
       
       
       
       
       

签到排名:今日本吧第个签到,

本吧因你更精彩,明天继续来努力!

本吧签到人数:0

一键签到
成为超级会员,使用一键签到
一键签到
本月漏签0次!
0
成为超级会员,赠送8张补签卡
如何使用?
点击日历上漏签日期,即可进行补签。
连续签到:天  累计签到:天
0
超级会员单次开通12个月以上,赠送连续签到卡3张
使用连续签到卡
08月22日漏签0天
brew吧 关注:119贴子:661
  • 看贴

  • 图片

  • 吧主推荐

  • 游戏

  • 5回复贴,共1页
<<返回brew吧
>0< 加载中...

求brew 应用--五子棋源码

  • 只看楼主
  • 收藏

  • 回复
  • llggcc3639
  • 初级粉丝
    1
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
0


  • 219.236.51.*
快试试吧,
可以对自己使用挽尊卡咯~
◆
◆
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
/*===========================================================================

FILE: five.c
===========================================================================*/


/*===============================================================================
INCLUDES AND VARIABLE DEFINITIONS
=============================================================================== */
#include "AEEModGen.h" // Module interface definitions
#include "AEEAppGen.h" // Applet interface definitions
#include "AEEShell.h" // Shell interface definitions

#include "AEEFile.h" // File interface definitions
#include "AEEDB.h" // Database interface definitions
#include "AEENet.h" // Socket interface definitions
#include "AEESound.h" // Sound Interface definitions
#include "AEETapi.h" // TAPI Interface definitions

#include "five.bid"
#include "five_res.h"
#include "five.h"

/*-------------------------------------------------------------------
Applet structure. All variables in here are reference via "pMe->"
-------------------------------------------------------------------*/
// create an applet structure that's passed around. All variables in
// here will be able to be referenced as static.
typedef struct _five {
AEEApplet a ;  // First element of this structure must be AEEApplet
 AEEDeviceInfo DeviceInfo; // always have access to the hardware device information
 IDisplay *pIDisplay; // give a standard way to access the Display interface
 IShell *pIShell; // give a standard way to access the Shell interface

//棋盘和棋子图片
 IImage  *chessBoard;
IImage  *chessBlack;
IImage  *chessWhite;
//棋盘数组,0为无,1为黑,2为白
uint32  board[BOARD_WIDTH][BOARD_HEIGHT];
//当前下子位置
int32  x;
int32  y;
//当前下子类型,1为黑,2为白
byte  chessType;

} five;

/*-------------------------------------------------------------------
Function Prototypes
-------------------------------------------------------------------*/
static boolean five_HandleEvent(five* pMe, 
 AEEEvent eCode, uint16 wParam, 
 uint32 dwParam);
boolean five_InitAppData(five* pMe);
void five_FreeAppData(five* pMe);

/*===============================================================================
FUNCTION DEFINITIONS
=============================================================================== */

/*===========================================================================
FUNCTION: AEEClsCreateInstance

DESCRIPTION
This function is invoked while the app is being loaded. All Modules must provide this 
function. Ensure to retain the same name and parameters for this function.
In here, the module must verify the ClassID and then invoke the AEEApplet_New() function
that has been provided in AEEAppGen.c. 

 After invoking AEEApplet_New(), this function can do app specific initialization. In this
 example, a generic structure is provided so that app developers need not change app specific
 initialization section every time except for a call to IDisplay_InitAppData(). 
 This is done as follows: InitAppData() is called to initialize AppletData 



2025-08-22 06:47:00
广告
不感兴趣
开通SVIP免广告
  • 219.236.51.*
快试试吧,
可以对自己使用挽尊卡咯~
◆
◆
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
 instance. It is app developers responsibility to fill-in app data initialization 
 code of InitAppData(). App developer is also responsible to release memory 
 allocated for data contained in AppletData -- this can be done in 
 IDisplay_FreeAppData().

PROTOTYPE:
 int AEEClsCreateInstance(AEECLSID ClsId,IShell * pIShell,IModule * po,void ** ppObj)

PARAMETERS:
clsID: [in]: Specifies the ClassID of the applet which is being loaded

pIShell: [in]: Contains pointer to the IShell object. 

pIModule: pin]: Contains pointer to the IModule object to the current module to which
this app belongs

ppObj: [out]: On return, *ppObj must point to a valid IApplet structure. Allocation
of memory for this structure and initializing the base data members is done by AEEApplet_New().

DEPENDENCIES
 none

RETURN VALUE
 AEE_SUCCESS: If the app needs to be loaded and if AEEApplet_New() invocation was
 successful
 EFAILED: If the app does not need to be loaded or if errors occurred in 
 AEEApplet_New(). If this function returns FALSE, the app will not be loaded.

SIDE EFFECTS
 none
===========================================================================*/
int AEEClsCreateInstance(AEECLSID ClsId, IShell *pIShell, IModule *po, void **ppObj)
{
*ppObj = NULL;

if( ClsId == AEECLSID_FIVE )
{
// Create the applet and make room for the applet structure
if( AEEApplet_New(sizeof(five),
 ClsId,
 pIShell,
 po,
 (IApplet**)ppObj,
 (AEEHANDLER)five_HandleEvent,
 (PFNFREEAPPDATA)five_FreeAppData) ) // the FreeAppData function is called after sending EVT_APP_STOP to the HandleEvent function
 
{
//Initialize applet data, this is called before sending EVT_APP_START
 // to the HandleEvent function
if(five_InitAppData((five*)*ppObj))
{
//Data initialized successfully
return(AEE_SUCCESS);
}
else
{
//Release the applet. This will free the memory allocated for the applet when
// AEEApplet_New was called.
IAPPLET_Release((IApplet*)*ppObj);
return EFAILED;
}

 } // end AEEApplet_New

 }

return(EFAILED);
}


/*===========================================================================
FUNCTION SampleAppWizard_HandleEvent

DESCRIPTION
This is the EventHandler for this app. All events to this app are handled in this
function. All APPs must supply an Event Handler.

PROTOTYPE:
boolean SampleAppWizard_HandleEvent(IApplet * pi, AEEEvent eCode, uint16 wParam, uint32 dwParam)

PARAMETERS:
pi: Pointer to the AEEApplet structure. This structure contains information specific
to this applet. It was initialized during the AEEClsCreateInstance() function.

ecode: Specifies the Event sent to this applet

 wParam, dwParam: Event specific data.

DEPENDENCIES
 none

RETURN VALUE
 TRUE: If the app has processed the event
 FALSE: If the app did not process the event

SIDE EFFECTS
 none
===========================================================================*/
//显示提示信息图片的通用方法
static void showPicRes(five* pMe,uint16 c)



  • 219.236.51.*
快试试吧,
可以对自己使用挽尊卡咯~
◆
◆
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
{
IImage* im = ISHELL_LoadResImage(pMe->a.m_pIShell,FIVE_RES_FILE,c);

AEEImageInfo ii;
IIMAGE_GetInfo(im,&ii);

IIMAGE_Draw(im,(pMe->DeviceInfo.cxScreen - ii.cx) / 2,(pMe->DeviceInfo.cyScreen - ii.cy) / 2);
IDISPLAY_Update(pMe->a.m_pIDisplay);

IIMAGE_Release(im);
}
//判断胜负
static boolean checkBoard(five* pMe)
{
boolean result;
int i,count;

//横向探索
count = 0;
for(i = -4;i<=4;i++)
{
if(pMe->x + i >= 0 && pMe->x + i <= BOARD_WIDTH - 1)
{
if(pMe->board[pMe->x + i][pMe->y] == pMe->chessType)
{
count ++;
if(count == 5)
{
return TRUE;
}
}
else
{
count = 0;
}
}
}
//纵向探索
count = 0;
for(i = -4;i<=4;i++)
{
if(pMe->y + i >= 0 && pMe->y + i <= BOARD_HEIGHT - 1)
{
if(pMe->board[pMe->x][pMe->y + i] == pMe->chessType)
{
count ++;
if(count == 5)
{
return TRUE;
}
}
else
{
count = 0;
}
}
}
//左上->右下探索
count = 0;
for(i = -4;i<=4;i++)
{
if(pMe->x + i >= 0 && pMe->x + i <= BOARD_WIDTH - 1 && pMe->y + i >= 0 && pMe->y + i <= BOARD_HEIGHT - 1)
{
if(pMe->board[pMe->x + i][pMe->y + i] == pMe->chessType)
{
count ++;
if(count == 5)
{
return TRUE;
}
}
else
{
count = 0;
}
}
}
//右上->左下探索
count = 0;
for(i = -4;i<=4;i++)
{
if(pMe->x + i >= 0 && pMe->x + i <= BOARD_WIDTH - 1 && pMe->y - i >= 0 && pMe->y - i <= BOARD_HEIGHT - 1)
{
if(pMe->board[pMe->x + i][pMe->y - i] == pMe->chessType)
{
count ++;
if(count == 5)
{
return TRUE;
}
}
else
{
count = 0;
}
}
}
return result;
}
//复位棋盘
static void iniBoard(five* pMe)
{
int i,j;
for(i = 0;i <= BOARD_WIDTH - 1;i++)
{
for(j = 0;j <= BOARD_HEIGHT - 1;j++)
{
pMe->board[i][j] = 0;
}
}
pMe->chessType = 1;
//pMe->x = BOARD_WIDTH / 2;
//pMe->y = BOARD_HEIGHT / 2;
pMe->x = 0;
pMe->y = 0;
}
//显示棋盘和棋子
static void show(five* pMe)
{
uint32 i,j;
AEERect rect;
//棋盘
IIMAGE_Draw(pMe->chessBoard,-1,0);
//棋子
for(i = 0;i <= BOARD_WIDTH - 1;i++)
{
for(j = 0;j <= BOARD_HEIGHT - 1;j++)
{
if(pMe->board[i][j] == 1)
{
IIMAGE_Draw(pMe->chessBlack,i*11,j*11);
}
else if(pMe->board[i][j] == 2)
{
IIMAGE_Draw(pMe->chessWhite,i*11,j*11);
}
}
}
//下子位置
rect.x = pMe->x*11;
rect.y = pMe->y*11;
rect.dx = 9;
rect.dy = 9;
IDISPLAY_DrawRect(pMe->a.m_pIDisplay,&rect,0,0,IDF_RECT_FRAME);
IDISPLAY_Update(pMe->a.m_pIDisplay);
}
static boolean five_HandleEvent(five* pMe, AEEEvent eCode, uint16 wParam, uint32 dwParam)
{ 

 switch (eCode) 
{
 // App is told it is starting up
 case EVT_APP_START:
{
show(pMe);
 return(TRUE);
}


 // App is told it is exiting
 case EVT_APP_STOP:
 // Add your code here...

  return(TRUE);


 // App is being suspended 
 case EVT_APP_SUSPEND:
 // Add your code here...

  return(TRUE);


 // App is being resumed
 case EVT_APP_RESUME:



  • 219.236.51.*
快试试吧,
可以对自己使用挽尊卡咯~
◆
◆
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
 // Add your code here...

  return(TRUE);


 // An SMS message has arrived for this app. Message is in the dwParam above as (char *)
 // sender simply uses this format "//BREW:ClassId:Message", example //BREW:0x00000001:Hello World
 case EVT_APP_MESSAGE:
 // Add your code here...

  return(TRUE);

 // A key was pressed. Look at the wParam above to see which key was pressed. The key
 // codes are in AEEVCodes.h. Example "AVK_1" means that the "1" key was pressed.
 case EVT_KEY:
{
switch(wParam)
{
case AVK_LEFT:
{
if(pMe->x > 0)
{
pMe->x -= 1;
show(pMe);
}
break;
}
case AVK_RIGHT:
{
if(pMe->x < BOARD_WIDTH - 1)
{
pMe->x += 1;
show(pMe);
}
break;
}
case AVK_UP:
{
if(pMe->y > 0)
{
pMe->y -= 1;
show(pMe);
}
break;
}
case AVK_DOWN:
{
if(pMe->y < BOARD_HEIGHT - 1)
{
pMe->y += 1;
show(pMe);
}
break;
}
case AVK_SELECT:
{
if(pMe->board[pMe->x][pMe->y] == 0)
{
pMe->board[pMe->x][pMe->y] = pMe->chessType;
show(pMe);
//未分出胜负
if(checkBoard(pMe) == FALSE)
{
pMe->chessType = pMe->chessType == 1?2:1;
}
//分出胜负
else
{
if(pMe->chessType == 1)
{
showPicRes(pMe,WIN_BLACK);
}
else
{
showPicRes(pMe,WIN_WHITE);
}
}
}
else
{
if(checkBoard(pMe) == TRUE)
{
iniBoard(pMe);
show(pMe);
}
}
break;
}
case AVK_CLR:
{
break;
}
}
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 five_InitAppData(five* 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;

 // Insert your code here for initializing or allocating resources...
iniBoard(pMe);

pMe->chessBoard = ISHELL_LoadResImage(pMe->a.m_pIShell,FIVE_RES_FILE,CHESSBOARD);
pMe->chessBlack = ISHELL_LoadResImage(pMe->a.m_pIShell,FIVE_RES_FILE,CHESSBLACK);
pMe->chessWhite = ISHELL_LoadResImage(pMe->a.m_pIShell,FIVE_RES_FILE,CHESSWHITE);
 // 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 five_FreeAppData(five* pMe)
{
IIMAGE_Release(pMe->chessBoard);
IIMAGE_Release(pMe->chessBlack);
IIMAGE_Release(pMe->chessWhite);
 // 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
 // }
 //

}


  • 124.78.225.*
快试试吧,
可以对自己使用挽尊卡咯~
◆
◆
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
猎头公司现招聘一个通讯/手机软件工程师;英语口语好,熟悉高通BREW平台开发,精通C/C++,工作地点上海。待遇优。感兴趣的联系我。 
邮件:it-hunter@hotmail.com


登录百度账号

扫二维码下载贴吧客户端

下载贴吧APP
看高清直播、视频!
  • 贴吧页面意见反馈
  • 违规贴吧举报反馈通道
  • 贴吧违规信息处理公示
  • 5回复贴,共1页
<<返回brew吧
分享到:
©2025 Baidu贴吧协议|隐私政策|吧主制度|意见反馈|网络谣言警示