www.pudn.com > super_plane.rar > vz_sp_ui.c, change:2013-11-22,size:50356b


#ifndef VZ_SP_UI_C 
#define VZ_SP_UI_C 
#ifdef __VLCZ_SP__ 
// 
#include "vz_common_gfx.h" 
#include "vz_common_debug.h" 
#include "vz_sp_ui.h" 
#include "vz_sp_ques.h" 
#include "vz_sp_res.h" 
 
 
///////////////////////////////////// 
//define 
///////////////////////////////////// 
typedef enum 
{ 
	STR_VZ_SP_SRC = 0, 
	STR_VZ_SP_SRC_GAME_SCORE, 
	STR_VZ_SP_SRC_ENEMY_DIE, 
	STR_VZ_SP_SRC_REWARD_SCORE, 
	STR_VZ_SP_SRC_PLANE_SCORE, 
	STR_VZ_SP_SRC_MAX_SCORE, 
	STR_VZ_SP_SRC_REPLAY, 
	STR_VZ_SP_SRC_EXIT, 
	STR_VZ_SP_SRC_CONTINUE, 
	STR_VZ_SP_SRC_RESTART, 
	STR_VZ_SP_SRC_EXITGAME, 
	STR_VZ_SP_SRC_MAX 
} mmi_sp_str_id_enum; 
///////////////////////////////////// 
//global variables 
///////////////////////////////////// 
 
 
char VzSP_stat=VZSP_GAMEOVER_MENU; 
int VzSP_pause_mark=0;//菜单下标 
static BOOL vz_sp_r2lMMIFlag = FALSE; 
///////////////////////////////////// 
//menu  
///////////////////////////////////// 
stFontAttribute vx_sp_newfont = {0,0,0,SMALL_FONT,0,1}; 
stFontAttribute vx_sp_newfont1 = {0,0,0,LARGE_FONT,0,1}; 
 
double VzSP_plane_max_score=0;//记录历史最高分 
double VzSP_plane_score=0;//本次得分 
double VzSP_game_score=0;//游戏得分 
int VzSP_over_time=0;//结束延迟时间 
 
int VzSP_left_flag=0;//0正常状态1按下 
int VzSP_right_flag=0; 
int VzSP_timer=100;//刷新时间 
int VzSP_game_time=0; 
 
///////////////////////////////////// 
//global variables 
///////////////////////////////////// 
 
char *vzsp_fraction_file= "sp.sys"; 
///////////////////////////////////// 
//static variables 
///////////////////////////////////// 
static gdi_handle gdi_VzSPBackGround;// 定义层 
static gdi_handle gdi_VzSPRole;// 定义层 
gdi_handle gdi_VzSPEffect; 
static PU8 gdi_VzSP_buf_ptr=NULL; 
 
void VzSP_enemy_product(); 
void VzSP_Repaint(); 
void VzSP_ChangeState(int newState); 
void VzSP_Enter_APP_INIT(); 
void VzSP_Run(); 
void VzSP_Enter(); 
void VzSP_LayerBlt(); 
void VzSP_draw_Text(int x, int y, color c, UI_string_type str , int border , color bc); 
void VzSP_GetFilePathConnection(WCHAR* fullPath, char* file); 
int VzSP_fraction_get_set_file(void* buf, short length, char getOrSet);//getOrSet 0 get,1 set 
int VzSP_DrawTextarea(int x , int y , int x2 , int y2 , const U8 *wcontent , color c , BOOL isdisplay); 
 
///////////////////////////////////// 
//function 
///////////////////////////////////// 
 
void VzSP_GetFilePathConnection(WCHAR* fullPath, char* file) 
{ 
    char*   temp_filename=NULL; 
     
    temp_filename=(char *)VzDynamicAllocMemory(&temp_filename , 2*strlen(vz_APP_DIRECTORY)+5,1); 
    vz_AnsiiToUnicodeString(temp_filename, vz_APP_DIRECTORY); 
    VzCheckDriveAndCreateDirectory(fullPath, 1024, temp_filename, VZQQ_C_DISK); 
    VzDynamicFreeMemory((void **)&temp_filename, 1); 
    if(NULL!=file) 
        vz_pfnUnicodeStrcat((S8*)fullPath, (S8*)file); 
} 
int VzSP_fraction_get_set_file(void* buf, short length, char getOrSet)//getOrSet 0 get,1 set 
{ 
    WCHAR       fullPath[64]={0}; 
    FS_HANDLE   filehandle; 
    UINT        readLen, writeLen; 
    int         result = -1; 
    vz_MYTIME   currTime; 
    char temp_filename[64]; 
    memset(fullPath, 0, sizeof(fullPath)); 
     
    vz_AnsiiToUnicodeString(temp_filename, vzsp_fraction_file);//临时文件 
    VzSP_GetFilePathConnection(fullPath, temp_filename); 
    filehandle = vz_FS_Open(fullPath, vz_FS_READ_WRITE | vz_FS_OPEN_SHARED | vz_FS_ATTR_HIDDEN); 
    if (getOrSet == 0 && filehandle > 0)//get 
    { 
        result = vz_FS_Read(filehandle, buf, length, &readLen); 
        result += 1; 
    } 
    if (getOrSet == 1)//set 
    { 
        if (filehandle < 0) 
            filehandle = vz_FS_Open(fullPath, vz_FS_READ_WRITE | vz_FS_CREATE_ALWAYS | vz_FS_OPEN_SHARED | vz_FS_ATTR_HIDDEN); 
        result = vz_FS_Write(filehandle, buf, length, &writeLen); 
        result += 1; 
    } 
    vz_FS_Close(filehandle); 
    return result; 
} 
 
#ifdef __VLCZ_SUP_CCH__  
void VzSP_ftostr(float value, char bp[]) 
{ 
	char *str=bp; 
	int temp=0; 
	if(value<0) 
	{ 
		*str++='-'; 
		value=-value; 
	} 
	temp=(int)value; 
	if(value>=1.0) 
	{ 
		itoa((int)value, str, 10); 
		while(temp) 
		{ 
			str++; 
			temp=temp/10; 
		} 
	} 
	else 
		*str++='0'; 
	*str++='.'; 
	itoa((int)((value-(int)value)*10), str, 10); 
	*(str+1)=0; 
} 
#endif 
S8 *VzSP_GetString(U16 StringId) 
{ 
	return GetString(STR_VZ_String_baseID + StringId); 
} 
 
//画背景 
void VzSP_draw_bg() 
{ 
      vz_gui_fill_rectangle(0, 0, vzSP_width, vzSP_height, vz_gui_color(0, 0, 0));//黑色背景  
} 
 
void VzSP_drawbuf(int state) 
{ 
     
    int drawstate = 0; 
     
    if(state != -1){ 
        drawstate = state; 
    }else{ 
        drawstate = VzSP_stat; 
    } 
    vz_gdi_layer_set_active(gdi_VzSPRole);//激活gdi_VzSPRole层 
    vz_gdi_layer_clear_background(VZ_GDI_COLOR_MAGENTA);//清除 
    vz_gdi_layer_set_active(gdi_VzSPEffect); 
    vz_gdi_layer_clear_background(VZ_GDI_COLOR_MAGENTA);//清除 
 
    vz_gdi_layer_set_active(gdi_VzSPBackGround); 
 
    VzSP_draw_bg();//背景 
    switch(drawstate){ 
        case VZSP_STATE_MAIN_MENU: 
            break; 
        case VZSP_GAMEOVER_MENU: 
            break; 
    		 
    } 
 
} 
 
//画战机生命,得分和按钮 
void VzSP_draw_top() 
{ 
	int i=0; 
	char str[120]={0}; 
	char pOutbuffer[120]={0}; 
	//战机生命 
//	VzSP_gdi_DP_clip_Ext2(0, 0, VzSP_UI_w, VzSP_UI_h ,0, 0, IMG_VZ_SP_UI); 
    vz_gdi_layer_set_active(gdi_VzSPEffect);//激活gdi_VzSPRole层 
#ifdef __SP_DRAW_IMAGE_ID__ 
    VzSP_gdi_image_draw_id(0, 0, VzSP_UI_w, VzSP_UI_h, 0, 0, IMG_VZSP_UI); 
#else 
	VzSP_gdi_DP_clip_Ext(0, 0, VzSP_UI_w, VzSP_UI_h, 0, 0, UI_png,vz_GDI_IMAGE_TYPE_PNG,UI_SIZE); 
#endif 
	for(i=0; i<VzSP_plane_life; i++) 
	{ 
	//	VzSP_gdi_DP_clip_Ext2(VzSP_top_heart_x+VzSP_top_heart_dx*i, VzSP_top_heart_y, VzSP_heart_w, VzSP_heart_h ,0, 0, IMG_VZ_SP_HEART); 
#ifdef __SP_DRAW_IMAGE_ID__ 
		VzSP_gdi_image_draw_id(VzSP_top_heart_x+VzSP_top_heart_dx*i, VzSP_top_heart_y, VzSP_heart_w, VzSP_heart_h, 0, 0, IMG_VZSP_UI_HEART); 
#else 
		VzSP_gdi_DP_clip_Ext(VzSP_top_heart_x+VzSP_top_heart_dx*i, VzSP_top_heart_y, VzSP_heart_w, VzSP_heart_h, 0, 0, UI_heart_png,vz_GDI_IMAGE_TYPE_PNG,UI_HEART_SIZE); 
#endif 
	} 
	//得分 
	vz_gui_set_text_color (vz_gui_color(255,255,255)); 
       vz_gui_move_text_cursor(VzSP_top_score_x,VzSP_top_score_y); 
//	#ifdef __VLCZ_SUP_MTK__ 
       sprintf(str, "%d", VzSP_game_time/9); 
//	#endif 
  //	 ftoa((float)VzSP_game_time/10*2, str); 
  //	#ifdef __VLCZ_SUP_CCH__ 
  //	VzSP_ftostr((float)VzSP_game_time/10*2, str); 
//	#endif 
       mmi_asc_to_ucs2(pOutbuffer,str); 
	   vz_gui_set_font(&vx_sp_newfont); 
       vz_gui_print_text ((UI_string_type) pOutbuffer); 
 
	   //按钮 
	   if(VzSP_top_stop_flag==0) 
	//       VzSP_gdi_DP_clip_Ext2(VzSP_top_stop_x, 0, VzSP_stop_w, VzSP_stop_h ,0, 0, IMG_VZ_SP_STOP); 
#ifdef __SP_DRAW_IMAGE_ID__ 
			   VzSP_gdi_image_draw_id(VzSP_top_stop_x, 0, VzSP_stop_w, VzSP_stop_h, 0, 0, IMG_VZSP_STOP); 
#else 
			   VzSP_gdi_DP_clip_Ext(VzSP_top_stop_x, 0, VzSP_stop_w, VzSP_stop_h, 0, 0, UI_stop_png,vz_GDI_IMAGE_TYPE_PNG,UI_STOP_SIZE); 
#endif 
	   else if(VzSP_top_stop_flag==1) 
	//   	VzSP_gdi_DP_clip_Ext2(VzSP_top_stop_x, 0, VzSP_stop_w, VzSP_stop_h ,0, VzSP_stop_h, IMG_VZ_SP_STOP); 
#ifdef __SP_DRAW_IMAGE_ID__ 
			   VzSP_gdi_image_draw_id(VzSP_top_stop_x, 0, VzSP_stop_w, VzSP_stop_h, 0, VzSP_stop_h, IMG_VZSP_STOP); 
#else 
			   VzSP_gdi_DP_clip_Ext(VzSP_top_stop_x, 0, VzSP_stop_w, VzSP_stop_h, 0, VzSP_stop_h, UI_stop_png,vz_GDI_IMAGE_TYPE_PNG,UI_STOP_SIZE); 
#endif 
} 
 
//画战机 
void VzSP_draw_plane() 
{ 
	if(VzSP_plane_flash_time%2==1) 
		gdi_effect_alpha_blending_rect(gdi_VzSPRole , VzSP_plane_x[VzSP_plane_i],VzSP_plane_y,VzSP_plane_x[VzSP_plane_i]+VzSP_plane_w,VzSP_plane_y+VzSP_plane_h,255,0,0,0);			//半透明 
	else 	 
	//	VzSP_gdi_DP_clip_Ext2(VzSP_plane_x[VzSP_plane_i], VzSP_plane_y, VzSP_plane_w, VzSP_plane_h ,0, 0, IMG_VZ_SP_PLANE); 
#ifdef __SP_DRAW_IMAGE_ID__ 
			   VzSP_gdi_image_draw_id(VzSP_plane_x[VzSP_plane_i], VzSP_plane_y, VzSP_plane_w, VzSP_plane_h ,0, 0, IMG_VZSP_PLANE); 
#else 
			   VzSP_gdi_DP_clip_Ext(VzSP_plane_x[VzSP_plane_i], VzSP_plane_y, VzSP_plane_w, VzSP_plane_h ,0, 0, plane_png,vz_GDI_IMAGE_TYPE_PNG,PLANE_SIZE); 
#endif 
} 
 
//画战机子弹 
void VzSP_draw_plane_bullet() 
{ 
	int i=0;	 
	for(i=0; i<15; i++) 
	{ 
		if(VzSP_plane_shell[i][1]>0) 
		//	VzSP_gdi_DP_clip_Ext2(VzSP_plane_x[VzSP_plane_shell[i][0]]+(VzSP_plane_w-VzSP_shell_w)/2, VzSP_plane_shell[i][1], VzSP_shell_w, VzSP_shell_h ,0, 0, IMG_VZ_SP_SHELL); 
#ifdef __SP_DRAW_IMAGE_ID__ 
			   VzSP_gdi_image_draw_id(VzSP_plane_x[VzSP_plane_shell[i][0]]+(VzSP_plane_w-VzSP_shell_w)/2, VzSP_plane_shell[i][1], VzSP_shell_w, VzSP_shell_h ,0, 0, IMG_VZSP_SHELL); 
#else 
			   VzSP_gdi_DP_clip_Ext(VzSP_plane_x[VzSP_plane_shell[i][0]]+(VzSP_plane_w-VzSP_shell_w)/2, VzSP_plane_shell[i][1], VzSP_shell_w, VzSP_shell_h ,0, 0, shell_png,vz_GDI_IMAGE_TYPE_PNG,SHELL_SIZE); 
#endif 
	} 
} 
 
//画战机爆炸 
void VzSP_draw_plane_explore() 
{ 
	if(VzSP_plane_is_hit>0) 
	//	VzSP_gdi_DP_clip_Ext2(VzSP_plane_x[VzSP_plane_i], VzSP_plane_y, VzSP_bomb_w, VzSP_bomb_h ,0, VzSP_bomb_h*(VzSP_plane_is_hit-1), IMG_VZ_SP_BOMB); 
#ifdef __SP_DRAW_IMAGE_ID__ 
			   VzSP_gdi_image_draw_id(VzSP_plane_x[VzSP_plane_i], VzSP_plane_y, VzSP_bomb_w, VzSP_bomb_h ,0, VzSP_bomb_h*(VzSP_plane_is_hit-1), IMG_VZSP_BOMB); 
#else 
			   VzSP_gdi_DP_clip_Ext(VzSP_plane_x[VzSP_plane_i], VzSP_plane_y, VzSP_bomb_w, VzSP_bomb_h ,0, VzSP_bomb_h*(VzSP_plane_is_hit-1), bomb_png,vz_GDI_IMAGE_TYPE_PNG,BOMB_SIZE); 
#endif 
} 
 
void VzSP_draw_enemy_explore() 
{ 
	int i=0; 
	for(i=0; i<VzSP_enemy_num; i++) 
	{ 
		if(VzSP_enemy_pos[i]>0) 
		//	VzSP_gdi_DP_clip_Ext2(VzSP_enemy_x[VzSP_enemy_pos[i]-1], VzSP_enemy_y[VzSP_enemy_pos[i]-1], VzSP_bomb_w, VzSP_bomb_h ,0, VzSP_bomb_h*(VzSP_enemy_is_hit[VzSP_enemy_pos[i]-1]-1), IMG_VZ_SP_BOMB); 
#ifdef __SP_DRAW_IMAGE_ID__ 
			   VzSP_gdi_image_draw_id(VzSP_enemy_x[VzSP_enemy_pos[i]-1], VzSP_enemy_y[VzSP_enemy_pos[i]-1], VzSP_bomb_w, VzSP_bomb_h ,0, VzSP_bomb_h*(VzSP_enemy_is_hit[VzSP_enemy_pos[i]-1]-1), IMG_VZSP_BOMB); 
#else 
			   VzSP_gdi_DP_clip_Ext(VzSP_enemy_x[VzSP_enemy_pos[i]-1], VzSP_enemy_y[VzSP_enemy_pos[i]-1], VzSP_bomb_w, VzSP_bomb_h ,0, VzSP_bomb_h*(VzSP_enemy_is_hit[VzSP_enemy_pos[i]-1]-1), bomb_png,vz_GDI_IMAGE_TYPE_PNG,BOMB_SIZE); 
#endif 
	} 
} 
 
//画敌机 
void VzSP_draw_enemy() 
{ 
	int i=0; 
	for(i=0; i<VzSP_enemy_num; i++) 
	{ 
		if(VzSP_enemy_pos[i]>0&&VzSP_enemy_is_hit[VzSP_enemy_pos[i]-1]==0) 
		//	VzSP_gdi_DP_clip_Ext2(VzSP_enemy_x[VzSP_enemy_pos[i]-1], VzSP_enemy_y[VzSP_enemy_pos[i]-1], VzSP_enemy_w, VzSP_enemy_h ,0, 0, IMG_VZ_SP_ENEMY); 
#ifdef __SP_DRAW_IMAGE_ID__ 
			   VzSP_gdi_image_draw_id(VzSP_enemy_x[VzSP_enemy_pos[i]-1], VzSP_enemy_y[VzSP_enemy_pos[i]-1], VzSP_enemy_w, VzSP_enemy_h ,0, 0, IMG_VZSP_ENEMY); 
#else 
			   VzSP_gdi_DP_clip_Ext(VzSP_enemy_x[VzSP_enemy_pos[i]-1], VzSP_enemy_y[VzSP_enemy_pos[i]-1], VzSP_enemy_w, VzSP_enemy_h ,0, 0, enemy_png,vz_GDI_IMAGE_TYPE_PNG,ENEMY_SIZE); 
#endif 
	} 
} 
 
//画敌机子弹 
void VzSP_draw_enemy_bullet() 
{ 
	int i=0, j=0; 
	for(i=0; i<VzSP_enemy_num; i++) 
	{ 
		for(j=0; j<18; j++) 
		{ 
			if(VzSP_enemy_pos[i]>0&&VzSP_enemy_shell[VzSP_enemy_pos[i]-1][j]>0) 
			{ 
			//	VzSP_gdi_DP_clip_Ext2(VzSP_enemy_x[VzSP_enemy_pos[i]-1]+(VzSP_enemy_w-VzSP_shell_w)/2, VzSP_enemy_shell[VzSP_enemy_pos[i]-1][j]+VzSP_enemy_h, VzSP_shell_w, VzSP_shell_h ,0, VzSP_shell_h, IMG_VZ_SP_SHELL); 
#ifdef __SP_DRAW_IMAGE_ID__ 
			   VzSP_gdi_image_draw_id(VzSP_enemy_x[VzSP_enemy_pos[i]-1]+(VzSP_enemy_w-VzSP_shell_w)/2, VzSP_enemy_shell[VzSP_enemy_pos[i]-1][j]+VzSP_enemy_h, VzSP_shell_w, VzSP_shell_h ,0, VzSP_shell_h, IMG_VZSP_SHELL); 
#else 
			   VzSP_gdi_DP_clip_Ext(VzSP_enemy_x[VzSP_enemy_pos[i]-1]+(VzSP_enemy_w-VzSP_shell_w)/2, VzSP_enemy_shell[VzSP_enemy_pos[i]-1][j]+VzSP_enemy_h, VzSP_shell_w, VzSP_shell_h ,0, VzSP_shell_h, shell_png,vz_GDI_IMAGE_TYPE_PNG,SHELL_SIZE); 
#endif 
			} 
		} 
	} 
} 
 
//画提示界面 
void VzSP_draw_tip_screen() 
{ 
	int strs_w=0,strs_h=0; 
	U8 conn[300]={0}; 
	U8 con[256]={0x49,0x00,0x66,0x00,0x20,0x00,0x79,0x00,0x6F,0x00,0x75,0x00,0x20,0x00,0x77,0x00, 
			0x61,0x00,0x6E,0x00,0x74,0x00,0x20,0x00,0x74,0x00,0x6F,0x00,0x20,0x00,0x63,0x00, 
			0x6F,0x00,0x6E,0x00,0x74,0x00,0x69,0x00,0x6E,0x00,0x75,0x00,0x65,0x00,0x20,0x00, 
			0x74,0x00,0x6F,0x00,0x20,0x00,0x65,0x00,0x6E,0x00,0x6A,0x00,0x6F,0x00,0x79,0x00, 
			0x20,0x00,0x74,0x00,0x68,0x00,0x65,0x00,0x20,0x00,0x67,0x00,0x61,0x00,0x6D,0x00, 
			0x65,0x00,0x2C,0x00,0x20,0x00,0x79,0x00,0x6F,0x00,0x75,0x00,0x20,0x00,0x6D,0x00, 
			0x75,0x00,0x73,0x00,0x74,0x00,0x20,0x00,0x61,0x00,0x63,0x00,0x74,0x00,0x69,0x00, 
			0x76,0x00,0x61,0x00,0x74,0x00,0x65,0x00,0x20,0x00,0x69,0x00,0x74,0x00,0x2C,0x00, 
			0x20,0x00,0x63,0x00,0x6F,0x00,0x6E,0x00,0x74,0x00,0x69,0x00,0x6E,0x00,0x75,0x00, 
			0x65,0x00,0x20,0x00,0x6F,0x00,0x72,0x00,0x20,0x00,0x6E,0x00,0x6F,0x00,0x74,0x00, 
			0x3F,0x00,0x20,0x00,0x54,0x00,0x61,0x00,0x72,0x00,0x69,0x00,0x66,0x00,0x66,0x00, 
			0x3A,0x00,0x20,0x00,0x00,0x00};//If you want to continue to enjoy the game, you must activate it, continue or not? Tariff:  
	const U8 yes[]={0x59,0x00,0x45,0x00,0x53,0x00,0x00,0x00}; 
	const U8 no[]={0x4E,0x00,0x4F,0x00,0x00,0x00};   
	vz_gdi_layer_set_active(gdi_VzSPEffect); 
	vz_gui_fill_rectangle(VzSP_tip_lr, VzSP_tip_top, vzSP_width-VzSP_tip_lr, vzSP_height-VzSP_tip_bottom, vz_gui_color(54, 54,54));//黑色背景 
	vz_sp_SetGameTips((WCHAR *)con , (WCHAR *)conn); 
	   vz_gui_set_font(&vx_sp_newfont); 
	VzSP_DrawTextarea(VzSP_tip_lr+2, VzSP_tip_top+2, vzSP_width-VzSP_tip_lr, vzSP_height-VzSP_tip_bottom , conn , vz_gui_color(255, 255, 255),1); 
 
	vz_gui_fill_rectangle(0,vzSP_height - VzSP_tip_s_h , VzSP_tip_s_w , vzSP_height , vz_gui_color(54, 54,54)); 
	vz_gui_draw_rectangle(-1,vzSP_height - VzSP_tip_s_h , VzSP_tip_s_w , vzSP_height , vz_gui_color(255, 255,255)); 
        vz_Get_StringWidthHeight((U8 *) yes , (S32*)&strs_w , (S32*)&strs_h); 
	vz_gui_move_text_cursor((VzSP_tip_s_w-strs_w)/2 , vzSP_height+(VzSP_tip_s_h-strs_h)/2-VzSP_tip_s_h); 
	vz_gui_print_text((UI_string_type) yes); 
	 
	vz_gui_fill_rectangle(vzSP_width - VzSP_tip_s_w , vzSP_height - VzSP_tip_s_h , vzSP_width , vzSP_height , vz_gui_color(54, 54,54)); 
	vz_gui_draw_rectangle(vzSP_width - VzSP_tip_s_w,vzSP_height - VzSP_tip_s_h , vzSP_width , vzSP_height , vz_gui_color(255, 255,255)); 
        vz_Get_StringWidthHeight((U8 *) no , (S32*)&strs_w , (S32*)&strs_h); 
	vz_gui_move_text_cursor(vzSP_width +(VzSP_tip_s_w-strs_w)/2 -VzSP_tip_s_w , vzSP_height+(VzSP_tip_s_h-strs_h)/2-VzSP_tip_s_h); 
	vz_gui_print_text((UI_string_type) no); 
} 
//画等待界面 
void VzSP_draw_wanting_screen() 
{ 
	int strs_w=0,strs_h=0; 
	const U8 wanting[]={0x50,0x00,0x6C,0x00,0x65,0x00,0x61,0x00,0x73,0x00,0x65,0x00,0x20,0x00,0x77,0x00, \ 
0x61,0x00,0x69,0x00,0x74,0x00,0x2E,0x00,0x2E,0x00,0x2E,0x00,0x00,0x00}; 
		vz_gdi_layer_set_active(gdi_VzSPEffect); 
   		vz_gdi_layer_clear_background(VZ_GDI_COLOR_MAGENTA);//清除 
   		vz_gui_fill_rectangle(VzSP_tip_lr, VzSP_tip_top, vzSP_width-VzSP_tip_lr, vzSP_height-VzSP_tip_bottom, vz_gui_color(54, 54,54));//黑色背景 
	   vz_gui_set_font(&vx_sp_newfont); 
        vz_Get_StringWidthHeight((U8 *) wanting , (S32*)&strs_w , (S32*)&strs_h); 
	vz_gui_move_text_cursor((vzSP_width-strs_w)/2 , (vzSP_height-strs_h)/2); 
	vz_gui_print_text((UI_string_type) wanting); 
} 
 
//画暂停界面 
void VzSP_draw_pause_screen() 
{ 
	int i=0; 
	int x1=VzSP_pause_word1_x,y1=VzSP_pause_word_y;	 
	vz_gui_fill_rectangle(0, 0, vzSP_width, vzSP_height, vz_gui_color(0, 0, 0));//黑色背景 
	vz_gui_set_text_color (vz_gui_color(255,255,255)); 
	vz_gui_set_font(&vx_sp_newfont1); 
	vz_gui_move_text_cursor(VzSP_pause_word1_x,VzSP_pause_word_y); 
	vz_gui_print_text ((UI_string_type)VzSP_GetString(STR_VZ_SP_SRC_CONTINUE)); 
	vz_gui_move_text_cursor(VzSP_pause_word1_x,VzSP_pause_word_y+VzSP_pause_word_dy); 
	vz_gui_print_text ((UI_string_type)VzSP_GetString(STR_VZ_SP_SRC_RESTART)); 
	vz_gui_move_text_cursor(VzSP_pause_word1_x,VzSP_pause_word_y+VzSP_pause_word_dy*2); 
	vz_gui_print_text ((UI_string_type)VzSP_GetString(STR_VZ_SP_SRC_EXITGAME)); 
			 
 
	y1=VzSP_pause_word_y+VzSP_pause_word_dy*VzSP_pause_mark; 
	vz_gui_draw_rectangle(x1-2, y1-2, x1+VzSP_pause_word_w,y1+VzSP_pause_word_h, vz_gui_color(255,114,0)); 
} 
 
//画结束界面 
void VzSP_draw_over_screen() 
{ 
    char str1[20]={0}; 
    char pOutbuffer1[20]={0}; 
    char str2[20]={0}; 
    char pOutbuffer2[20]={0}; 
    char str3[20]={0}; 
    char pOutbuffer3[10]={0}; 
    char str4[20]={0}; 
    char pOutbuffer4[20]={0}; 
    char str5[20]={0}; 
    char pOutbuffer5[20]={0}; 
   switch(VzSP_stat) 
  { 
		case VZSP_STATE_MAIN_MENU:	 
			gdi_effect_alpha_blending_rect(gdi_VzSPBackGround , 0,0,vzSP_width,vzSP_height,0,0,0,0);          //半透明 
		break; 
		case VZSP_GAMEOVER_MENU: 
			 gdi_effect_alpha_blending_rect(gdi_VzSPBackGround , 0,0,vzSP_width,vzSP_height,180,0,0,0);          //半透明 
		break; 
   } 
    vz_gdi_layer_set_active(gdi_VzSPEffect);//激活gdi_VzBSRole层 
     vz_gdi_layer_clear_background(VZ_GDI_COLOR_MAGENTA);//清除 
 
	VzSP_plane_score=VzSP_game_score+VzSP_enemy_die_num*100; 
    if(VzSP_plane_max_score<VzSP_plane_score) 
    { 
        VzSP_plane_max_score=VzSP_plane_score; 
 
    } 
  VzSP_fraction_get_set_file(&VzSP_plane_max_score,sizeof(VzSP_plane_max_score),1);//最高分写入文件 
     
 //   VzSP_gdi_DP_clip_Ext2(VzSP_over_tck_x, VzSP_over_tck_y, VzSP_over_w, VzSP_over_h, 0, 0, IMG_VZ_SP_OVER); 
#ifdef __SP_DRAW_IMAGE_ID__ 
			   VzSP_gdi_image_draw_id(VzSP_over_tck_x, VzSP_over_tck_y, VzSP_over_w, VzSP_over_h, 0, 0, IMG_VZSP_OVER); 
#else 
			   VzSP_gdi_DP_clip_Ext(VzSP_over_tck_x, VzSP_over_tck_y, VzSP_over_w, VzSP_over_h, 0, 0, over_png,vz_GDI_IMAGE_TYPE_PNG,OVER_SIZSE); 
#endif 
#if 0//def __CRLGAME_240X320__ 
   vz_gui_set_text_color (vz_gui_color(255,255,255)); 
    vz_gui_set_font(&vx_sp_newfont1); 
    vz_gui_move_text_cursor(VzSP_over_word1_x,VzSP_over_score_y); 
    vz_gui_print_text ((UI_string_type)VzSP_GetString(STR_VZ_SP_SRC_GAME_SCORE));//游戏得分 
    sprintf(str1, "%.1f", VzSP_game_score); 
    mmi_asc_to_ucs2(pOutbuffer1,str1); 
    vz_gui_move_text_cursor(VzSP_over_word1_x+92, VzSP_over_score_y); 
    vz_gui_print_text ((UI_string_type) pOutbuffer1); 
#endif 
#if 0//def __VZGAME_176X220__ 
	vz_gui_set_text_color (vz_gui_color(255,255,255)); 
    vz_gui_move_text_cursor(VzSP_over_word2_x,VzSP_over_score_y+VzSP_over_score_dy*2); 
    vz_gui_print_text ((UI_string_type)VzSP_GetString(STR_VZ_SP_SRC_ENEMY_DIE));//炸毁敌机数 
    sprintf(str2, "%d", VzSP_enemy_die_num); 
    mmi_asc_to_ucs2(pOutbuffer2,str2); 
    vz_gui_move_text_cursor(VzSP_over_word2_x+60, VzSP_over_score_y+VzSP_over_score_dy*3); 
    vz_gui_print_text ((UI_string_type) pOutbuffer2); 
 
    vz_gui_move_text_cursor(VzSP_over_word3_x,VzSP_over_score_y+VzSP_over_score_dy*4); 
    vz_gui_print_text ((UI_string_type)VzSP_GetString(STR_VZ_SP_SRC_REWARD_SCORE));//奖励得分 
    sprintf(str3, "%d", VzSP_enemy_die_num*100); 
    mmi_asc_to_ucs2(pOutbuffer3,str3); 
    vz_gui_move_text_cursor(VzSP_over_word3_x+30, VzSP_over_score_y+VzSP_over_score_dy*5); 
    vz_gui_print_text ((UI_string_type) pOutbuffer3); 
 
    vz_gui_move_text_cursor(VzSP_over_word4_x,VzSP_over_score_y); 
    vz_gui_print_text ((UI_string_type)VzSP_GetString(STR_VZ_SP_SRC_PLANE_SCORE));//本次总分 
    #ifdef __VLCZ_SUP_MTK__ 
    sprintf(str4, "%.1f", VzSP_plane_score); 
    #endif 
    #ifdef __VLCZ_SUP_CCH__ 
    VzSP_ftostr(VzSP_plane_score, str4); 
    #endif 
    mmi_asc_to_ucs2(pOutbuffer4,str4); 
    vz_gui_move_text_cursor(VzSP_over_word4_x, VzSP_over_score_y+VzSP_over_score_dy); 
    vz_gui_print_text ((UI_string_type) pOutbuffer4); 
 
    vz_gui_set_text_color (vz_gui_color(255,114,0)); 
    vz_gui_move_text_cursor(VzSP_over_word5_x,VzSP_over_score_y+VzSP_over_score_dy*6); 
    vz_gui_print_text ((UI_string_type)VzSP_GetString(STR_VZ_SP_SRC_MAX_SCORE));//历史最高 
    #ifdef __VLCZ_SUP_MTK__ 
    sprintf(str5, "%.1f", VzSP_plane_max_score); 
    #endif 
    #ifdef __VLCZ_SUP_CCH__ 
    VzSP_ftostr(VzSP_plane_max_score, str5); 
    #endif 
    mmi_asc_to_ucs2(pOutbuffer5,str5); 
    vz_gui_move_text_cursor(VzSP_over_word5_x+30, VzSP_over_score_y+VzSP_over_score_dy*7); 
    vz_gui_print_text ((UI_string_type) pOutbuffer5); 
#endif 
#if 1//def __VZGAME_220X176__ 
	//本次总分 
	VzSP_draw_Text(VzSP_over_word_x,VzSP_over_score_y , vz_gui_color(255,255,255) , (UI_string_type)VzSP_GetString(STR_VZ_SP_SRC_PLANE_SCORE) ,0 ,vz_gui_color(0,0,0)); 
#ifdef __VLCZ_SUP_MTK__ 
	sprintf(str4, "%.1f", VzSP_plane_score); 
#endif 
#ifdef __VLCZ_SUP_CCH__ 
	VzSP_ftostr(VzSP_plane_score, str4); 
#endif 
	mmi_asc_to_ucs2(pOutbuffer4,str4); 
	VzSP_draw_Text(vzSP_width - VzSP_over_wordnum_x, VzSP_over_score_y +VzSP_over_scorenum_dy, vz_gui_color(255,255,255) , (UI_string_type)pOutbuffer4 ,0 ,vz_gui_color(0,0,0)); 
 
	//炸毁敌机数 
	VzSP_draw_Text(VzSP_over_word_x,VzSP_over_score_y+VzSP_over_score_dy*1 , vz_gui_color(255,255,255) , (UI_string_type)VzSP_GetString(STR_VZ_SP_SRC_ENEMY_DIE) ,0 ,vz_gui_color(0,0,0)); 
	sprintf(str2, "%d", VzSP_enemy_die_num); 
	mmi_asc_to_ucs2(pOutbuffer2,str2); 
	VzSP_draw_Text(vzSP_width - VzSP_over_wordnum_x,VzSP_over_score_y*1+VzSP_over_score_dy+VzSP_over_scorenum_dy , vz_gui_color(255,255,255) , (UI_string_type)pOutbuffer2 ,0 ,vz_gui_color(0,0,0)); 
 
	//奖励得分 
	VzSP_draw_Text(VzSP_over_word_x,VzSP_over_score_y+VzSP_over_score_dy*2 , vz_gui_color(255,255,255) , (UI_string_type)VzSP_GetString(STR_VZ_SP_SRC_REWARD_SCORE) ,0 ,vz_gui_color(0,0,0)); 
	sprintf(str3, "%d", VzSP_enemy_die_num*100); 
	mmi_asc_to_ucs2(pOutbuffer3,str3); 
	VzSP_draw_Text(vzSP_width - VzSP_over_wordnum_x, VzSP_over_score_y+VzSP_over_score_dy*2+VzSP_over_scorenum_dy , vz_gui_color(255,255,255) , (UI_string_type)pOutbuffer3 ,0 ,vz_gui_color(0,0,0)); 
 
	//历史最高 
	VzSP_draw_Text(VzSP_over_word_x,VzSP_over_score_y+VzSP_over_score_dy*3 , vz_gui_color(255,114,0) , (UI_string_type)VzSP_GetString(STR_VZ_SP_SRC_MAX_SCORE) ,0 ,vz_gui_color(0,0,0)); 
#ifdef __VLCZ_SUP_MTK__ 
	sprintf(str5, "%.1f", VzSP_plane_max_score); 
#endif 
#ifdef __VLCZ_SUP_CCH__ 
	VzSP_ftostr(VzSP_plane_max_score, str5); 
#endif 
	mmi_asc_to_ucs2(pOutbuffer5,str5); 
	VzSP_draw_Text(vzSP_width - VzSP_over_wordnum_x, VzSP_over_score_y+VzSP_over_score_dy*3+VzSP_over_scorenum_dy , vz_gui_color(255,114,0) , (UI_string_type)pOutbuffer5 ,0 ,vz_gui_color(0,0,0)); 
 
#endif 
    //重玩和退出按钮 
    if(0==VzSP_left_flag) 
  //  		VzSP_gdi_DP_clip_Ext2(VzSP_over_re_btn_x, VzSP_over_btn_y, VzSP_button_w, VzSP_button_h, 0, 0, IMG_VZ_SP_BUTTON); 
#ifdef __SP_DRAW_IMAGE_ID__ 
			   VzSP_gdi_image_draw_id(VzSP_over_re_btn_x, VzSP_over_btn_y, VzSP_button_w, VzSP_button_h, 0, 0, IMG_VZSP_BUTTON); 
#else 
			   VzSP_gdi_DP_clip_Ext(VzSP_over_re_btn_x, VzSP_over_btn_y, VzSP_button_w, VzSP_button_h, 0, 0, button_png,vz_GDI_IMAGE_TYPE_PNG,BUTTON_SIZE); 
#endif 
    else  
//		VzSP_gdi_DP_clip_Ext2(VzSP_over_re_btn_x, VzSP_over_btn_y, VzSP_button_w, VzSP_button_h, 0, VzSP_button_h, IMG_VZ_SP_BUTTON); 
#ifdef __SP_DRAW_IMAGE_ID__ 
			   VzSP_gdi_image_draw_id(VzSP_over_re_btn_x, VzSP_over_btn_y, VzSP_button_w, VzSP_button_h, 0, VzSP_button_h, IMG_VZSP_BUTTON); 
#else 
			   VzSP_gdi_DP_clip_Ext(VzSP_over_re_btn_x, VzSP_over_btn_y, VzSP_button_w, VzSP_button_h, 0, VzSP_button_h, button_png,vz_GDI_IMAGE_TYPE_PNG,BUTTON_SIZE); 
#endif 
    if(0==VzSP_right_flag) 
  //  	VzSP_gdi_DP_clip_Ext2(VzSP_over_btn_x, VzSP_over_btn_y, VzSP_button_w, VzSP_button_h, 0, 0, IMG_VZ_SP_BUTTON); 
#ifdef __SP_DRAW_IMAGE_ID__ 
			   VzSP_gdi_image_draw_id(VzSP_over_btn_x, VzSP_over_btn_y, VzSP_button_w, VzSP_button_h, 0, 0, IMG_VZSP_BUTTON); 
#else 
			   VzSP_gdi_DP_clip_Ext(VzSP_over_btn_x, VzSP_over_btn_y, VzSP_button_w, VzSP_button_h, 0, 0, button_png,vz_GDI_IMAGE_TYPE_PNG,BUTTON_SIZE); 
#endif 
    else 
//	VzSP_gdi_DP_clip_Ext2(VzSP_over_btn_x, VzSP_over_btn_y, VzSP_button_w, VzSP_button_h, 0,VzSP_button_h, IMG_VZ_SP_BUTTON); 
#ifdef __SP_DRAW_IMAGE_ID__ 
			   VzSP_gdi_image_draw_id(VzSP_over_btn_x, VzSP_over_btn_y, VzSP_button_w, VzSP_button_h, 0, VzSP_button_h, IMG_VZSP_BUTTON); 
#else 
			   VzSP_gdi_DP_clip_Ext(VzSP_over_btn_x, VzSP_over_btn_y, VzSP_button_w, VzSP_button_h, 0, VzSP_button_h, button_png,vz_GDI_IMAGE_TYPE_PNG,BUTTON_SIZE); 
#endif 
 
	vz_gui_set_text_color (vz_gui_color(255,255,255)); 
    vz_gui_move_text_cursor(VzSP_over_re_btn_x+VzSP_over_lx,VzSP_over_btn_y+VzSP_over_lry); 
    vz_gui_print_text ((UI_string_type)VzSP_GetString(STR_VZ_SP_SRC_REPLAY)); 
    vz_gui_move_text_cursor(VzSP_over_btn_x+VzSP_over_rx,VzSP_over_btn_y+VzSP_over_lry); 
    vz_gui_print_text ((UI_string_type)VzSP_GetString(STR_VZ_SP_SRC_EXIT));  
} 
void VzSP_enemy_bullet_hit() 
{ 
	int i=0, j=0; 
	//敌机中弹 
	for(i=0; i<VzSP_enemy_num; i++) 
	{ 
		for(j=0; j<VzSP_plane_shell_num; j++) 
		{ 
			if(VzSP_plane_shell[j][1]>0&&VzSP_enemy_pos[i]>0) 
			{ 
				if(abs(VzSP_enemy_x[VzSP_enemy_pos[i]-1]-VzSP_plane_x[VzSP_plane_shell[j][0]])<VzSP_plane_w-5&& 
					(VzSP_plane_shell[j][1]-VzSP_enemy_y[VzSP_enemy_pos[i]-1])>0&&(VzSP_plane_shell[j][1]-VzSP_enemy_y[VzSP_enemy_pos[i]-1])<VzSP_enemy_h) 
				{ 
					VzSP_plane_shell[j][1]=0; 
					VzSP_enemy_bullet[VzSP_enemy_pos[i]-1]++; 
					if(VzSP_enemy_bullet[VzSP_enemy_pos[i]-1]==3) 
					{ 
						VzSP_enemy_die_num++; 
						VzSP_enemy_is_hit[VzSP_enemy_pos[i]-1]=1; 
					//	VzSP_enemy_y[VzSP_enemy_pos[i]-1]=vzSP_height; 
						break; 
					} 
				} 
			} 
		} 
	} 
} 
 
//判断战机是否中弹或被撞击,敌机中弹 
void VzSP_plane_bullet_hit() 
{ 
	int i=0, j=0, k=0; 
	for(i=0; i<VzSP_enemy_num; i++) 
	{ 
		if(VzSP_enemy_pos[i]>0)//被撞击 
		{ 
			if(abs(VzSP_enemy_x[VzSP_enemy_pos[i]-1]-VzSP_plane_x[VzSP_plane_i])<VzSP_plane_w&& 
				VzSP_enemy_y[VzSP_enemy_pos[i]-1]<vzSP_height-VzSP_enemy_h/2&&(VzSP_enemy_y[VzSP_enemy_pos[i]-1]+VzSP_enemy_h)>VzSP_plane_y) 
			{ 
				VzSP_enemy_y[VzSP_enemy_pos[i]-1]=vzSP_height; 
				for(k=0; k<3; k++) 
					if(VzSP_enemy_pos[k]>0) 
						VzSP_enemy_y[VzSP_enemy_pos[k]-1]=vzSP_height; 
				VzSP_enemy_die_num++; 
				VzSP_plane_is_hit=1; 
				VzSP_plane_hit_flag=0; 
				if(VzSP_plane_life>0)	 
					VzSP_plane_life--; 
				return; 
			} 
		} 
	} 
	//战机中弹 
	for(i=0; i<VzSP_enemy_num; i++) 
	{ 
		for(j=0; j<18; j++) 
		{ 
			if(VzSP_enemy_pos[i]>0) 
			{ 
				if(abs(VzSP_enemy_x[VzSP_enemy_pos[i]-1]-VzSP_plane_x[VzSP_plane_i])<VzSP_plane_w-5&& 
					VzSP_enemy_shell[VzSP_enemy_pos[i]-1][j]<vzSP_height-VzSP_plane_h/2&&VzSP_enemy_shell[VzSP_enemy_pos[i]-1][j]>=VzSP_plane_y) 
				{ 
					VzSP_enemy_shell[VzSP_enemy_pos[i]-1][j]=0;//子弹消失 
					VzSP_plane_bullet++; 
					if(VzSP_plane_bullet>=4) 
					{ 
						VzSP_plane_hit_flag=0; 
						VzSP_plane_is_hit=1; 
						VzSP_plane_bullet=0; 
						if(VzSP_plane_life>0)	 
							VzSP_plane_life--; 
						return; 
					} 
				} 
			} 
		} 
	} 
	 
} 
 
void VzSP_enemy_logic(int enemy_sd, int shell_tm, int shell_sd)//敌机速度,炮弹发射时间间隔,炮弹速度 
{ 
	int i=0, j=0, k=0; 
	int rand=0; 
	//敌机移动速度 
	for(i=0; i<VzSP_enemy_num; i++) 
	{ 
		for(j=0; j<enemy_sd; j++) 
		{ 
			if(VzSP_enemy_pos[i]>0&&VzSP_enemy_is_hit[VzSP_enemy_pos[i]-1]==0) 
				VzSP_enemy_y[VzSP_enemy_pos[i]-1]++; 
			if(VzSP_enemy_y[VzSP_enemy_pos[i]-1]>=vzSP_height-VzSP_enemy_h) 
			{ 
				//	VzSP_enemy_pos[i]=0; 
				VzSP_enemy_y[VzSP_enemy_pos[i]-1]=vzSP_height; 
				break; 
			} 
		} 
		//敌机炮弹速度 
		for(k=0; k<18; k++) 
		{ 
			for(j=0; j<shell_sd; j++) 
			{ 
				if(VzSP_enemy_shell[VzSP_enemy_pos[i]-1][k]>0) 
					VzSP_enemy_shell[VzSP_enemy_pos[i]-1][k]++; 
				if(VzSP_enemy_shell[VzSP_enemy_pos[i]-1][k]>=vzSP_height) 
				{ 
					VzSP_enemy_shell[VzSP_enemy_pos[i]-1][k]=vzSP_height; 
				//	VzSP_enemy_shell[VzSP_enemy_pos[i]-1][k]=0; 
					break; 
				} 
			} 
		} 
	} 
		 
	//敌机产生子弹 
	if(VzSP_enemy_flag==1||VzSP_enshell_flag%shell_tm==0) 
	{ 
		for(i=0; i<VzSP_enemy_num; i++) 
		{ 
			srand(i); 
			rand=VzSP_RandomEvent_Random(1, 10); 
			if(VzSP_enemy_pos[i]>0&&VzSP_enemy_is_hit[VzSP_enemy_pos[i]-1]==0) 
			{ 
				if(rand>=1&&rand<=5) 
				{ 
				VzSP_enemy_shell_num[VzSP_enemy_pos[i]-1]+=1; 
				VzSP_enemy_shell[VzSP_enemy_pos[i]-1][VzSP_enemy_shell_num[VzSP_enemy_pos[i]-1]-1]=VzSP_enemy_y[VzSP_enemy_pos[i]-1]-5; 
				} 
				else if(rand>=6&&rand<=7) 
				{ 
				VzSP_enemy_shell_num[VzSP_enemy_pos[i]-1]+=2; 
				VzSP_enemy_shell[VzSP_enemy_pos[i]-1][VzSP_enemy_shell_num[VzSP_enemy_pos[i]-1]-2]=VzSP_enemy_y[VzSP_enemy_pos[i]-1]-5; 
				VzSP_enemy_shell[VzSP_enemy_pos[i]-1][VzSP_enemy_shell_num[VzSP_enemy_pos[i]-1]-1]=VzSP_enemy_y[VzSP_enemy_pos[i]-1]+10+VzSP_shell_h; 
				} 
				else if(rand>=8&&rand<=10) 
				{ 
				VzSP_enemy_shell_num[VzSP_enemy_pos[i]-1]+=3; 
				VzSP_enemy_shell[VzSP_enemy_pos[i]-1][VzSP_enemy_shell_num[VzSP_enemy_pos[i]-1]-3]=VzSP_enemy_y[VzSP_enemy_pos[i]-1]-5; 
				VzSP_enemy_shell[VzSP_enemy_pos[i]-1][VzSP_enemy_shell_num[VzSP_enemy_pos[i]-1]-2]=VzSP_enemy_y[VzSP_enemy_pos[i]-1]+10+VzSP_shell_h; 
				VzSP_enemy_shell[VzSP_enemy_pos[i]-1][VzSP_enemy_shell_num[VzSP_enemy_pos[i]-1]-1]=VzSP_enemy_y[VzSP_enemy_pos[i]-1]+25+2*VzSP_shell_h; 
				} 
				if(VzSP_enemy_shell_num[VzSP_enemy_pos[i]-1]>=14)	VzSP_enemy_shell_num[VzSP_enemy_pos[i]-1]=0; 
			} 
		} 
		VzSP_enemy_flag=0; 
	} 
	if(VzSP_enemy_flag==0) 
		VzSP_enshell_flag++; 
} 
 
// 
void VzSP_plane_logic() 
{ 
	int i=0, j=0; 
	VzSP_game_time++; 
	if(VzSP_game_time%2==0&&VzSP_plane_num<VzSP_plane_shell_num)//不断的产生子弹 
	{ 
		if(VzSP_plane_is_hit>0) 
			VzSP_plane_num=VzSP_plane_shell_num; 
		if(VzSP_plane_num<VzSP_plane_shell_num) 
		{ 
			VzSP_plane_shell[VzSP_plane_num][0]=VzSP_plane_i; 
			VzSP_plane_shell[VzSP_plane_num][1]=VzSP_plane_y-1; 
		} 
		VzSP_plane_num++; 
		if(VzSP_plane_num>=VzSP_plane_shell_num) VzSP_plane_num=0; 
	} 
	for(i=0; i<VzSP_plane_shell_num; i++) 
	{ 
		for(j=0; j<VzSP_plane_speed; j++)//战机子弹的速度 
		{ 
			if(VzSP_plane_shell[i][1]>0) 
				VzSP_plane_shell[i][1]--; 
			else 
				VzSP_plane_shell[i][1]=0; 
		} 
	} 
	//敌机 
	if(VzSP_enemy_pos[0]>0)//产生下一波敌机 
	{ 
		if(VzSP_enemy_bullet[VzSP_enemy_pos[0]-1]<3&&VzSP_enemy_y[VzSP_enemy_pos[0]-1]>=vzSP_height-VzSP_enemy_h) 
			VzSP_enemy_product(); 
		else if(VzSP_enemy_bullet[VzSP_enemy_pos[0]-1]>=3&&VzSP_enemy_num==1&&VzSP_enemy_hit_time>4) 
			VzSP_enemy_product(); 
	} 
	if(VzSP_enemy_pos[0]>0&&VzSP_enemy_pos[1]>0) 
	{ 
		if(VzSP_enemy_bullet[VzSP_enemy_pos[0]-1]>=3&&VzSP_enemy_bullet[VzSP_enemy_pos[1]-1]<3&&VzSP_enemy_y[VzSP_enemy_pos[1]-1]>=vzSP_height-VzSP_enemy_h) 
			VzSP_enemy_product(); 
		else if(VzSP_enemy_bullet[VzSP_enemy_pos[0]-1]>=3&&VzSP_enemy_bullet[VzSP_enemy_pos[1]-1]>=3&&VzSP_enemy_num==2&&VzSP_enemy_hit_time>4) 
			VzSP_enemy_product(); 
	} 
	if(VzSP_enemy_pos[0]>0&&VzSP_enemy_pos[1]>0&&VzSP_enemy_pos[2]>0) 
	{ 
		if(VzSP_enemy_bullet[VzSP_enemy_pos[0]-1]>=3&&VzSP_enemy_bullet[VzSP_enemy_pos[1]-1]>=3&&VzSP_enemy_bullet[VzSP_enemy_pos[2]-1]<3&&VzSP_enemy_y[VzSP_enemy_pos[2]-1]>=vzSP_height-VzSP_enemy_h) 
			VzSP_enemy_product(); 
		else if(VzSP_enemy_bullet[VzSP_enemy_pos[0]-1]>=3&&VzSP_enemy_bullet[VzSP_enemy_pos[1]-1]>=3&&VzSP_enemy_bullet[VzSP_enemy_pos[2]-1]>=3&&VzSP_enemy_hit_time>4) 
			VzSP_enemy_product(); 
	} 
	 
	if(VzSP_game_time<=300) 
	{ 
		VzSP_enemy_logic(VzSP_enemy_speed[0], VzSP_enemy_bullet_st[0], VzSP_enemy_bullet_sd[0]); 
	} 
	else if(VzSP_game_time>300&&VzSP_game_time<=600) 
	{ 
		VzSP_enemy_logic(VzSP_enemy_speed[1], VzSP_enemy_bullet_st[0], VzSP_enemy_bullet_sd[1]); 
	} 
	else if(VzSP_game_time>600&&VzSP_game_time<=900) 
	{ 
		VzSP_enemy_logic(VzSP_enemy_speed[2], VzSP_enemy_bullet_st[1], VzSP_enemy_bullet_sd[2]); 
	} 
	else if(VzSP_game_time>900&&VzSP_game_time<=1200) 
	{ 
		VzSP_enemy_logic(VzSP_enemy_speed[3], VzSP_enemy_bullet_st[1], VzSP_enemy_bullet_sd[3]); 
	} 
	else 
	{ 
		VzSP_enemy_logic(VzSP_enemy_speed[4], VzSP_enemy_bullet_st[1], VzSP_enemy_bullet_sd[4]); 
	} 
} 
 
/* 
*生成随机数 
*/ 
int VzSP_RandomEvent_Random(int min, int max) 
{ 
    int rnd_value = 0; 
    int rd=rand(); 
    if(min == max) 
        return min; 
    rnd_value =rd % (max - min + 1) + min; 
    //vz_debug_log_prompt(("rnd_value=%d",rnd_value)); 
    return rnd_value; 
} 
 
//产生战机 
void VzSP_plane_product() 
{ 
	VzSP_plane_bullet=0; 
	VzSP_plane_i=VzSP_RandomEvent_Random(0, 13); 
} 
 
//产生敌机,每次1-3架由4个道随机出 
void VzSP_enemy_product() 
{ 
	int i=0, j=0; 
	U32 seed; 
   	kal_get_time(&seed); 
    	srand(seed); 
	VzSP_enemy_flag=1; 
	VzSP_enshell_flag=15; 
	VzSP_enemy_hit_time=0; 
	for(i=0; i<3; i++) 
		VzSP_enemy_pos[i]=0; 
	for(i=0; i<4; i++) 
	{ 
		VzSP_enemy_bullet[i]=0; 
	} 
	for(i=0; i<4; i++) 
	{ 
		for(j=0; j<18; j++) 
		{ 
			VzSP_enemy_shell[i][j]=0; 
		} 
	} 
	VzSP_enemy_num=VzSP_RandomEvent_Random(1, 3);//产生1-3架 
	VzSP_enemy_pos[0]=VzSP_RandomEvent_Random(1, 4); 
	VzSP_enemy_x[VzSP_enemy_pos[0]-1]=(VzSP_enemy_pos[0]-1)*VzSP_enemy_rand_w+VzSP_RandomEvent_Random(0, VzSP_enemy_rand_w-VzSP_enemy_w); 
	if(VzSP_enemy_num>=2) 
		VzSP_enemy_pos[1]=VzSP_RandomEvent_Random(1, 4); 
	while(VzSP_enemy_num>=2&&(VzSP_enemy_pos[1]==VzSP_enemy_pos[0])) 
	{ 
		VzSP_enemy_pos[1]=VzSP_RandomEvent_Random(1, 4); 
	} 
	if(VzSP_enemy_num>=3) 
		VzSP_enemy_pos[2]=VzSP_RandomEvent_Random(1, 4); 
	while(VzSP_enemy_num>=3&&(VzSP_enemy_pos[2]==VzSP_enemy_pos[0]||VzSP_enemy_pos[2]==VzSP_enemy_pos[1])) 
	{ 
		VzSP_enemy_pos[2]=VzSP_RandomEvent_Random(1, 4); 
	} 
	if(VzSP_enemy_num>=2) 
		VzSP_enemy_x[VzSP_enemy_pos[1]-1]=(VzSP_enemy_pos[1]-1)*VzSP_enemy_rand_w+VzSP_RandomEvent_Random(0, VzSP_enemy_rand_w-VzSP_enemy_w); 
	if(VzSP_enemy_num>=3) 
		VzSP_enemy_x[VzSP_enemy_pos[2]-1]=(VzSP_enemy_pos[2]-1)*VzSP_enemy_rand_w+VzSP_RandomEvent_Random(0, VzSP_enemy_rand_w-VzSP_enemy_w); 
	for(i=0; i<VzSP_enemy_num; i++) 
	{ 
	if(i==0) 
		VzSP_enemy_y[VzSP_enemy_pos[i]-1]=-VzSP_enemy_h; 
	else 
		VzSP_enemy_y[VzSP_enemy_pos[i]-1]=-(VzSP_RandomEvent_Random(VzSP_enemy_h, i*VzSP_enemy_h)); 
	} 
} 
 
 
//改变状态 
void VzSP_ChangeState(int newState) 
{ 
    VzSP_stat = newState; 
    switch(newState) 
    { 
        case VZSP_STATE_MAIN_MENU: 
            break; 
    } 
    VzSP_drawbuf(-1); 
} 
 
//左软件按下 
void VzSP_left_soft_press() 
{ 
	switch(VzSP_stat) 
	{ 
		case VZSP_STATE_MAIN_MENU: 
			break; 
		case VZSP_GAMEOVER_MENU: 
			VzSP_left_flag=1; 
		break; 
	} 
} 
 
//左软件松开 
void VzSP_left_soft_up() 
{ 
				//VzSP_stat = VZSC_STATE_TIP; 
				//return; 
    switch(VzSP_stat) 
    { 
        case VZSP_GAMEOVER_MENU: 
			VzSP_left_flag=0; 
			VzSP_Enter_APP_INIT(); 
                     VzSP_ChangeState(VZSP_STATE_MAIN_MENU); 
        break; 
	case VZSC_STATE_TIP: 
		vz_sp_GameActivation(); 
		VzSP_stat = VZSC_STATE_WANTING; 
		break; 
    } 
     
} 
void VzSP_enter_soft_up() 
{ 
	switch(VzSP_stat) 
      { 
        case VZSP_STATE_MAIN_MENU: 
	 break; 
	 case VZSC_STATE_PAUSE: 
	 	if(VzSP_pause_mark==0) 
	 		VzSP_ChangeState(VZSP_STATE_MAIN_MENU); 
		else if(VzSP_pause_mark==1) 
		{ 
			VzSP_Enter_APP_INIT(); 
                     VzSP_ChangeState(VZSP_STATE_MAIN_MENU); 
		} 
		else if(VzSP_pause_mark==2) 
		{ 
		//	VzSP_ChangeState(VZSP_GAMEOVER_MENU); 
			GoBackHistory(); 
		} 
	 break; 
        case VZSP_GAMEOVER_MENU: 
        break; 
     } 
} 
void VzSP_right_soft_press() 
{ 
	switch(VzSP_stat) 
	{ 
		case VZSP_STATE_MAIN_MENU: 
			VzSP_top_stop_flag=1; 
		break; 
		case VZSP_GAMEOVER_MENU: 
			VzSP_right_flag=1; 
		break; 
	} 
} 
 
void VzSP_right_soft_up() 
{ 
    switch(VzSP_stat) 
    { 
        case VZSP_STATE_MAIN_MENU: 
			if(VzSP_top_stop_flag==1) 
			{ 
				VzSP_top_stop_flag=0; 
				VzSP_pause_mark=0; 
				VzSP_ChangeState(VZSC_STATE_PAUSE); 
			} 
	break; 
        case VZSP_GAMEOVER_MENU: 
	case VZSC_STATE_TIP: 
		VzSP_right_flag=0; 
              GoBackHistory(); 
        break; 
    }  
} 
void VzSP_up_arrow_up() 
{ 
	switch(VzSP_stat) 
      { 
        case VZSP_STATE_MAIN_MENU: 
	 break; 
	 case VZSC_STATE_PAUSE: 
	 	if(VzSP_pause_mark>0) 
	 		VzSP_pause_mark=(VzSP_pause_mark-1)%3; 
	 break; 
        case VZSP_GAMEOVER_MENU: 
        break; 
     } 
} 
void VzSP_down_arrow_up() 
{ 
	switch(VzSP_stat) 
      { 
        case VZSP_STATE_MAIN_MENU: 
	 break; 
	 case VZSC_STATE_PAUSE: 
	 	if(VzSP_pause_mark<2) 
	 		VzSP_pause_mark=(VzSP_pause_mark+1)%3; 
	 break; 
        case VZSP_GAMEOVER_MENU: 
        break; 
     } 
} 
void VzSP_left_arrow_up() 
{ 
	switch(VzSP_stat) 
      { 
        case VZSP_STATE_MAIN_MENU: 
		if(VzSP_plane_i>0&&VzSP_plane_is_hit==0) 
			{ 
			VzSP_plane_i--; 
			} 
	 break; 
        case VZSP_GAMEOVER_MENU: 
        break; 
     } 
} 
 
void VzSP_right_arrow_up() 
{ 
	switch(VzSP_stat) 
      { 
        case VZSP_STATE_MAIN_MENU: 
		if(VzSP_plane_i<13&&VzSP_plane_is_hit==0) 
			{ 
			VzSP_plane_i++; 
			} 
	 break; 
        case VZSP_GAMEOVER_MENU: 
        break; 
     } 
} 
 
void VzSP_key5_arrow_press() 
{ 
	VzSP_enter_soft_up(); 
} 
void VzSP_key4_arrow_press() 
{ 
	VzSP_left_arrow_up(); 
} 
void VzSP_key6_arrow_press() 
{ 
	VzSP_right_arrow_up(); 
} 
 
 
//按下屏幕 
void VzSP_getTouchXYDown(mmi_pen_point_struct pen_fp) 
{ 
    int x=pen_fp.x,y=pen_fp.y; 
    switch(VzSP_stat) 
	{ 
	 case VZSP_STATE_MAIN_MENU: 
	 	if(pen_fp.x>VzSP_top_stop_x&&pen_fp.x<vzSP_width&&pen_fp.y>0&&pen_fp.y<VzSP_stop_h) 
	 	{ 
	 		VzSP_top_stop_flag=1; 
	 	} 
        break; 
	case VZSP_GAMEOVER_MENU: 
		if(pen_fp.x>VzSP_over_re_btn_x&&pen_fp.x<VzSP_button_w&&pen_fp.y>(vzSP_height-VzSP_button_h)&&pen_fp.y<vzSP_height) 
		{ 
			VzSP_left_flag=1; 
		} 
		else if(pen_fp.x>(vzSP_width-VzSP_button_w)&&pen_fp.x<vzSP_width&&pen_fp.y>(vzSP_height-VzSP_button_h)&&pen_fp.y<vzSP_height) 
		{ 
			VzSP_right_flag=1; 
		} 
	break; 
		} 
} 
//松开屏幕 
void VzSP_getTouchXYUp(mmi_pen_point_struct pen_fp) 
{ 
    int x=pen_fp.x,y=pen_fp.y; 
    switch(VzSP_stat) 
    { 
    case VZSP_STATE_MAIN_MENU: 
	     if(pen_fp.x>VzSP_top_stop_x&&pen_fp.x<vzSP_width&&pen_fp.y>0&&pen_fp.y<VzSP_stop_h) 
	 	{ 
	 		if(VzSP_top_stop_flag==1) 
			{ 
				VzSP_top_stop_flag=0; 
				VzSP_pause_mark=0; 
				VzSP_ChangeState(VZSC_STATE_PAUSE); 
			} 
	 	} 
		 else if(pen_fp.x>0&&pen_fp.x<vzSP_width/2) 
		{ 
			if(VzSP_plane_i>0&&VzSP_plane_is_hit==0) 
			{ 
			VzSP_plane_i--; 
			} 
		} 
		else if(pen_fp.x>vzSP_width/2&&pen_fp.x<vzSP_width) 
		{ 
			if(VzSP_plane_i<13&&VzSP_plane_is_hit==0) 
			{ 
			VzSP_plane_i++; 
			} 
		} 
    break; 
    case VZSC_STATE_PAUSE: 
	 	if(pen_fp.x>VzSP_pause_word1_x-2&&pen_fp.x<(VzSP_pause_word1_x+VzSP_pause_word_w)&&pen_fp.y>VzSP_pause_word_y-2&&pen_fp.y<(VzSP_pause_word_y+VzSP_pause_word_h)) 
	 	{ 
	 		VzSP_pause_mark=0; 
			VzSP_ChangeState(VZSP_STATE_MAIN_MENU); 
	 	} 
		else if(pen_fp.x>VzSP_pause_word1_x-2&&pen_fp.x<(VzSP_pause_word1_x+VzSP_pause_word_w)&&pen_fp.y>(VzSP_pause_word_y-2+VzSP_pause_word_dy)&&pen_fp.y<(VzSP_pause_word_y+VzSP_pause_word_dy+VzSP_pause_word_h)) 
		{ 
			VzSP_pause_mark=1; 
			VzSP_Enter_APP_INIT(); 
                     VzSP_ChangeState(VZSP_STATE_MAIN_MENU); 
		} 
		else if(pen_fp.x>VzSP_pause_word1_x-2&&pen_fp.x<(VzSP_pause_word1_x+VzSP_pause_word_w)&&pen_fp.y>(VzSP_pause_word_y-2+VzSP_pause_word_dy*2)&&pen_fp.y<(VzSP_pause_word_y+VzSP_pause_word_dy*2+VzSP_pause_word_h)) 
		{ 
			VzSP_pause_mark=2; 
			GoBackHistory(); 
		} 
    break; 
    case VZSP_GAMEOVER_MENU: 
		if(pen_fp.x>VzSP_over_re_btn_x&&pen_fp.x<VzSP_button_w&&pen_fp.y>(vzSP_height-VzSP_button_h)&&pen_fp.y<vzSP_height) 
		{ 
			VzSP_left_flag=0; 
			VzSP_Enter_APP_INIT(); 
			VzSP_ChangeState(VZSP_STATE_MAIN_MENU); 
		} 
		else if(pen_fp.x>(vzSP_width-VzSP_button_w)&&pen_fp.x<vzSP_width&&pen_fp.y>(vzSP_height-VzSP_button_h)&&pen_fp.y<vzSP_height) 
		{ 
			VzSP_right_flag=0; 
			GoBackHistory(); 
		} 
    break; 
    } 
} 
//移动 
void VzSP_getTouchXYMove(mmi_pen_point_struct pen_fp) 
{ 
    int x=pen_fp.x,y=pen_fp.y; 
    switch(VzSP_stat) 
    { 
        case VZSP_STATE_MAIN_MENU: 
            break; 
    } 
} 
 
void VzSP_game_screen() 
{ 
	int i=0; 
	vz_gdi_layer_set_active(gdi_VzSPRole);//激活gdi_VzSPRole层 
	//vz_gdi_layer_clear_background(VZ_GDI_COLOR_MAGENTA);//清除 
	VzSP_draw_bg(); 
	if(VzSP_plane_is_hit>0) 
	{ 
		if(VzSP_plane_is_hit<13) 
			VzSP_draw_plane_explore(); 
		VzSP_plane_is_hit++; 
		if(VzSP_plane_is_hit>10&&VzSP_plane_life!=0) 
		{ 
			VzSP_plane_product(); 
			VzSP_plane_flash_time=1; 
			VzSP_plane_num=0; 
			VzSP_plane_is_hit=0; 
			VzSP_plane_hit_flag=1; 
		} 
	} 
	for(i=0; i<VzSP_enemy_num; i++) 
	{ 
		if(VzSP_enemy_pos[i]>0&&VzSP_enemy_is_hit[VzSP_enemy_pos[i]-1]>0) 
		{ 
			if(VzSP_enemy_is_hit[VzSP_enemy_pos[i]-1]<6) 
				VzSP_draw_enemy_explore();  
			VzSP_enemy_is_hit[VzSP_enemy_pos[i]-1]++; 
			if(VzSP_enemy_is_hit[VzSP_enemy_pos[i]-1]>=6) 
			{ 
				VzSP_enemy_y[VzSP_enemy_pos[i]-1]=vzSP_height; 
				VzSP_enemy_is_hit[VzSP_enemy_pos[i]-1]=0; 
			} 
		} 
	} 
	VzSP_draw_enemy_bullet(); 
	if(VzSP_plane_is_hit==0) 
	{ 
		VzSP_draw_plane(); 
		VzSP_draw_enemy(); 
	} 
	VzSP_draw_plane_bullet(); 
	VzSP_draw_top();			    
} 
extern char vz_sms_callback_value; 
void VzSP_Run() 
{ 
	vz_StartTimer(VZ_SPTIME_RUN, VzSP_timer, VzSP_Run); 
     
    switch(VzSP_stat) 
	{ 
		case VZSP_STATE_MAIN_MENU: 
			if((float)VzSP_game_time/10*2 == 30.0 && vz_sp_isActivation()==1) 
			{ 
				VzSP_stat = VZSC_STATE_TIP; 
				break; 
			} 
			VzSP_plane_logic(); 
			if(VzSP_plane_flash_time>0) 
				VzSP_plane_flash_time++; 
			if(VzSP_plane_flash_time>12) 
				VzSP_plane_flash_time=0; 
			if(VzSP_plane_hit_flag==1&&VzSP_plane_flash_time==0) 
				VzSP_plane_bullet_hit();	 
			VzSP_enemy_bullet_hit(); 
			if(VzSP_enemy_pos[0]>0&&VzSP_enemy_bullet[VzSP_enemy_pos[0]-1]>=3&&VzSP_enemy_num==1) 
				VzSP_enemy_hit_time++; 
			if(VzSP_enemy_pos[1]>0&&VzSP_enemy_bullet[VzSP_enemy_pos[0]-1]>=3&&VzSP_enemy_bullet[VzSP_enemy_pos[1]-1]>=3&&VzSP_enemy_num==2) 
				VzSP_enemy_hit_time++; 
			if(VzSP_enemy_pos[2]>0&&VzSP_enemy_bullet[VzSP_enemy_pos[0]-1]>=3&& 
				VzSP_enemy_bullet[VzSP_enemy_pos[1]-1]>=3&&VzSP_enemy_bullet[VzSP_enemy_pos[2]-1]>=3&&VzSP_enemy_num==3) 
				VzSP_enemy_hit_time++; 
			if(VzSP_plane_life==0) 
				VzSP_over_time++; 
			if(VzSP_plane_life==0&&VzSP_over_time>7||VzSP_game_time>39999) 
			{ 
				VzSP_game_score=(double)VzSP_game_time/10*2; 
				VzSP_ChangeState(VZSP_GAMEOVER_MENU); 
			} 
		break; 
		case VZSC_STATE_PAUSE: 
		break; 
		case VZSP_GAMEOVER_MENU: 
		break; 
		case VZSC_STATE_WANTING: 
			break; 
	} 
	VzSP_Repaint();  
} 
void VzSP_Repaint() 
{ 
	switch(VzSP_stat) 
		{ 
			case VZSP_STATE_MAIN_MENU:	 
			//	VzSP_draw_over_screen(); 
				VzSP_game_screen(); 
			break; 
			case VZSC_STATE_PAUSE: 
				VzSP_draw_pause_screen(); 
			break; 
			case VZSP_GAMEOVER_MENU: 
				VzSP_draw_over_screen(); 
			break; 
			case VZSC_STATE_TIP: 
				VzSP_draw_tip_screen(); 
				break; 
			case VZSC_STATE_WANTING: 
				VzSP_draw_wanting_screen(); 
				if(vz_sms_callback_value == 1) 
				{ 
					vz_sms_callback_value=-1; 
				vz_gdi_layer_set_active(gdi_VzSPEffect); 
		   		vz_gdi_layer_clear_background(VZ_GDI_COLOR_MAGENTA);//清除 
					VzSP_stat = VZSP_STATE_MAIN_MENU; 
				} 
				else if(vz_sms_callback_value == 0) 
				{	 
					vz_sms_callback_value=-1; 
				vz_gdi_layer_set_active(gdi_VzSPEffect); 
		   		vz_gdi_layer_clear_background(VZ_GDI_COLOR_MAGENTA);//清除 
					VzSP_stat = VZSC_STATE_TIP; 
				} 
				break; 
		} 
	VzSP_LayerBlt();//合并层 
} 
 
 
void VzSP_LayerBlt() 
{ 
    // 显示 
    gdi_layer_blt(  gdi_VzSPBackGround, /* layer 0 */ 
       gdi_VzSPRole,   /* layer 1 */ 
         gdi_VzSPEffect,                     					/* layer 2 */ 
        0,                  						/* layer 3 */ 
        0,                      					/* offset x */ 
        0,                      					/* offset y */ 
        vzSP_width,           		/* widht */ 
        vzSP_height);             /* height */ 
    //vz_gdi_layer_set_active(gdi_VzSPRole); 
} 
void VzSP_Exit() 
{ 
    int i=0; 
     
    if(gdi_VzSPRole != NULL){ 
        gdi_layer_free(gdi_VzSPRole); 
        gdi_VzSPRole = NULL; 
    } 
     
    if(gdi_VzSPEffect != NULL){ 
            gdi_layer_free(gdi_VzSPEffect); 
            gdi_VzSPEffect = NULL; 
    	} 
        if(NULL != gdi_VzSP_buf_ptr) 
    	{ 
            VzDynamicFreeMemory((void **)&gdi_VzSP_buf_ptr , 1); 
            gdi_VzSP_buf_ptr = NULL; 
    	} 
    vz_StopTimer(VZ_SPTIME_RUN); 
    vz_gdi_layer_set_active(gdi_VzSPBackGround); 
	 
	if(vz_sp_r2lMMIFlag) 
	{ 
		vz_sp_r2lMMIFlag = FALSE; 
		r2lMMIFlag = TRUE; 
	} 
} 
 
void VzSP_Enter_APP() 
{ 
	if(r2lMMIFlag) 
	{ 
		vz_sp_r2lMMIFlag = TRUE; 
		r2lMMIFlag = FALSE; 
	} 
 
    vz_EntryNewScreen(VZ_SP_SCREEN_ID,VzSP_Exit , VzSP_Enter_APP , NULL); 
    vz_SetKeyHandler(VzSP_left_soft_press,vz_KEY_LSK,vz_KEY_EVENT_DOWN); 
    vz_SetKeyHandler(VzSP_left_soft_up,vz_KEY_LSK,vz_KEY_EVENT_UP); 
    vz_SetKeyHandler(VzSP_enter_soft_up,vz_KEY_ENTER,vz_KEY_EVENT_UP); 
    vz_SetKeyHandler(VzSP_right_soft_press,vz_KEY_RSK,vz_KEY_EVENT_DOWN); 
    vz_SetKeyHandler(VzSP_right_soft_up,vz_KEY_RSK,vz_KEY_EVENT_UP); 
   vz_SetKeyHandler(VzSP_down_arrow_up,vz_KEY_DOWN_ARROW,vz_KEY_EVENT_UP); 
    vz_SetKeyHandler(VzSP_right_arrow_up,vz_KEY_RIGHT_ARROW,vz_KEY_EVENT_UP); 
	vz_SetKeyHandler(VzSP_left_arrow_up,vz_KEY_LEFT_ARROW,vz_KEY_EVENT_UP); 
    vz_SetKeyHandler(VzSP_up_arrow_up,vz_KEY_UP_ARROW,vz_KEY_EVENT_UP); 
    vz_SetKeyHandler(VzSP_key5_arrow_press,vz_KEY_5,vz_KEY_EVENT_UP); 
    vz_SetKeyHandler(VzSP_key4_arrow_press,vz_KEY_4,vz_KEY_EVENT_UP); 
    vz_SetKeyHandler(VzSP_key6_arrow_press,vz_KEY_6,vz_KEY_EVENT_UP); 
   
 
     
    //注册触屏开始 
    Vz_mmi_pen_init(); 
    Vz_mmi_pen_enable(); 
    Vz_mmi_pen_register_down_handler(VzSP_getTouchXYDown); 
    Vz_mmi_pen_register_up_handler(VzSP_getTouchXYUp); 
    Vz_mmi_pen_register_move_handler(VzSP_getTouchXYMove); 
    
    //注册触屏结束 
     
        /* init key's state */ 
    //vz_gdi_layer_multi_layer_enable(); 
    vz_gdi_layer_get_base_handle(&gdi_VzSPBackGround); 
    vz_gdi_layer_create(0, 0, vzSP_width, vzSP_height, &gdi_VzSPRole); 
    vz_gdi_layer_set_active(gdi_VzSPRole); 
    vz_gdi_layer_set_source_key(TRUE, VZ_GDI_COLOR_MAGENTA);        /* set pure-blue as the transparent color in gdi_VzSPRole */ 
    vz_gdi_layer_clear_background(VZ_GDI_COLOR_MAGENTA);            /* clean  layer */ 
    //vz_gdi_layer_clear_background(VZ_GDI_COLOR_MAGENTA);          /* clean  layer */ 
    //vz_gdi_layer_set_active(gdi_VzQQBackGround); 
     gdi_VzSP_buf_ptr = (PU8)VzDynamicAllocMemory(&gdi_VzSP_buf_ptr , GDI_LCD_WIDTH*GDI_LCD_HEIGHT*2 , 1); 
     if (gdi_VzSP_buf_ptr == NULL) 
     { 
        return; 
     } 
     vz_gdi_layer_create_using_outside_memory( 
           0, 
           0, 
           vzSP_width, 
           vzSP_height, 
           &gdi_VzSPEffect, 
           (PU8) gdi_VzSP_buf_ptr, 
           (S32) vzSP_width*vzSP_height*2); 
    vz_gdi_layer_set_active(gdi_VzSPEffect); 
    vz_gdi_layer_set_source_key(TRUE, VZ_GDI_COLOR_MAGENTA);        /* set pure-blue as the transparent color in CrlBookRole */ 
    vz_gdi_layer_clear_background(VZ_GDI_COLOR_MAGENTA);            /* clean  layer */ 
 
    VzSP_ChangeState(VZSP_STATE_MAIN_MENU);//VZSP_STATE_MAIN_MENU VZSP_GAMEOVER_MENU 
    VzSP_Run(); 
     
} 
 
void VzSP_draw_Text(int x, int y, color c, UI_string_type str , int border , color bc) 
{ 
    vz_gui_set_text_color(c); 
    vz_gui_move_text_cursor(x, y);	 
    if(border ==0) 
    { 
        vz_gui_print_text(str); 
    } 
    else 
    { 
        vz_gui_set_text_border_color(bc); 
        vz_gui_print_bordered_text(str); 
    } 
} 
 
int VzSP_DrawTextarea(int x , int y , int x2 , int y2 , const U8 *wcontent , color c , BOOL isdisplay) 
{ 
    int row = 1 , index = 0; 
    int strs_w = 0,strs_h = 0 , str_maxw = 0 , str_maxh = 0; 
    int px = x , py = y; 
    int wc_len = vz_pfnUnicodeStrlen((const S8 *)wcontent)*2; 
    U8 one[4] = {0}; 
    one[0]=0xFD; one[1]=0x56; 
    vz_Get_StringWidthHeight((U8 *) one , (S32*)&str_maxw , (S32*)&str_maxh);//一个汉字宽高 
    //str_maxw =20;str_maxh=20;//手动设置汉字宽度 
    while(index < wc_len) 
    { 
        one[0] = wcontent[index];one[1]=wcontent[index+1];  
        vz_Get_StringWidthHeight((U8 *) one , (S32*)&strs_w , (S32*)&strs_h); 
        //strs_w =20;strs_h=20;//手动设置汉字宽度 
        if(py > y2 - strs_h) 
    	{ 
            break; 
    	} 
        if(one[0] == 10&&one[1] == 0) 
    	{ 
            	row++; 
            	px = x; 
                py += str_maxh +1; 
                index +=2; 
                continue; 
    	} 
        if(one[0] == 92&& one[1] == 0)// '\n' 
    	{ 
            if(((4+index) < wc_len) && (wcontent[index+2] == 110) && (wcontent[index+3] == 0))// 'n' 
    		{ 
            	row++; 
            	px = x; 
                py += str_maxh +1; 
                index +=4; 
                continue; 
    		} 
    	} 
        if(isdisplay) 
            VzSP_draw_Text(px, py+(str_maxh - strs_h) , c ,(UI_string_type)one , 0 ,c); 
        //z_debug_log_prompt(("|%d",one[0]));//非测试需注释 
         
        px += strs_w + 1; 
        if(px > x2 - strs_w) 
    	{ 
            	row++; 
            	px = x; 
                py += str_maxh +1; 
    	} 
        index +=2; 
    } 
    return index; 
} 
 
void VzSP_Enter_APP_INIT() 
{ 
    //初始化 
    int i, j; 
    U32 seed; 
    kal_get_time(&seed); 
    srand(seed); 
    VzSP_fraction_get_set_file(&VzSP_plane_max_score,sizeof(VzSP_plane_max_score),0); 
    VzSP_top_stop_flag=0; 
	VzSP_pause_mark=0; 
	VzSP_game_time=0; 
	VzSP_game_score=0; 
	VzSP_plane_score=0; 
	 
	VzSP_plane_life=3; 
	VzSP_plane_i=6; 
	VzSP_plane_bullet=0; 
	VzSP_plane_is_hit=0; 
	VzSP_plane_hit_flag=1; 
	VzSP_plane_flash_time=0; 
	VzSP_plane_num=0; 
	VzSP_over_time=0; 
	VzSP_enemy_num=0; 
	VzSP_enemy_flag=1; 
	VzSP_enshell_flag=15; 
	VzSP_enemy_die_num=0; 
	VzSP_enemy_hit_time=0; 
	for(i=0; i<VzSP_plane_shell_num; i++) 
	{ 
	for(j=0; j<2; j++) 
		VzSP_plane_shell[i][j]=0; 
	} 
	for(i=0; i<3; i++) 
	{ 
		VzSP_enemy_pos[i]=0; 
	} 
	for(i=0; i<4; i++) 
	{ 
	VzSP_enemy_x[i]=0; 
	VzSP_enemy_y[i]=-VzSP_enemy_h; 
	VzSP_enemy_bullet[i]=0; 
	VzSP_enemy_shell_num[i]=0; 
	VzSP_enemy_is_hit[i]=0; 
	} 
	for(i=0; i<4; i++) 
	{ 
		for(j=0; j<18; j++) 
		{ 
			VzSP_enemy_shell[i][j]=0; 
		} 
	} 
	VzSP_enemy_product(); 
} 
void VzSP_Enter() 
{ 
	if(!vz_sp_SelectworkType()) 
	{ 
		return; 
 
	} 
    //初始化 
    VzSP_Enter_APP_INIT(); 
    // 
    VzSP_Enter_APP(); 
} 
 
#endif 
#endif