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

📄 main.java

📁 之前有人传过`不过是没有资源只有代码的` 我在重新传一遍有资源的`是一个滑雪的游戏`类似flash的打企鹅`
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
   		hp = null;   		v = v1 = v2 = null;   		gd = null;   		font = null;   		str = str2 = null;      	state = STATE_MENU;		resourcesLoaded = false;		System.gc();    }    void initEditor(String name,String value,int count)     {    	menuName = name;    	editText = new char[count];    	for (i = 0; i < count; editText[i] = value.charAt(i++));    	state = STATE_EDITOR;    	if (enqueue_abc(0)) loadImages(false);    	go_delay = 0;    	editX = editY = idx = 0;    	initOK = true;    }    void initMenu(String name, boolean isPointer, boolean isState, boolean showLogo)     {    	initOK = false;    	state = STATE_MENU;		menuIndex = menuDisp = 0;		vMenuName = prepareText(name,s_w - 8);		menuWidth = 0;		menuSize = vMenuName.size();		for (i = 0; i < menuSize; i++)		{			menuName = (String)vMenuName.elementAt(i);			j = getStringWidth(menuName);			if (j > menuWidth) menuWidth = j;		}		if (paused) menuTop = 6;		else		{//#if Size_0			if (menuLevel != 0) logoTop = 6;//#endif			menuTop = logoTop + (showLogo ? 0 : 16);		}		menuHeight = 16;		menuRange = (s_h - menuTop + (menuHeight >> 1)) / menuHeight - menuSize + 1;		this.isPointer = isPointer;		this.showLogo = showLogo;		this.isState = isState;		vMenu = new Vector();		vMenuId = new Vector();		if (isState) vState = new Vector();    	menuItemWidth = 0;		for (tabi = 0; tabi < tabx.length; tabi++) tabx[tabi] = 0;		needCalcTabulations = true;		tabi = 0;    	loadText();    	if (enqueue_abc(0) || (paused || resourcesLoaded ? false : loadLogo())) loadImages(false);    	go_delay = 0;    	initOK = true;    }    void init(int game_id,boolean needGhost,String code, int post_mode)    {    	try    	{			i = 27;			if (game_id == G_SKATER) i = 28;			if (game_id == G_BIATHLON) i = 29;			running = initOK = false;			needLoadingIndicator = true;			setScreen(text[i]); // loading			text[42] = text[43] = text[44] = text[45] = text[46] = null;			ghost_data_w = null;			doRepaint();			release();			m_v1 = m_v2 = 0;			fGo = new Frame[4];       	   	for (i = 0; i < fGo.length; i++) fGo[i] = gf("go" + i);       	   	fBoard = gf("board");       	   	switch(game_id)       	   	{			case G_SKIJUMP:				state = STATE_SKIJUMP_RUN;				fTree = new Frame[1];				fT = new Frame[4];//#if Nokia				fSn = new Frame[8];//#else				fSn = new Frame[16];//#endif				for (i = 0; i < fT.length; i++) fT[i] = gf("jt" + i);				for (i = 0; i < fSn.length; i++) fSn[i] = gf("jm" + i);				for (i = 0; i < fTree.length; i++) fTree[i] = gf("tree" + i);				fSnow = gf("jsn");				fBg = gf("bg0");				fSign = gf("dsign");				fMeter = gf("jw");				fMeterred = gf("jwp");				fChess = gf("mtr");				fBoard = gf("mtrred");				fTarget = gf("mw");				track_x = new int[5];				track_x[0] = 48 * 4;				track_x[1] = 20;				track_x[2] = 20;				track_x[3] = 576;				track_x[4] = 400;				track_width = 0;				for (i = 0; i < track_x.length; i++) track_width += track_x[i];				y_bg_top = ((s_h - fBg.fh) >> 1) + (track_width >> 5);				y_bound_top = s_h / 4;				y_bound_bottom = s_h * 2 / 3;				x_bound = s_w / 3;				start_y = y_bound_top;				a_x_range = track_width - s_w;				v1 = parse(gp("sin"));				sin = new int[v1.size()];    			for (j = 0; j < sin.length; j++) sin[j] = ((Integer)v1.elementAt(j)).intValue();				v1 = parse(gp("cos"));				cos = new int[v1.size()];    			for (j = 0; j < cos.length; j++) cos[j] = ((Integer)v1.elementAt(j)).intValue();				man = new Dynamic();				man.init(0,0,null,false);				if (needGhost)				{					ghost = new Dynamic();					ghost.init(0,0,null,true);				}	           	enqueue_abc(2);	           	break;			case G_SKATER:				state = STATE_SKATER_RUN;				fTarget = gf("aud");				fAmmo = gf("cones");				fSnow = gf("snow");				fBg = gf("bg1");				fChess = gf("chess");				fSign = gf("dsign");				fT = new Frame[2];				for (i = 0; i < fT.length; i++) fT[i] = gf("adv" + i);				if (isBannerLoaded == true && banner != null)				{					img_names[fT[1].index] = banner;				}				readAnimation("a_s",4);				man = new Dynamic();				man.init(20,0,"s",false);				if (needGhost)				{					ghost = new Dynamic();					ghost.init(20,0,"sg",true);				}				track_width = 3200;				tracks_total = track_width;				a_x_range = track_width - s_w + 100;				x_bound = s_w - (s_w >> 2);	           	enqueue_abc(2);	           	break;			case G_BIATHLON:				state = STATE_BIATHLON_RUN;				track_x = new int[9];				track_y = new int[track_x.length];				track_x[0] = 512;				track_x[1] = 384;				track_x[2] = 256;				track_x[3] = 256;				track_x[4] = 384;				track_x[5] = 128;				track_x[6] = 128;				track_x[7] = 256;				track_x[8] = 640;				track_y[0] = 0;				track_y[1] = 96;				track_y[2] = 0;				track_y[3] = -64;				track_y[4] = 0;				track_y[5] = 32;				track_y[6] = 0;				track_y[7] = -64;				track_y[8] = 0;				track_width_one = 0;				for (i = 0; i < track_x.length; i++) track_width_one += track_x[i];				x_bound = s_w >> 1;				shoot_bound = track_width_one - track_x[track_x.length - 1] + 100 - s_w + x_bound - 10;				track_x_sum = track_width_one;				track_width = track_width_one * rounds_count;				track_width_one = track_width_one * (rounds_count - 1) + 32;				tracks_total = track_x.length * rounds_count;				a_x_range = track_width - s_w;                                        				fT = new Frame[3];				fSn = new Frame[8];				fTree = new Frame[1];				fFlag = new Frame[2];				for (i = 0; i < fT.length; i++) fT[i] = gf("tr" + i);				for (i = 0; i < fSn.length; i++) fSn[i] = gf("sn" + i);				for (i = 0; i < fTree.length; i++) fTree[i] = gf("tree" + i);				for (i = 0; i < fFlag.length; i++) fFlag[i] = gf("flag" + i);				y_bound_bottom = s_h - 8;				if (s_h > 100) y_bound_bottom -= 8;				if (s_h > 130) y_bound_bottom -= 8;				y_bound_top = y_bound_bottom - 10;				if (s_h > 100) y_bound_top -= 6;				if (s_h > 130) y_bound_top -= 6;//#if !T610				fBg = gf("bg0");				y_bg_top = y_bound_top - fBg.fh - 8;//#endif				fChess = gf("chess");				fTarget = gf("target");				fSign = gf("csh");				fMeter = gf("mtr");				fMeterred = gf("mtrred");				fHeart = gf("heart");				fAmmo = gf("ammo");				readAnimation("a_b",7);				man = new Dynamic();				man.init(0,0,"m",false);				if (needGhost)				{					ghost = new Dynamic();					ghost.init(0,0,"mg",true);				}				start_x = 0;				start_y = y_bound_bottom;				state_delay = 1000;			}			hp = null;			System.gc();           	enqueue_abc(0);           	enqueue_abc(1);			if (!loadImages(false))			{				endGame();				return;			}			needLoadingIndicator = false;			font = Font.getFont(Font.FACE_MONOSPACE, Font.STYLE_PLAIN, Font.SIZE_SMALL);			if (needGhost)			{	        	ghost_data = new byte[GHOST_DATA_SIZE];				ghost_data_count = readGhostLocal(game_id,ghost_data);				if (ghost_data_count == 0)				{					ghost = null;					ghost_data = null;				}			}			resourcesLoaded = true;			restart();		}		catch(Exception ex)		{//			ex.printStackTrace();		}    }    void restart()    {    	try    	{			ghost_data_w = null;			ghost_data_count_w = ghost_data_ptr = ghost_data_ptr_w = 0;			System.gc();	   	   	switch(state)   		   	{			case STATE_SKIJUMP_RUN:				points = 100;				distance = total_points = 0;	           	break;			case STATE_SKATER_RUN:				man.state = STATE_SKATER_RUN;				if (ghost != null)				{					ghost.state = STATE_SKATER_RUN;				}    	       	break;			case STATE_BIATHLON_RUN:				man.state = STATE_BIATHLON_RUN;				man.target_y = y_bound_bottom - 32;				if (ghost != null)				{					ghost.state = STATE_BIATHLON_RUN;					ghost.target_y = y_bound_bottom - 32;				}			}			man.restart();			if (ghost != null) ghost.restart();			rounds_passed = 0;			ghost_data_w = new byte[GHOST_DATA_SIZE]; // alloc memory for ghost data			a_x_d = a_y_d = 0;			time_start = 0;			go_delay = 20;			go_index = 0;			paused = false;    		time_start = 0;    		time_current = 0;    		time_finish = 0;    		ghost_time = 0;    		ghost_time_w = 0;			frames_passed = 0;			isKeyPressed = false;	    	initOK = true;//	    	m("restarted");		}		catch(Exception ex)		{		}    }    void readAnimation(String prefix,int a) throws Exception    {    	anims = new int[a][];    	for (i = 0; i < a; i++)    	{	    		str = gp(prefix + i);    		if (str != null)    		{    			v1 = parse(str);    			anims[i] = new int[((Integer)v1.elementAt(0)).intValue()];    			for (j = 0; j < anims[i].length; j++) anims[i][j] = ((Integer)v1.elementAt(j + 1)).intValue();		    	v1 = null;    		}    	}    }    static long time_start, time_current, time_finish, ghost_time, ghost_time_w, time_extra, time_total;    static long frames_passed;    static boolean isKeyPressed;    protected void keyPressed(int keyCode)    {	    key_action = action = keyCode;	    isKeyPressed = true;//#if !Nokia	    game_action = getGameAction(keyCode);	    switch(game_action)	    {	    	case Canvas.UP: 	action = KEY_NUM2; break;	    	case Canvas.DOWN: 	action = KEY_NUM8; break;	    	case Canvas.LEFT: 	action = KEY_NUM4; break;	    	case Canvas.RIGHT:  action = KEY_NUM6; break;	    	case Canvas.FIRE: 	action = KEY_NUM5; 	    }	    key_action = action;//#endif	}    protected void keyReleased(int keyCode)    {		isKeyPressed = false;	}	static int ghost_action = 0;	static void readGhost()	{		try		{			if (ghost_data_count > ghost_data_ptr)			{				ghost_action =  NO_ACTION;				tt = frames_passed;				i = ((ghost_data[ghost_data_ptr] & 0x000000FF) << 8) | (ghost_data[ghost_data_ptr + 1] & 0x000000FF);						if (ghost_time + i <= tt)				{					ghost_time = tt;					g_action =   (ghost_data[ghost_data_ptr + 3] & 0x000000FF) | 								((ghost_data[ghost_data_ptr + 2] & 0x000000FF) << 8);					j = (g_action >> 4) & 0x0000000F;					if (ghost != null)					{						if (j != ghost.j_wind_dest)						{							ghost.j_wind_dest = j;	    					ghost.j_wind_d = ghost.j_wind_dest - ghost.j_wind;    						if (ghost.j_wind_d > 8 || (ghost.j_wind_d < -8))     							ghost.j_wind_d = - ghost.j_wind_d;		    				ghost.j_wind_d = ghost.j_wind_d > 0 ? 1 : -1;		    			}						ghost.j_wind_power_dest = (g_action >> 8) & 0x00000003;						ghost.jw = 50 * ghost.j_wind_power_dest / 3;						ghost.j_i1 = (g_action >> 10) & 0x00000007;						ghost.j_i2 = (g_action >> 13) & 0x00000007;						ghost.processed = true;					}					ghost_action = NO_ACTION;					switch (g_action & 0x0000000F)					{//						case 1:  ghost_action = Canvas.KEY_NUM0; break;//						case 2:  ghost_action = Canvas.KEY_NUM1; break;						case 3:  ghost_action = Canvas.KEY_NUM2; break;//						case 4:  ghost_action = Canvas.KEY_NUM3; break;						case 5:  ghost_action = Canvas.KEY_NUM4; break;						case 6:  ghost_action = Canvas.KEY_NUM5; break;						case 7:  ghost_action = Canvas.KEY_NUM6; break;//						case 8:  ghost_action = Canvas.KEY_NUM7; break;						case 9:  ghost_action = Canvas.KEY_NUM8; break;//						case 10: ghost_action = Canvas.KEY_NUM9; break;						case 11: ghost_action = Canvas.KEY_STAR; break;//						case 12: ghost_action = Canvas.KEY_POUND; break;					}					ghost_data_ptr += 4;				}			}		}		catch(Exception ex){}	}	static void writeGhost(boolean processed)	{		try		{			if (ghost_data_w != null)			if (ghost_data_count_w == 0 && processed)			{				i = (int)(frames_passed - ghost_time_w);				ghost_time_w = frames_passed;				// skip empty periods				while (i > 0xFFFF)				{					ghost_data_w[ghost_data_ptr_w] = (byte)0xFF;					ghost_data_w[ghost_data_ptr_w + 1] = (byte)0xFF;					ghost_data_w[ghost_data_ptr_w + 2] = (byte)0;					ghost_data_w[ghost_data_ptr_w + 3] = (byte)0;					i -= 0xFFFF;				}				ghost_data_w[ghost_data_ptr_w] = (byte)((i & 0xFF00) >> 8);				ghost_data_w[ghost_data_ptr_w + 1] = (byte)(i & 0xFF);				g_action = 0;				switch(key_action)				{//					case Canvas.KEY_NUM0:	//						g_action = 1; //						break;//					case Canvas.KEY_NUM1:	//						g_action = 2; //						break;					case -1:					case Canvas.KEY_NUM2:							g_action = 3; 						break;//					case Canvas.KEY_NUM3:	//						g_action = 4; //						break;					case -3:									case Canvas.KEY_NUM4:  						g_action = 5; 						break;      					case -5:					case -6:					case Canvas.KEY_NUM5:							g_action = 6; 						break;					case -4:					case Canvas.KEY_NUM6:							g_action = 7; 						break;//					case Canvas.KEY_NUM7:	//						g_action = 8; //						break;					case -2:					case Canvas.KEY_NUM8:							g_action = 9; 						break;//					case Canvas.KEY_NUM9:	//						g_action = 10;//						break;					case -7:					case Canvas.KEY_STAR:							g_action = 11; 						break;//					case Canvas.KEY_POUND:	//						g_action = 12; //						break;				}				g_action |= man.j_wind_dest << 4;				g_action |= man.j_wind_power_dest << 8;				g_action |= man.ji1 << 10;				g_action |= man.ji2 << 13;				ghost_data_w[ghost_data_ptr_w + 2] = (byte)((g_action & 0xFF00) >> 8);				ghost_data_w[ghost_data_ptr_w + 3] = (byte)(g_action & 0x00FF);				ghost_data_ptr_w += 4;			}		}		catch(Exception ex)		{			ghost_data_w = null;			ghost_data_count_w = ghost_data_ptr_w = 0;		}	}    static void pause()    {    	paused = true;    	state_old = state;

⌨️ 快捷键说明

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