⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mmiballoon.c

📁 是一个手机功能的模拟程序
💻 C
📖 第 1 页 / 共 5 页
字号:
   DrawLine(cursorline2);
   
}
/*************************************************************************************
  函数名:gameinterfaceshow
  描述:当气球需要上移的时候,需要调用这个函数,显示游戏
         玩的时候的内容,另外原来时间停止的时候也调用的这个
         函数,必须为时间停止在做一个函数
**************************************************************************************/
void gameinterfaceshow(BalloonItemHeader *pheader, char* pscreenbuffer)
{
  
    BalloonItem *tempballoon;


    tempballoon=pheader->pfirst;
  
    
   // TRACE_EVENT("gameinterfaceshow");
   
    dspl_Clear(0, 160-pheader->balloonspeed,120,160);
    while(tempballoon)
    	{
    	tempballoon=tempballoon->balloonnext;   	
    	if(tempballoon)
    		{    		
    		if((tempballoon->yposition+balloonproperty[tempballoon->balloontype].height*2-159)>0)
    			{
    			#ifdef BALLOONDEBUG
    		     zgzTraceDataFunc("gameinterfaceshow yposition", (U16)tempballoon->yposition);
    			#endif
    		     balloondisplay(tempballoon);
    			}
    		}
    	if(pheader->fireflag!=1)
    	tempballoon->yposition=tempballoon->yposition-tempballoon->speed;
    	}
    if(pheader->fireflag!=1)		
    mvoe_memory(pheader);
    //气球的显示部分
    
    if(moveoutside(pheader))
     removeelement(pheader);	
    
    if(pheader->balloonspeed/2==1)
    dspl_Clear(0, 159-pheader->balloonspeed,120,160);
    else
    dspl_Clear(0, 160-pheader->balloonspeed,120,160);
    
    cursor_resume(pheader,pscreenbuffer);

}

/*************************************************************************************
  函数名:balloonheadinitial
  描述:此函数用于显示光标,由于要响应按键,所以所有的
         光标显示不能全部在timercb中处理。因此记录下一位置
         的屏幕内容就非常有必要
  *************************************************************************************/
void showcursor(char * pscreenbuffer)
{
   static U16 nextx,nexty;
   U32 pixcolor,oldcolor;
   game_Line cursorline1,cursorline2;
   U8 umode;


   if(lcdischange==0&&winfocusout==0)
	dspl_BitBlt(nextx,nexty,CURSORSIZE,CURSORSIZE,0,(void *)pscreenbuffer, 0);
   else
   	{     
   clear_remain(pscreenbuffer,nextx,nexty); 
      lcdischange=0;
   	}
   
   nextx=cursor.xposition-CURSORWIDTH;
   nexty=cursor.yposition-CURSORWIDTH;
   
   dspl_getscreen(nextx,nexty,CURSORSIZE,CURSORSIZE, pscreenbuffer);
 
   pixcolor=*(U16 *)(pscreenbuffer+CURSORSIZE*CURSORSIZE);

   cursorline1.x1=cursor.xposition-CURSORWIDTH;
   cursorline1.x2=cursor.xposition+CURSORWIDTH;
   cursorline1.y1=cursorline1.y2=cursor.yposition;
   cursorline1.color=0x0;//(~pixcolor)&0x00ffffff; 

   cursorline2.y1=cursor.yposition-CURSORWIDTH;
   cursorline2.y2=cursor.yposition+CURSORWIDTH;
   cursorline2.x1=cursorline2.x2=cursor.xposition;
   cursorline2.color=0x0;//(~pixcolor)&0xffff;

   umode=dspl_Enable(0);
   DrawLine(cursorline1);
   DrawLine(cursorline2);
   dspl_Enable(umode);
}

/*************************************************************************************
  函数名:clear_remain
  描述:  击中气球,或者气球刷新的时候如果光标在刷新的区域内
           就必须考虑重新刷新的大小,详情参照get_freshsize
  *************************************************************************************/
void clear_remain(char *pscreenbuffer,U16 xposition,U16 yposition)
{
U16 remainmask[CURSORSIZE][CURSORSIZE],i,j,umode;

memset(&remainmask[0][0],0x0000,(CURSORSIZE*CURSORSIZE)*sizeof(U16)); 

switch(lcdischange)
{
   case 1:// x-  y-
    	for(i=freshheight;i<CURSORSIZE;i++)
  	       for(j=freshwidth;j<CURSORSIZE;j++)
  			{
  			#ifdef BALLOONDEBUG
            zgzTraceDataFunc("clear_remain1 i", (U16)i);
            zgzTraceDataFunc("clear_remain1 j", (U16)j);
            #endif
  			remainmask[i][j]=0xffff;
  			}  	  
   	  break;
   case 2:  //x-  y+
      for(i=0;(i<freshheight)&&(i<CURSORSIZE);i++)
	  	for(j=freshwidth;j<CURSORSIZE;j++)
	  		{
	  		#ifdef BALLOONDEBUG
	  		zgzTraceDataFunc("clear_remain2 i", (U16)i);
            zgzTraceDataFunc("clear_remain2 j", (U16)j);
            #endif
	  		remainmask[i][j]=0xffff;
	  		}
   	  break;
   case 3:  //x+ y-
   	    for(i=freshheight;i<CURSORSIZE;i++)
  		 for(j=0;(j<freshwidth)&&(j<CURSORSIZE);j++)
  			{
  			#ifdef BALLOONDEBUG
  			zgzTraceDataFunc("clear_remain3 i", (U16)i);
            zgzTraceDataFunc("clear_remain3 j", (U16)j);
            #endif
  			remainmask[i][j]=0xffff;
  			}
   	  break;
   case 4:  // x+ y+
   	   for(i=0;(i<freshheight)&&(i<CURSORSIZE);i++)
    		for(j=0;(j<freshwidth)&&(j<CURSORSIZE);j++)
  			{
  			#ifdef BALLOONDEBUG
  			zgzTraceDataFunc("clear_remain4 i", (U16)i);
            zgzTraceDataFunc("clear_remain4 j", (U16)j);
            #endif
  			remainmask[i][j]=0xffff;
  			}
   	  break;
   default:
      break;
}

#ifdef BALLOONDEBUG
TraceMMIValue("clear_remain freshwidth", (int)freshwidth);
TraceMMIValue("clear_remain freshheight", (int)freshheight);
zgzTraceDataFunc("clear_remain freshwidth", (U16)freshwidth);
zgzTraceDataFunc("clear_remain freshheight", (U16)freshheight);
for(i=0;i<CURSORSIZE;i++)
	for(j=0;j<CURSORSIZE;j++)
		{
		zgzTraceDataFunc("clear_remain remainmask", (U16)remainmask[i][j]);
		}
#endif

umode=dspl_Enable(0);
dspl_BitBlt(xposition, yposition, CURSORSIZE, CURSORSIZE, 0, (void *)pscreenbuffer, DSPL_BMPXOR);
dspl_BitBlt(xposition, yposition, CURSORSIZE, CURSORSIZE, 0, (void *)&remainmask[0][0],DSPL_BMPAND);
dspl_BitBlt(xposition, yposition, CURSORSIZE, CURSORSIZE, 0, (void *)pscreenbuffer, DSPL_BMPXOR);
dspl_Enable(umode);
}
/*************************************************************************************
  函数名:balloondisplay
  描述:此函数用于显示气球,这里的气球都是透明位图,
         它的显示,如果光标的位置在
         
  *************************************************************************************/
void balloondisplay(BalloonItem *tempballoon)
{

U16 xposition,yposition,height,width;
char * balloonaddr,*balloonmaskaddr;
Balloon_Property balloon;

balloon=balloonproperty[tempballoon->balloontype];
xposition=tempballoon->xposition;
yposition=tempballoon->yposition;
height=2*(balloon.height);

balloonaddr=balloonaddresses[tempballoon->balloontype];
dspl_BitBlt(xposition, yposition, height, height, 0, (void *)balloonaddr, 0);

if(cursor.yposition>120)
lcdischange=get_freshsize(xposition,yposition,height,height);
#ifdef BALLOONDEBUG
zgzTraceDataFunc("balloondisplay lcdischange", (U16)lcdischange);
#endif
}


/*************************************************************************************
  函数名:mvoe_memory
  描述: 根据当前的级别是屏幕上移n个象素
  *************************************************************************************/
void mvoe_memory(BalloonItemHeader *pheader)
{

dspl_move_lcdbuffer(pheader->balloonspeed);

}
/*****************************和计算相关的*****************************************/
/*************************************************************************************
  函数名:balloonheadinitial
  描述:所有的气球y坐标加上的speed,并且调用moveoutside函数判断
         是不是已经有气球移出屏幕了
  *************************************************************************************/
void Set_Bs_Btimer(BalloonItemHeader* pheader,Balloon_Speed currentlevel)
{
T_MFW_HND       win  = mfw_parent (mfw_header());
T_MFW_WIN     * win_data = ((T_MFW_HDR *)win)->data;
Balloon_Game         * data = (Balloon_Game *)win_data->user;
    
if(currentlevel>=SpeedMax)
{
MmiTrace("erro");
return;
}
switch(currentlevel)
{
    case SpeedOne://timer=200
    	 pheader->balloonspeed=2;
    	 timSetTime(data->bltimer,balloontimer3);
         break;
    case SpeedTwo:
    	 pheader->balloonspeed=3;
    	 timSetTime(data->bltimer,balloontimer3);
    	 break;
    case SpeedThree:
    	 pheader->balloonspeed=4;
    	 timSetTime(data->bltimer,balloontimer3);
    	 break;
    case SpeedFour://timer=100
    	 pheader->balloonspeed=2;
       	 timSetTime(data->bltimer,balloontimer1);
         break;
    case SpeedFive://timer=150
    	 pheader->balloonspeed=3;
    	 timSetTime(data->bltimer,balloontimer2); 
    	 break;
    case SpeedSix:
    	 pheader->balloonspeed=4;
    	 timSetTime(data->bltimer,balloontimer2); 
    	 break;
    case SpeedSeven://timer=100
    	 pheader->balloonspeed=3;
    	timSetTime(data->bltimer,balloontimer1); 
    	 break;
    case SpeedEight:
    	 pheader->balloonspeed=4;
    	timSetTime(data->bltimer,balloontimer1); 
    	 break;
    case SpeedNine:
    	 pheader->balloonspeed=5;
    	timSetTime(data->bltimer,balloontimer1); 
    	 break;
    default: break;
}

}
/*************************************************************************************
  函数名:balloonheadinitial
  描述:所有的气球y坐标加上的speed,并且调用moveoutside函数判断
         是不是已经有气球移出屏幕了
  *************************************************************************************/
void balloonrise(BalloonItemHeader *pheader)
{
  BalloonItem *tempballoon;
 tempballoon=pheader->pfirst;

// TRACE_EVENT("ballloonrise");
 while(tempballoon->balloonnext)
 	{
 	tempballoon=tempballoon->balloonnext;

 		tempballoon->yposition=tempballoon->yposition-tempballoon->speed;
 		#ifdef BALLOONDEBUG
 		zgzTraceDataFunc("balloonrise yposition", (U16)tempballoon->yposition);
 		#endif
 	}
  if(moveoutside(pheader))
  removeelement(pheader);
}

/*************************************************************************************
  函数名:balloonheadinitial
  描述:此函数用于确定新气球的x坐标,他必须满足这样的条件
         如果,生成的坐标必须在0到100之间。另外他和上一个气
         球的横坐标间距必须大于15 ,否则判断上一气球的横坐标
         如果大于60,那就返回一个减去40的数,否则就加40
  *************************************************************************************/
U16 randomxpositioncreate(BalloonItemHeader *pheader)
{
    U16 random,pre1xpos,pre2xpos,smallerx,lagerx;
    short int tempint;
    BalloonItem * temp=pheader->plast;

    
//明天检查这个函数的返回值
    if(pheader->ballooncount<1)
    	{
    	  random=rand();
          random=random%96;
          return random;
    	}
    if(pheader->ballooncount<2)
    	{
    	  random=rand();
          random=random%24+24;
          pre1xpos=temp->xposition;
          return (((pre1xpos-48)>=0)?(pre1xpos-random):(pre1xpos+random));
    	}

    temp=pheader->pfirst;
    
    while(temp->balloonnext)
 	{
 	pre2xpos=temp->xposition;
 	temp=temp->balloonnext;
    pre1xpos=temp->xposition;
    }
    
    #ifdef BALLOONDEBUG
    zgzTraceDataFunc("randomxpositioncreate pre2xpos", (U16)pre2xpos);
    zgzTraceDataFunc("randomxpositioncreate pre1xpos", (U16)pre1xpos);
    #endif
    
    tempint=abs(pre2xpos-pre1xpos)-48;
  
    if((tempint>0)&&(tempint<49))
    	{
    	random=rand();
        random=random%tempint+24;
        #ifdef BALLOONDEBUG
        zgzTraceDataFunc("randomxpositioncreate random1", (U16)random);
        #endif
        return SMALLER(pre1xpos,pre2xpos)+random;
    	}
    if(tempint==0)
    	return  SMALLER(pre1xpos,pre2xpos)+24;

    smallerx=SMALLER(pre1xpos,pre2xpos);
    lagerx=96-LAGER(pre1xpos,pre2xpos);
 //   zgzTraceDataFunc("randomxpositioncreate smallerx", (U16)smallerx);
  //  zgzTraceDataFunc("randomxpositioncreate lagerx", (U16)lagerx);
    if(smallerx>=lagerx)
    	{
    	tempint=smallerx-24;
    	random=rand();
        random=random%tempint;
        #ifdef BALLOONDEBUG
        zgzTraceDataFunc("randomxpositioncreate random2", (U16)tempint);
        #endif
        return random;
    	}
    else
    	{
    	tempint=lagerx-24;
    	random=rand();
        random=random%tempint+24;
        #ifdef BALLOONDEBUG
         zgzTraceDataFunc("randomxpositioncreate random3", (U16)random);
        #endif
     //    这里不能是72 加上random 应该是lagerx
        lagerx=LAGER(pre1xpos,pre2xpos);
        return lagerx+random;
    	}
    
     return 0;
     
}

/*************************************************************************************
  函数名:balloonheadinitial
  描述:此函数用于确定新气球的类型,总共有8种最后三种是*2 /2
         和停止,*2 /2 s只能有一个
         气球产生的规则
         (1) 总共产生33个气球,其中得分各六个,另外三种各一个
         (2) 前15个气球当中不能有/2 *2 s 这三种气球其它的5中气球
             不能超过3个
         (3) 后18个球当中可以创建任意类型的气球但是必须满足
            条件1
  *************************************************************************************/
U16 randomtypecreate(BalloonItemHeader *pheader)
{
    U8 random,i,j;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -