以文本方式查看主题
-
曙海教育集团论坛
(http://sun4.cn/bbs/index.asp)
--
MTK开发
(http://sun4.cn/bbs/list.asp?boardid=43)
----
在MTK上开发的游戏源代码
(http://sun4.cn/bbs/dispbbs.asp?boardid=43&id=1984)
-- 作者:wangxinxin
-- 发布时间:2010-12-2 10:18:42
-- 在MTK上开发的游戏源代码
以下内容含脚本,或可能导致页面不正常的代码
MTK上就那几个<span class="t_tag" onclick="tagshow(event)" href="tag.php?name=%D3%CE%CF%B7">游戏</span>太腻了,于是我就搞了个小游戏上去,跑得很好。效果不错。 这是我在MTK上<span class="t_tag" onclick="tagshow(event)" href="tag.php?name=%BF%AA%B7%A2">开发</span>的游戏源代码---推箱子。 MTK<span class="t_tag" onclick="tagshow(event)" href="tag.php?name=%C6%BD%CC%A8">平台</span>调试通过。我去掉了数据部分和内核。,留下了框架供大家学习MTK平台开发。 <p align="left">-------------- <p align="left">#include \\"GlobalDefs.h\\" #include \\"HistoryGprot.h\\" #include \\"GlobalConstants.h\\" <p align="left">#include \\"MMI_features.h\\" #include \\"<img alt="" src="http://bbs.mobiletest.cn/images/smilies/default/titter.gif" border="0" smilieid="9"/>ixtelDataTypes.h\\" #include \\"Unicodexdcl.h\\" <p align="left">#include \\"gui.h\\" #include \\"Calculator.h\\" #include \\"SettingProfile.h\\" #include \\"<img alt="" src="http://bbs.mobiletest.cn/images/smilies/default/titter.gif" border="0" smilieid="9"/>rofileGprots.h\\" <p align="left">#include \\"Globaldefs.h\\" #include \\"CustDataRes.h\\" #include \\"gui_themes.h\\" #include \\"wgui_categories.h\\" #include \\"wgui_softkeys.h\\" #include \\"HistoryGprot.h\\" #include \\"OrganizerDef.h\\" #include \\"GameDefs.h\\" <p align="left">#define MTK_GUANSHU 40 #define PUSH_LCD_WIDTH 176 #define PUSH_LCD_HEIGHT 220 <p align="left">static const char MTK_DATA[MTK_GUANSHU][80] = { {1,1,1,1,1,1,1,1,1,1, 1,0,0,0,1,3,0,1,1,1, 1,3,0,0,2,0,0,1,1,1, 1,1,2,1,1,0,0,1,1,1, 1,0,0,1,1,2,1,1,1,1, 1,0,0,4,0,0,0,1,1,1, 1,0,3,1,0,0,0,1,1,1, 1,1,1,1,1,1,1,1,1,1}}; <p align="left"> typedef struct{ INT16 X; INT16 Y; }MTK_POS; <p align="left">typedef struct{ UINT8 Data1; UINT8 Data2; } MTK_sg_PUSHBOXSTRUCT; <p align="left"> static MTK_sg_PUSHBOXSTRUCT g_Pushbox; static char Config_Passs=1; <p align="left">enum{ PushSharp_Blank , PushSharp_Bar , PushSharp_Box , PushSharp_Goal , PushSharp_Boxer , PushSharp_Ok }e_PushSharp; <p align="left">void Game_Push_Null(void) { return; } <p align="left">/*Name:Calculate Desc: Calculate the current position of the block Return: no return value Author: helloworld */ static void Game_Push_Calculate( UINT8 val ) { UINT8 row; UINT8 col; //kal_prompt_trace(MOD_MMI, \\"\\\\n[Push-->Game_Push_Calculate,val=%d ]\\\\n\\", val); <p align="left">row = val/10; col = val - row * 10; <p align="left">kal_prompt_trace(MOD_MMI, \\"\\\\n[Push-->Game_Push_Calculate,row=%d, col=%d ]\\\\n\\",row,col); <p align="left">g_Pushbox.BoxPos.X = 15 * col + 14; g_Pushbox.BoxPos.Y = 15 * row + 24; } <p align="left"> static void UIFDrawBitmap(S32 offset_x, S32 offset_y, U16 image_id) { //kal_prompt_trace(MOD_MMI, \\"\\\\n[Push-->UIFDrawBitmap, image_id=%d]\\\\n\\", image_id); pixtel_UI_lock_double_buffer(); //pixtel_UI_reset_clip(); <p align="left">pixtel_UI_show_image(offset_x,(offset_y +20),(UI_image_type)GetImage(image_id)); <p align="left">pixtel_UI_unlock_double_buffer(); pixtel_UI_BLT_double_buffer(0,0,PUSH_LCD_WIDTH,PUSH_LCD_HEIGHT); } <p align="left">static short Game_Push_Itou(short *pOutStr,long InNum) { // 0: ox0030 char NumString[10]; short i,j; short NumLen;// 位数 <p align="left">memset(NumString,\\\'\\\\0\\\',10); kal_prompt_trace(MOD_MMI, \\"\\\\n[Push-->Game_Push_Itoa, InNum=%d]\\\\n\\", InNum); <p align="left">if(NULL==pOutStr) { return; } if(InNum/1000000 >0) {// to long return; } <p align="left">if(InNum/100000 >0) { NumLen=6; } else if(InNum/10000 >0) { NumLen=5; } else if(InNum/1000 >0) { NumLen=4; } else if(InNum/100 >0) { NumLen=3; } else if(InNum/10 >0) { NumLen=2; } else { NumLen=1; } <p align="left">for(i=NumLen;i>0;i--) { if(1==i) { NumString[0]= InNum%10 +\\\'0\\\'; } else if(2==i) { NumString[i-1]= (InNum/10)%10 +\\\'0\\\'; } else if(3==i) { NumString[i-1]= (InNum/100)%10 +\\\'0\\\'; } else if(4==i) { NumString[i-1]= (InNum/1000)%10 +\\\'0\\\'; } else if(5==i) { NumString[i-1]= (InNum/10000)%10 +\\\'0\\\'; } pOutStr[NumLen-i]= NumString[i-1]; kal_prompt_trace(MOD_MMI, \\"\\\\n[Push-->Game_Push_Itoa, =%d]\\\\n\\", pOutStr[NumLen-i]); } <p align="left">kal_prompt_trace(MOD_MMI, \\"\\\\n[Push-->Game_Push_Itoa, len=%d]\\\\n\\",NumLen); <p align="left">return j; } <p align="left">const color PushTextColor = {0,0,100,100}; <p align="left">static void Game_Push_DrawString(void) { #define REC_POS_X 1 #define REC_POS_Y 170 #define REC_POS_W 176 #define REC_POS_H 50 <p align="left">S32 w; short Psss_uncode[10], Step_uncode[10]; memset(Psss_uncode,\\\'\\\\0\\\',10); memset(Step_uncode,\\\'\\\\0\\\',10); <p align="left">Game_Push_Itou(Psss_uncode, (long)Config_Passs); Game_Push_Itou(Step_uncode, (long)g_Pushbox.step); <p align="left">pixtel_UI_lock_double_buffer(); <p align="left">pixtel_UI_set_font(&MMI_medium_font); pixtel_UI_set_text_color(PushTextColor); <p align="left">pixtel_UI_reset_clip(); pixtel_UI_reset_text_clip(); <p align="left">pixtel_UI_move_text_cursor( 63, 185 ); pixtel_UI_print_text((UI_string_type)Psss_uncode); <p align="left">UIFDrawBitmap( 145, (185 -20) ,IMG_ID_PUSH_BOX_SMALL_BKG); UIFDrawBitmap( 155, (185 -20) ,IMG_ID_PUSH_BOX_SMALL_BKG); <p align="left">pixtel_UI_move_text_cursor( 145, 185 ); pixtel_UI_print_text((UI_string_type)Step_uncode); <p align="left">pixtel_UI_unlock_double_buffer(); pixtel_UI_BLT_double_buffer(REC_POS_X, REC_POS_Y, REC_POS_X + REC_POS_W, REC_POS_Y + REC_POS_H); <p align="left">return; } <p align="left">// service for FirstDraw and commonDraw static void Game_Push_Draw(INT8 i ) { Game_Push_Calculate( i ); kal_prompt_trace(MOD_MMI, \\"\\\\n[Push-->Game_Push_Draw, drawID=%d, posX=%d, posY=%d]\\\\n\\", g_Pushbox.tempbox<i>, g_Pushbox.BoxPos.X, g_Pushbox.BoxPos.Y); <p align="left"> switch( g_Pushbox.tempbox<i> ) { case 0: //为空时根本就不用画. 让他显示背景,(不行! 还是要画) UIFDrawBitmap( g_Pushbox.BoxPos.X, g_Pushbox.BoxPos.Y, IMG_ID_PUSH_BOX_BLANK); break; <p align="left"> case 1: UIFDrawBitmap( g_Pushbox.BoxPos.X, g_Pushbox.BoxPos.Y, IMG_ID_PUSH_BOX_BAR); break; <p align="left"> case 2: UIFDrawBitmap( g_Pushbox.BoxPos.X, g_Pushbox.BoxPos.Y, IMG_ID_PUSH_BOX_BOX); break; <p align="left"> case 3:/*这是个傻办法, 以保证用24.. 但又不露出背景... 挖空背景后, 仍要用, 因为推走box后,要立即将其覆盖掉 */ UIFDrawBitmap( g_Pushbox.BoxPos.X, g_Pushbox.BoxPos.Y,IMG_ID_PUSH_BOX_GOAL); break; <p align="left"> case 4: UIFDrawBitmap( g_Pushbox.BoxPos.X, g_Pushbox.BoxPos.Y, IMG_ID_PUSH_BOX_BOXER); break; <p align="left"> case 5: UIFDrawBitmap( g_Pushbox.BoxPos.X, g_Pushbox.BoxPos.Y,IMG_ID_PUSH_BOX_OK); break; <p align="left"> case 6: UIFDrawBitmap( g_Pushbox.BoxPos.X, g_Pushbox.BoxPos.Y, IMG_ID_PUSH_BOX_BOXER ); break; <p align="left"> case 7: UIFDrawBitmap( g_Pushbox.BoxPos.X, g_Pushbox.BoxPos.Y, IMG_ID_PUSH_BOX_SMALL_BKG ); break; <p align="left"> default: break; } } <p align="left"> static void Game_Push_FirstDraw(void) { short i; pixtel_UI_lock_double_buffer(); pixtel_UI_reset_clip(); clear_screen(); <p align="left"> UIFDrawBitmap( 0, 0,IMG_ID_PUSH_BOX_BKG); //大背景 <p align="left">for( i = 0; i < 80; i++ ) { Game_Push_Draw( i ); } Game_Push_DrawString(); pixtel_UI_unlock_double_buffer(); pixtel_UI_BLT_double_buffer(0,0,PUSH_LCD_WIDTH,PUSH_LCD_HEIGHT); } <p align="left">static void Game_Push_ComonDraw(void) { Game_Push_Draw( g_Pushbox.BeforeBoxer ); Game_Push_Draw( g_Pushbox.Boxer ); Game_Push_Draw( g_Pushbox.AfterBoxer ); } <p align="left">static void Game_Push_Ini(void) {//开局 short i; g_Pushbox.over = FALSE; g_Pushbox.goalnum = 0; g_Pushbox.I = 0; g_Pushbox.step = 0; <p align="left">for( i = 0; i < 80; i++ ) { g_Pushbox.tempbox<i> = MTK_DATA[Config_Passs - 1]<i>; <p align="left"> if( ( g_Pushbox.tempbox<i> == 3 ) || ( g_Pushbox.tempbox<i> == 5 ) || ( g_Pushbox.tempbox<i> == 6 ) ) { g_Pushbox.goalnum++; } <p align="left"> if( ( g_Pushbox.tempbox<i> == 4 ) || ( g_Pushbox.tempbox<i> == 6 ) ) { g_Pushbox.Boxer = i; } if( g_Pushbox.tempbox<i> == 5 ) { g_Pushbox.I++; } } } <p align="left">static void Game_Push_DeIni(void) { return; } <p align="left">//新开局 static void Game_Push_BeginNewStep(void) { Game_Push_Ini(); Game_Push_FirstDraw(); return; } void Game_Push_Begin(void); <p align="left">static void Game_Push_ConfirmNewGame(void) { //GoBackHistory(); Game_Push_Begin(); return; } <p align="left">static void Game_Push_ConfirmExitGame(void) { Game_Push_DeIni(); GoBacknHistory(2); //GoBackHistory(); return; } <p align="left">static char Game_Push_GameOverProc(void) { if( FALSE == g_Pushbox.over ) { return g_Pushbox.over; } <p align="left">Config_Passs++; if( Config_Passs > MTK_GUANSHU ) { Config_Passs = 1; } <p align="left">DisplayConfirm( STR_GLOBAL_YES, IMG_GLOBAL_YES, STR_GLOBAL_NO, IMG_GLOBAL_NO, get_string(STR_GAME_RESUME),IMG_GLOBAL_QUESTION, WARNING_TONE); <p align="left">SetRightSoftkeyFunction(Game_Push_ConfirmExitGame,KEY_EVENT_UP); SetLeftSoftkeyFunction(Game_Push_ConfirmNewGame,KEY_EVENT_UP); return g_Pushbox.over; } <p align="left">/*Name:MoveStep Desc: Move the block Return: no return value Author: helloworld */ static void Game_Push_MoveStep( void) { //core } <p align="left"> static void Game_Push_UpKeyProc(void) { kal_prompt_trace(MOD_MMI, \\"\\\\n[Push-->Game_Push_UpKeyProc]\\\\n\\"); <p align="left">g_Pushbox.flag = 0 - 10; <p align="left">Game_Push_MoveStep(); return; } static void Game_Push_DownKeyProc(void) { kal_prompt_trace(MOD_MMI, \\"\\\\n[Push-->Game_Push_DownKeyProc]\\\\n\\"); g_Pushbox.flag = 10; <p align="left">Game_Push_MoveStep(); return; } static void Game_Push_LeftKeyProc(void) { kal_prompt_trace(MOD_MMI, \\"\\\\n[Push-->Game_Push_LeftKeyProc]\\\\n\\"); <p align="left">g_Pushbox.flag = -1; Game_Push_MoveStep(); return; } static void Game_Push_RightKeyProc(void) { kal_prompt_trace(MOD_MMI, \\"\\\\n[Push-->Game_Push_RightKeyProc]\\\\n\\"); g_Pushbox.flag = 1; Game_Push_MoveStep(); return; } <p align="left">static void Game_Push_HashKeyProc(void) { kal_prompt_trace(MOD_MMI, \\"\\\\n[Push-->Game_Push_HashKeyProc]\\\\n\\"); <p align="left">Config_Passs--; <p align="left">if( Config_Passs < 1 ) { Config_Passs = MTK_GUANSHU; } Game_Push_BeginNewStep(); return; } <p align="left"> static void Game_Push_StarKeyProc(void) { kal_prompt_trace(MOD_MMI, \\"\\\\n[Push-->Game_Push_StarKeyProc]\\\\n\\"); <p align="left">Config_Passs++; <p align="left">if( Config_Passs > MTK_GUANSHU ) { Config_Passs = 1; } Game_Push_BeginNewStep(); return; } <p align="left">static void Game_Push_SendKeyProc(void) { Game_Push_BeginNewStep(); return; } <p align="left">static void Game_Push_EndKeyProc(void) { Game_Push_DeIni(); GoBackHistory(); return; } <p align="left"> static void Game_Push_SetKeysHandle(void) { //kal_prompt_trace(MOD_MMI, \\"\\\\n[Push-->Game_Push_SetKeysHandle]\\\\n\\"); ClearAllKeyHandler(); <p align="left">SetKeyHandler(Game_Push_UpKeyProc, KEY_UP_ARROW, KEY_EVENT_DOWN); SetKeyHandler(Game_Push_DownKeyProc, KEY_DOWN_ARROW, KEY_EVENT_DOWN); <p align="left">SetKeyHandler(Game_Push_LeftKeyProc, KEY_LEFT_ARROW, KEY_EVENT_DOWN); SetKeyHandler(Game_Push_RightKeyProc, KEY_RIGHT_ARROW, KEY_EVENT_DOWN); <p align="left">// * # SetKeyHandler(Game_Push_StarKeyProc, KEY_STAR, KEY_EVENT_DOWN); SetKeyHandler(Game_Push_HashKeyProc, KEY_POUND, KEY_EVENT_DOWN); <p align="left">// send, end SetKeyHandler(Game_Push_SendKeyProc, KEY_SEND, KEY_EVENT_DOWN); SetKeyHandler(Game_Push_EndKeyProc, KEY_END, KEY_EVENT_DOWN); <p align="left">// back SetRightSoftkeyFunction(GoBackHistory,KEY_EVENT_UP); } <p align="left">static void Game_Push_Entry(void) { EntryNewScreen(SCR_ID_CALC_APP, NULL, Game_Push_Entry, NULL); Game_Push_FirstDraw(); RedrawCategoryFunction=Game_Push_FirstDraw; } <p align="left"> // for menu void Game_Push_Begin(void) { Game_Push_Ini(); Game_Push_Entry(); Game_Push_SetKeysHandle(); return; } </i></i></i></i></i></i></i></i></i></i>
说明:
上面显示的是代码内容。您可以先检查过代码没问题,或修改之后再运行.