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

📄 main.java

📁 之前有人传过`不过是没有资源只有代码的` 我在重新传一遍有资源的`是一个滑雪的游戏`类似flash的打企鹅`
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
		action = key_action = NO_ACTION;		m_paused = true;		m_state = state;		menuLevel = 0;		m_time_left = System.currentTimeMillis();		midlet.main.returnMenu();    }    static void finish_skater_run()    {		state = STATE_SKATER_RUN_FINISH;		state_delay = 40;		go_delay = 20;		go_index = 3;		time_finish = time_total = time_current;		total_points = (int)(8000 - (time_total - 40000) / 10);		if (total_points < 0) total_points = 0;		ghost_data_count_w = ghost_data_ptr_w;    }    static void finish_biathlon_run()    {		go_delay = 20;		go_index = 3;		time_finish = time_current;		time_extra = man.missed * 5000;		time_total = time_finish + time_extra;		total_points = (int)(9000 - (time_total - 90000) / 10);		if (total_points < 0) total_points = 0;		ghost_data_count_w = ghost_data_ptr_w;    }    static void update_skater_run()    {    	readGhost();    	if (ghost != null) ghost.update_skater_run(ghost_action);    	writeGhost(man.update_skater_run(key_action));    	rel_dx = man.x - a_x_d;    	if ((s_w - x_bound < rel_dx) && (man.dx > 0)) a_x_d += man.dx;    	if (a_x_d > a_x_range) a_x_d = a_x_range;		frames_passed++;    }        static void update_biathlon()    {    	readGhost();    	if (ghost != null) ghost.update_biathlon(ghost_action);    	writeGhost(man.update_biathlon(key_action));    	if (man.state == STATE_BIATHLON_SHOOT) action = key_action = NO_ACTION;    	rel_dx = man.x - a_x_d;    	rel_dy = start_y - man.y - a_y_d;    	if ((x_bound > rel_dx) && (man.dx < 0))    	{    		a_x_d += man.dx;    	}    	if ((s_w - x_bound < rel_dx) && (man.dx > 0))    	{    		if ((man.x % track_x_sum > shoot_bound) && man.shootEnabled){}    		else     		if ((man.state == STATE_BIATHLON_RUN) || (man.state == STATE_BIATHLON_RUN_FINISH)) a_x_d += man.dx;    	}    	if ((y_bound_top > rel_dy) && (man.dy > 0))    	{    		a_y_d -= man.dy;    	}    	if ((y_bound_bottom < rel_dy) && (man.dy < 0))    	{    		a_y_d -= man.dy;    	}		frames_passed++;    }    void update_skijump()    {    	if (ghost != null)    	{	    	readGhost();    		ghost.update_skijump_1(ghost_action);    	}    	man.update_skijump_1(key_action);   		writeGhost(man.processed);		frames_passed++;		key_action = action = NO_ACTION;    	if (ghost != null) ghost.update_skijump_2();    	man.update_skijump_2();		if (go_delay > 0)		{			if (--go_delay <= 0) 			{				if (go_index < 2)				{					go_delay = 20;					go_index++;					if ((go_index >= 2) && (man.j_state == 0))					{						man.j_state = 1;						man.j_t1 = 80;						man.j_ay = 4096;						if (ghost != null)						{							ghost.j_state = 1;							ghost.j_t1 = 80;							ghost.j_ay = 4096;						}					}					else					{					}					}				if (go_index >= 3)				{					if (man.j_state == 18)					{						menuLevel = 9;						returnMenu();						return;					}					else					{						ghost_data_count_w = ghost_data_ptr_w;						go_delay = 0;						state_delay = 40;						state = STATE_SKIJUMP_RUN_SCORES;					}				}			}		}    	if (ghost != null) ghost.update_skijump_3();    	man.update_skijump_3();    	rel_dx = man.j_x - a_x_d;    	rel_dy = man.j_y - a_y_d;    	if (x_bound < rel_dx)     	{    		if ((man.j_state == 18) && (man.j_v > 0)) a_x_d += 2;    		else a_x_d += man.j_dx;    	}    	if (a_x_d > a_x_range) a_x_d = a_x_range;    	if (y_bound_bottom < rel_dy)    	{     		if ((man.j_state == 18) && (man.j_v > 0)) a_y_d += 2;    		else a_y_d += man.j_dy;    	}		y_bg_top = ((s_h - fBg.fh) >> 1) - (a_y_d >> 3) + 10;	}	void updateEditor()	{		try		{		    switch (action)		    {				case -3:				case Canvas.KEY_NUM4:if (--editX < 0) editX = 10;						break;				case -4:				case Canvas.KEY_NUM6:if (++editX > 10) editX = 0;						break;				case -1:											case Canvas.KEY_NUM2:if (--editY < 0) editY = 3;						break;				case -2:				case Canvas.KEY_NUM8:if (++editY > 3) editY = 0;						break;				case -6:				case -5:				case Canvas.KEY_NUM5:						ch = letters.charAt(editY * 11 + editX);						if (ch == '_')						{							if (idx > 0) idx--;						}						else						{							if (ch != '#')							{								editText[idx] = ch;								if (idx + 1 < editText.length) idx++;								else ch = '#';							}							if (ch == '#')							{								if (new String(editText).trim().length() > 0)								{									state = STATE_EDITOR_FINISH;										state_delay = 2;								}							}							}						break;				case NO_ACTION:break;				case -7:				case KEY_STAR:						action = NO_ACTION;						editBack();			}		}		catch(Exception ex){}        action = NO_ACTION;	}	void updateMenu()	{		if (vMenu != null)		{			try			{			    switch (action)			    {					// left					case -3: // 7210					case Canvas.KEY_NUM4://							menuIndex -= menuRange;							break;					// right					case -4: // 7210					case Canvas.KEY_NUM6://							menuIndex += menuRange;							break;					// up					case -1: // 7210					case Canvas.KEY_NUM2:							if (isPointer) menuIndex --;							else menuDisp -= menuRange;							break;					// down					case -2: // 7210					case Canvas.KEY_NUM8:							if (isPointer) menuIndex ++;							else menuDisp += menuRange;							break;					// select					case -5: // 60					case -6: // 7210					case Canvas.KEY_NUM5:							menuOk(menuIndex);							break; 						case NO_ACTION:break;					// exit					case -7: // 7210					case KEY_STAR:					        action = key_action = NO_ACTION;							if (menuLevel != 0)							{								resourcesLoaded = false;								menuBack(menuLast < 0 ? 0 : menuLast);							}				}				if (isPointer)				{					if (menuIndex < 0) menuIndex = 0;					if (menuIndex >= vMenu.size()) menuIndex = vMenu.size() - 1;					j = menuSize - vMenuName.size();					for (i = 0, n = 0; i < vMenu.size(); i++)					{						v = (Vector)vMenu.elementAt(i);									if (i == menuIndex) // correct menuDisp to scroll menu						{							while(n < menuDisp) menuDisp --;							while(menuDisp + menuRange <= (n + v.size() - 1) && (menuDisp + menuRange <= j)) 								menuDisp ++;						}						n += v.size();					} 				}				else				{					if (menuDisp + menuRange > vMenu.size()) menuDisp = vMenu.size() - menuRange;					if (menuDisp < 0) menuDisp = 0;				}			}			catch(Exception ex){}		}        action = key_action = NO_ACTION;	}    // graphics methods *******************************************************************************    static Graphics gd = null;    static void createImage(int index, String resourceName) throws IOException    {		img[index] = Image.createImage(resourceName);    }    static int getImageWidth(int index)    {                		return img[index].getWidth();    }    static int getImageHeight(int index)    {                		return img[index].getHeight();    }    static void setClip(int x,int y,int w,int h)    {    	gd.setClip(x,y,w,h);    }    static void drawImage(int index,int x,int y)    {    	gd.drawImage(img[index],x,y,20);    }    static void setColor(int color)    {		gd.setColor(color);    	    }    static void fillRect(int x, int y, int w, int h)    {    	gd.fillRect(x,y,w,h);    }    static void setFont(Font font)    {    	gd.setFont(font);    }    static void drawLine(int x1, int y1, int x2, int y2)    {    	gd.drawLine(x1, y1, x2, y2);    }    static void drawString(String str, int x, int y, int pos)    {    	gd.drawString(str,x,y,pos);    }    static void drawRect(int x1, int y1, int x2, int y2)    {    	gd.drawRect(x1,y1,x2,y2);    }    //    static long tt=0;    static int state_delay = 0;    static int go_delay = 0, go_index = 0;    boolean isBoard = false;    static int pstate = -1, state_old;    static boolean paused = false;    static boolean isPainting = false;    public void paint(Graphics g)    {    	doPaint(g);    }    public void doPaint(Graphics gd)    {	    isPainting = true;	    Frame.cnt = 0;		tt = System.currentTimeMillis();		time_current = 0;		if (time_start > 0) time_current = tt - time_start;		isBoard = false;		this.gd = gd;    	try    	{	    	setFont(font);			setClip(0,0,s_w,s_h);	    	pstate = paused ? state_old : state;			if (running && (initOK || (pstate == STATE_INTRO) || (pstate == STATE_LOGO)))			{				switch (pstate)				{				case STATE_SKIJUMP_RUN:				case STATE_SKIJUMP_RUN_FINISH:					setColor(0x88AAEE);					fillRect(0,0,s_w,y_bg_top);					setColor(0xFFFFFF);					fillRect(0,fBg.fh + y_bg_top,s_w,s_h);					x = (a_x_d >> 3) % fBg.fw;				// background    		     	for (i = - x; i < s_w; i+= fBg.fw) 						fBg.draw(i,y_bg_top);					y = y_bg_top + fBg.fh - fTree[0].fh + 10;					for (i = 0, j = -2; i < track_width; i += 40, j = -j)					{						x = i - (a_x_d >> 2);						if ((x > - fTree[0].fw) && (x <= s_w))							fTree[0].draw(x,y + j);					}                    setColor(0xffFFFF);                    //////////////////////////////////////////////////////////////////////////////////////                    for (i = 0, j = 0; i < track_x[0]; i += fT[0].fw, j += 34)                    {                    	x = i - a_x_d;                    	y = j + start_y - a_y_d;                    	if ((x >= - fT[0].fw) && (x <= s_w))                    	{                    		setClip(0,0,s_w,s_h);                    		fillRect(x, y + 34, fT[0].fw, s_h - y - 34);							fT[0].draw(x,y);						}                    }                    //////////////////////////////////////////////////////////////////////////////////////                   	x = i - a_x_d;                   	y = j + start_y - a_y_d;                   	if ((x >= - fT[1].fw) && (x <= s_w))                   	{                   		setClip(0,0,s_w,s_h);                   		fillRect(x, y + 34, fT[0].fw - 10, s_h - y - 34);						fT[1].draw(x,y);                    						}					j += Dynamic.J_HEIGHT + 7;					i += track_x[1] + track_x[2];					w2 = i + track_x[3];					for (k = 0, i2 = 0; i < w2; i += fT[2].fw, j += 16, k = 1 - k, i2 += 10) // diagonal landing					{                    	x = i - a_x_d;                    	y = j + start_y - a_y_d;                    	if ((x >= - fT[2].fw) && (x <= s_w) && (y <= s_h))                    	{                    		setClip(0,0,s_w,s_h);                    		fillRect(x, y + 16, fT[2].fw, s_h - y - 16);							fT[2].draw(x,y);						}                    	if ((k == 0) && (x >= - 28) && (x <= s_w))                    	{								fSign.draw(x,y - 12);        	            		intToString(i2,0,3);    	                		buf[3] = 'm';		                   		drawChars(0,4,x + 1, y - 8,2);						}					}					w2 = i + track_x[4];					for (; i < w2; i += fT[3].fw)	// horizontal landing					{                    	x = i - a_x_d;                    	y = j + start_y - a_y_d;                    	if ((x >= - fT[3].fw) && (x <= s_w))                    	{                    		setClip(0,0,s_w,s_h);                    		fillRect(x, y + 30, fT[2].fw, s_h - y - 30);							fT[3].draw(x,y);						}					}            		setClip(0,0,s_w,s_h);					if (ghost != null)					{						ghost.drawSJ();						drawGhostName(ghost.j_x - a_x_d + 8, ghost.y - a_y_d - 24, 0xFF1020);					}            		setClip(0,0,s_w,s_h);					man.drawSJ();					abci = 0;                    str = text[41]; // wind                    x = s_w - getStringWidth(str);                    y = 1;                    x1 = s_w - fMeter.fw - 4;                    y1 = y + 11;                    x2 = x1 + 6;                    y2 = y1 + 16;//#if Size_0            	    x -= 10;	                x2 = s_w - 8;                    y2 = 1;        	        x1 = x2 - 20;    	            y1 = y + 10;//#endif                    drawString(str,x,y);					setClip(0, 0, s_w, s_h);					fMeter.draw(x1,y1);					x1 += 8;					y1 += 8;					w2 = x1 + (cos[man.j_wind] >> 5);					h2 = y1 + (sin[man.j_wind] >> 5);					setClip(0,0,s_w,s_h);					setColor(0xFF0000);					drawLine(x1, y1, w2, h2);					fMeterred.draw(w2 - 2,h2 - 2);					setClip(0, 0, s_w, s_h);					fChess.draw(x2,y2);					fBoard.draw(x2,y2 + 8);					for (y = 4; y < 50; y += 14)					{						fTarget.draw(x2,y + y2, x2,y2,6,50 - man.j_wind_power);					}					if (ghost != null)						if (m_ghost != null) drawString(m_ghost,2,2);						else drawString(text[30],2,2); // ghost					break;				case STATE_SKIJUMP_RUN_SCORES:					y = s_h >> 1;					drawBgm();					drawString(text[31],2,y - 24); // length					intToString(distance,0,3);					drawChars(0,3,s_w - 22,y - 27,1);					drawString(text[32],2,y - 8); // style					intToString(points,0,3);					drawChars(0,3,s_w - 22,y - 10,1);					setColor(0xA0A000);					setClip(0,0,s_w,s_h);					drawLine(2,y + 4,s_w - 2,y + 4);					drawString(text[33],2,y + 11); // score					intToString(total_points,0,3);					drawChars(0,3,s_w - 22,y + 9,1);					break;				case STATE_SKATER_RUN:				case STATE_SKATER_RUN_FINISH:

⌨️ 快捷键说明

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