📄 mmiballoon.c
字号:
/*******************************************************************************
CONDAT (UK)
********************************************************************************
This software product is the property of Condat (UK) Ltd and may not be
disclosed to any third party without the express permission of the owner.
********************************************************************************
$Project name: eg730
$Project code: BMI (6349)
$Module: Game
$File: mmiballoon.c
$Revision: 1.0
$Author: tangyan
$Date: 08/21/02
********************************************************************************
Description
This provides the main game (boxman) functionality
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
********************************************************************************/
/*******************************************************************************
History
Date Modified
08/26/02
*******************************************************************************/
/*******************************************************************************
Include files
*******************************************************************************/
#include "mfw_sys.h"
//#include "stddefs.h"
#include "custom.h"
#include "gsm.h"
//#include "vsi.h"
#include "ffs.h"
#include "p_sim.h"
#include "cus_aci.h"
#include "Rtc_Api.h"
#include "mfw_mfw.h"
#include "mfw_win.h"
#include "mfw_kbd.h"
#include "mfw_edt.h"
#include "mfw_tim.h"
#include "mfw_icn.h"
#include "mfw_mnu.h"
#include "mfw_sat.h"
#include "mfw_mnu.h"
#include "mfw_ffs.h"
#include "dspl.h"
#include "bmieastapi.h"
#include "MmiMmi.h"
#include "MmiDummy.h"
#include "MmiDialogs.h"
#include "MmiSoftkeys.h"
#include "MmiIcons.h"
#include "MmiMenu.h"
#include "gdi.h"
#include "Audio.h"
#include "MmiSounds.h"
#include "MmiBookShared.h"
#include "mmiballoon.h"
#include "MmiBlkLangDB.h"
#include "GameDisplay.h"
#include "mmigameicons.h"
#include "mmi3dframe.h"
#include "mmisettings.h"
/******************************************************************************
宏定义
********************************************************************************/
#define balloongame 121
#define CURSORSPEED 5
//对于不同的级别定时器有可能不一样
#define balloontimer1 100
#define balloontimer2 150
#define balloontimer3 200
#define balloontimeout 900
#define CURSORXMAX 120
#define CURSORYMAX 160
#define CURSORXMIN 0
#define CURSORYMIN 0
#define CURSORWIDTH 4
#define GAMESELECTY 10 //选择游戏的字符显示初始位置
#define CURSORSIZE 9
#define abs(a) ((a)>0? (a):-(a))
#define SMALLER(a,b) (((a-b)>0)?(b):(a))
#define LAGER(a,b) (((a-b)>0)?(a):(b))
#ifndef BALLOONDEBUG
#define BALLOONDEBUG 1
#endif
#undef BALLOONDEBUG
#define HELPDISPLAY 22
/*******************************************************************************
数据结构定义
*******************************************************************************/
typedef enum {
BALLOONINITIAL,
//游戏初始状态
BALLOONPLAY,
//游戏进行状态
BALLOONEXIT,
//游戏选择状态
BALLOONSCORE,
//游戏编辑状态
BALLOONSETTING,
//游戏设置状态
BALLOONHELP,
//游戏帮助状态
BALLOONWIN,
//游戏胜利状态
MAX_MENU_MODE
}Balloon_Modes;
typedef enum {
SpeedOne=1,
SpeedTwo,
SpeedThree,
SpeedFour,
SpeedFive,
SpeedSix,
SpeedSeven,
SpeedEight,
SpeedNine,
SpeedMax
}Balloon_Speed;//游戏速度级别
typedef struct{
U16 width;
U16 height;
U16 score;
} Balloon_Property;
typedef struct{
U8 balloontype; //气球的属性,总共设置了14总气球
U8 speed; //记录气球的上升速度
U8 flag; //值为1时表示这个子项需要删除
U16 xposition;
//当前气球的位置,对于rect记录左上角的位置
short yposition;
//对于圆则记录圆最上面的位置
void * balloonnext; //指向本元素的下一个元素
}BalloonItem;
typedef struct{
U8 countall;
U8 btcount[8];
}BalloonTotal;
typedef struct{
U16 ballooncount; //当前屏幕上气球的总数
U16 keycode; //当前按键的值
// BalloonItem ballooncur; //指向气球链表的当前聚焦的子项
U8 balloonspeed;
U8 hitcount[8];
U8 fireflag;
U16 score;
BalloonItem *pfirst;//指向链表的头
BalloonItem *plast;//指向链表的最后的一个元素
BalloonTotal *balloontotal;//记录每种气球出项的个数,并且记录气球的总数
} BalloonItemHeader;
typedef struct
{
T_MMI_CONTROL mmi_control; // common control parameter
T_MFW_HND win;
T_MFW_HND kbd;
T_MFW_HND bltimer;
U8 balloonTimeflag;
BalloonItemHeader *pheader;
char * pscreenbuffer;
} Balloon_Game;
/******************************************************************************
常量定义
********************************************************************************/
//球的类型,包括球的大小,球的积分
char *balloonaddresses[]={(char *)balloon16,(char *)balloon18,(char *)balloon20,(char *)balloon22,
(char *)balloon24,(char *)balloon16mul,(char *)balloon24div,(char *)balloonstop};
Balloon_Property balloonproperty[]={{8,8,9,},{9,9,7},{10,10,6},{11,11,5},
{12,12,4},{8,8,0},{12,12,0},{10,10,0}};
/**********************************************************************************************
系统回调函数声明
**********************************************************************************************/
T_MFW_HND balloon_create(MfwHnd parent);
void balloon_destroy (T_MFW_HND);
void balloon_dialog (T_MFW_HND win, USHORT event, SHORT value, void * parameter);
int balloon_kbd_cb (MfwEvt e, MfwKbd *k);
int balloon_win_cb (MfwEvt e, MfwWin *w);
int balloon_mnu_cb (MfwEvt e, MfwMnu *m);
T_MFW_HND balloon_start (T_MFW_HND win_parent,char *character);
int balloon(MfwMnu* m, MfwMnuItem* i);
int balloontimerfunc(MfwEvt e, MfwTim *bmtime);
/**********************************************************************************
函数声明
***********************************************************************************/
/***********************************************************************************
历史:
名称 添加日期
gameinterfaceshow 08/22/02
balloonheadinitial 08/22/02
addballoonitem 08/22/02
iteminitial 08/22/02
randomxpositioncreate 08/22/02
randomtypecreate 08/22/02
removeelement 08/22/02
removeallitem 08/22/02
balloonrise 08/22/02
countbaloontype 08/26/02
randcreate 08/26/02
ypositionadd 08/27/02
settimelevel 08/27/02
movecursor 08/27/02
gunshurt 08/27/02
shotinside 08/27/02
moveoutside 09/02/02
judgeoutside 09/02/02
balloondisplay 09/13/02
countscore 09/15/02
gameover 09/15/02
newgame 09/15/02
countballoontotal 09/16/02
gamelevelselect 09/18/02
drawgamelevel 09/28/02
balloonwinshow 10/11/02
gamescoresave 10/11/02
socreinitial() 10/11/02
get_freshsize() 27/11/02
clear_remain() 28/11/02
************************************************************************************/
void gameinterfaceshow(BalloonItemHeader *pheader, char* pscreenbuffer);
void balloonheadinitial(BalloonItemHeader *pheader);
void addballoonitem(BalloonItemHeader *pheader);
void iteminitial(BalloonItem *newballoon,BalloonItemHeader *pheader);
U16 randomxpositioncreate(BalloonItemHeader *pheader);
U16 randomtypecreate(BalloonItemHeader *pheader);
void removeelement(BalloonItemHeader *pheader);
void removeallitem(BalloonItemHeader *pheader);
void balloonrise(BalloonItemHeader *pheader);
void countballoontype(BalloonItemHeader *pheader);
void ypositionadd(BalloonItemHeader * pheader,char* pscreenbuffer);
U16 settimelevel(void);
void movecursor(BalloonItemHeader * pheader);
void showcursor(char *pscreenbuffer);
int gunshort(BalloonItemHeader *pheader);
int shortinside(BalloonItem *balloon);
int moveoutside(BalloonItemHeader *pheader);
int judgeoutside(BalloonItem *balloon);
void test(U8 select);
void balloondisplay(BalloonItem *tempballoon);
void countscore(BalloonItemHeader *pheader,BalloonItem *tempballoon,U8 scoreflag);
void gameover(BalloonItemHeader *pheader);
void newgame(BalloonItemHeader* pheader);
void countballoontotal(BalloonItemHeader *pheader);
void movecursorquik(BalloonItemHeader * pheader);
void mvoe_memory(BalloonItemHeader *pheader);
void cursor_resume(BalloonItemHeader *pheader, char *pscreenbuffer);
U8 get_freshsize(U16 xposition,U16 yposition,U16 height,U16 width);
void clear_remain(char *pscreenbuffer,U16 xposition,U16 yposition);
void dspl_all(BalloonItemHeader *pheader, char* pscreenbuffer);
void balloon_help(void);
void Show_Socre(BalloonItemHeader *pheader);
void Show_Hitin(BalloonItemHeader *pheader);
void Set_Bs_Btimer(BalloonItemHeader* pheader,Balloon_Speed currentlevel);
U16 getballoonymin(BalloonItemHeader * pheader);
void Balloon_Mnushow();
/**********************************************************************************
外部函数声明
***********************************************************************************/
//extern void drawcolrclaritytext(U16 left , U16 top , char* text, U32 color );
/**********************************************************************************
全局变量定义
***********************************************************************************/
extern INT8 g_norejectkeyflag;
extern ffsgamedata ffs_gamedata;
static Balloon_Modes l_mode=BALLOONINITIAL;
BalloonItem cursor={0,61,61,0,0,0};
Balloon_Speed BalloonGamelevel;
U16 lcdischange=0;
char freshwidth,freshheight;
U16 timestoped=0;
GameScore *Blloon_Score=(GameScore *)&ffs_gamedata.Blloon_ffsScore;
U32 totalscore=0;
/**********************************************************************************
系统回调函数定义
**********************************************************************************/
T_MFW_HND balloon_create (T_MFW_HND parent_window)
{
T_MFW_WIN * win;
char *balloontitle;
Balloon_Game * data;
BalloonItemHeader * pheader;
char * pscreenbuffer;
data = (Balloon_Game *)ALLOC_MEMORY (sizeof (Balloon_Game));
if(data==NULL)
return 0;
pheader=(BalloonItemHeader *)ALLOC_MEMORY(sizeof(BalloonItemHeader));
if(pheader==NULL)
{
FREE_MEMORY ((void *)data, sizeof (Balloon_Game));
return 0;
}
pscreenbuffer=(char *)ALLOC_MEMORY((CURSORSIZE*CURSORSIZE*2+2)*sizeof(char));
if(pscreenbuffer==NULL)
{
FREE_MEMORY ((void *)data, sizeof (Balloon_Game));
FREE_MEMORY ((void *)pheader, sizeof (BalloonItemHeader));
return 0;
}
data->pscreenbuffer=pscreenbuffer;
data->pheader=pheader;
// mapinfo->selcet=1;
TRACE_FUNCTION ("boxman_create()");
memset(pscreenbuffer,0xff,(CURSORSIZE*CURSORSIZE*2)*sizeof(char));
balloontitle=(char *) MmiRsrcGetText(TxtBalloongame); // get the editor title text
data->win = win_create (parent_window, 0, E_WIN_VISIBLE, (T_MFW_CB)balloon_win_cb);
if (data->win EQ 0)
return 0;
g_game_win=data->win;
data->mmi_control.dialog = (T_DIALOG_FUNC)balloon_dialog;
data->mmi_control.data = data;
win = ((T_MFW_HDR *)data->win)->data;
win->user = (void *) data;
/*
* Create any other handler
*/
data->kbd = kbd_create (data->win,KEY_ALL | KEY_MAKE,(T_MFW_CB)balloon_kbd_cb);
data->bltimer = timCreate (data->win, balloontimeout, (MfwCb)balloontimerfunc);
data->balloonTimeflag = 0;
// winShow(data->win);
return data->win;
}
/*******************************************************************************
$Function: balloon_destroy
$Description:
$Returns:
$Arguments:
*******************************************************************************/
void balloon_destroy (T_MFW_HND own_window)
{
T_MFW_WIN * win;
Balloon_Game * data;
BalloonItemHeader *pheader;
char * pscreenbuffer;
TRACE_EVENT("balloon_destroy");
if (own_window)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -