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

📄 dynamic.java

📁 之前有人传过`不过是没有资源只有代码的` 我在重新传一遍有资源的`是一个滑雪的游戏`类似flash的打企鹅`
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
					a2 = 2;
					begin = false;
				}
			}

	       	if (period > 0)
			{
        	   	aa = 2;
        		if(task <= time)
	        	{
    	        	next();
	    	    	period--;
        			task += taskInterval;
		        }
    	        time += 75;
        	}

        }

    	dx = 0;

		v += aa;
		if (v < 0) v = 0;
		if (v > 160) v = 160;

		s += v;

		dx = x;
		x = s >> 5;
		dx = x - dx;
        //////////////////////////////////////////////////////////////////////////////////
		if (x < track_x_cur) 
		{
			p --;
			track_x_cur -= Main.track_x[p];
			track_y_cur -= Main.track_y[p];
		}
		if (x > (track_x_cur + Main.track_x[p]))
		{
			track_x_cur += Main.track_x[p];
			track_y_cur += Main.track_y[p];
			p ++;
		}
		if (p >= Main.track_x.length)
		{
			p = 0;
			Main.rounds_passed++;
			shootEnabled = true;
		}

		if (x + 32 > Main.track_width_one)
		{
			if (!finished)
			{
				finished = true;
				state = Main.STATE_BIATHLON_RUN_FINISH;
				state_delay = 40;
				if (!isGhost) Main.finish_biathlon_run();
			}
		}

		rx = x - track_x_cur;

		if (rx > 100 && (p + 1 >= Main.track_x.length) && shootEnabled)
		{
			s_v = v; 					// store current speed for heartbeat control
			shootEnabled = false;
			aim_n = 0;
			aim_x = -10;
			aim_y = 0;
			aim_dy = 5 + (s_v >> 5);
			aim_amplitude = 30;
			aim_x_range = 20;
			targets = new int[5];
			for (i = 0; i < targets.length; i++) targets[i] = 0;
			heart_delay = (v >> 5) + 1;
			heart_index = 0;
			state = Main.STATE_BIATHLON_SHOOT;
		}

		dy = y;
		y = track_y_cur;
		if (Main.track_y[p] < 0) y -= (rx >> 2);
		if (Main.track_y[p] > 0) y += (rx >> 2);
		dy = y - dy;

		return processed;
    }

    boolean update_biathlon_shoot(int action)
    {
    	aim_dx = 0;

    	processed = false;

		switch (action)
	    {
            case -3:
			case Canvas.KEY_NUM4:	
					if (state == Main.STATE_BIATHLON_SHOOT) aim_dx = -2;
			    	processed = true;
					break;
			case -4:
			case Canvas.KEY_NUM6:
					if (state == Main.STATE_BIATHLON_SHOOT) aim_dx = 2;
			    	processed = true;
					break;
			case -5:
			case -6:
			case Canvas.KEY_NUM5:
					if (state == Main.STATE_BIATHLON_SHOOT)
					{
						if (aim_y < 12 && (aim_y > -12) && (aim_x < 8) && (aim_x > -8))
						{
							targets[aim_n] = -1;
						}
						else
						{
							targets[aim_n] = 6;
							missed++;
						}
						aim_x = -10;
						if (++aim_n >= targets.length)
						{
							state_delay = 20;
							state = Main.STATE_BIATHLON_SHOOT_FINISH;
						}
					}
//					action = Main.NO_ACTION;
			    	processed = true;
					break;
			case Main.NO_ACTION:
					break;
			case -7:
			case Canvas.KEY_STAR:
			    	processed = true;
					Main.pause();
		}

		for (i = 0; i < targets.length; i++) 
			if (targets[i] > 0) targets[i]--;

		if (s_v > 0) s_v--;

		aim_y += aim_dy;
		if (aim_y < -aim_amplitude)
		{
			aim_dy = 5 + (s_v >> 5);
		}
		if (aim_y > aim_amplitude)
		{
			aim_dy = - 5 - (s_v >> 5);
		}

		aim_x += aim_dx;
		if (aim_x < - aim_x_range)
		{
			aim_x = - aim_x_range;
		}
		if (aim_x > aim_x_range)
		{
			aim_x = aim_x_range;
		}

		if (--heart_delay <= 0)
		{
			heart_delay = 6 - (s_v >> 5);
			heart_index = 1 - heart_index;
		}
		return processed;
    }

    int j_state = 0;
    int j_x = 0;
    int j_y = 0;
    int j_jx = 0, j_jxr;
    int j_jy = 0;
    int j_v = 0, j_s = 0, j_vy = 0, j_sy = 0, j_h, j_ay;
    int j_dx = 0;
    int j_dy = 0;
    int j_i1, j_i2, j_t1, j_t2, j_wind, j_wind_power, j_wind_dest, j_wind_power_dest, j_wind_d, jw;
    int ji1,ji2;
	int track_x_sum;

	int j_x0, j_y0;

    void update_skijump_1(int action)
    {
    	processed = false;
    	// random events
    	if (j_state == 13)
    	{
    		if (!isGhost)
    		{
    			i = Main.rnd(256);
	    		j = Main.rnd(256);

				if ((i < 12)  && (j_i1 < 3) && (j_i1 > 0)) { j_i1--; processed = true; }
				if ((i > 244) && (j_i1 > 1) && (j_i1 < 4)) { j_i1++; processed = true; }

				if ((j < 12)  && (j_i2 < 3) && (j_i2 > 0)) { j_i2--; processed = true; }
				if ((j > 244) && (j_i2 > 1) && (j_i2 < 4)) { j_i2++; processed = true; }
			}
			if (j_i1 != 2)
			{
				if (++j_t1 > 8)
				{
					j_t1 = 0;
					Main.points --;
					if ((j_i1 == 0) || (j_i1 == 4)) Main.points --;
				}
			}

			if (j_i2 != 2)
			{   	
				if (++j_t2 > 8)
				{
					j_t2 = 0;
					Main.points --;
					if ((j_i2 == 0) || (j_i2 == 4)) Main.points --;
				}
			}
    	}

    	if (!isGhost)
    	{
    		if (Main.rnd(256) < 10 && (j_wind_power > 0) && (j_wind == j_wind_dest))
    		{
    			j_wind_dest = Main.rnd(16);
    			j_wind_d = j_wind_dest - j_wind;
    			if (j_wind_d > 8 || (j_wind_d < -8)) j_wind_d = - j_wind_d;
    			j_wind_d = j_wind_d > 0 ? 1 : -1;
    			processed = true;
    		}
    		if (Main.rnd(256) < 8 && (j_wind_power == jw))
    		{
    			j_wind_power_dest = Main.rnd(4);
    			jw = j_wind_power_dest * 50 / 3;
    			processed = true;
    		}
    	}

    	ji1 = j_i1;
    	ji2 = j_i2;
	    switch (action)
	    {
			case -3:
			case Canvas.KEY_NUM4:
					if (j_i1 < 4) j_i1++;
					if (j_i1 == 2) j_t1 = 0;
					processed = true;
					break;
			case -4:
			case Canvas.KEY_NUM6:
					if (j_i1 > 0) j_i1--;
					if (j_i1 == 2) j_t1 = 0;
					processed = true;
					break;
			case -1:							
			case Canvas.KEY_NUM2:
					if (j_i2 < 4) j_i2++;
					if (j_i2 == 2) j_t2 = 0;
					processed = true;
					break;
			case -2:
			case Canvas.KEY_NUM8:
					if (j_i2 > 0) j_i2--;
					if (j_i2 == 2) j_t2 = 0;
					processed = true;
					break;
			case -6:
			case -5:
			case Canvas.KEY_NUM5:
					if (j_state == 1)	// start to slide
					{
						j_state = 10;
					}
					else
					if (j_state == 12)  // jump from the ramp
					{
						j_state = 13;
						j_dy = j_y;

						j_jx = j_x; // coords of jump
						j_jy = j_y;

						j_x0 = track_x_sum;
						j_y0 = j_y;

						j_vy = j_v = 0;
						j_sy = j_s = 0;

						j_jxr = track_x_sum;

						j_t1 = j_t2 = 0;

						track_x_sum += Main.track_x[3];
					}
					else
					if (j_state == 13)	// prepare to landing
					{
						j_state = 20;
						if (j_i2 == 4)  // wrong landing - should fall
						{
							j_state = 14;		
							j_sy >>= 1;
						}
						else
						{
							if (j_i2 == 3) // mistake
							{
								Main.points -= 5;		
							}
							j_h = j_y;
							j_dx --;
							j_v = j_dx << 5;

							j_ay += 1024;
						}
					}
					processed = true;
					break;
			case Main.NO_ACTION:break;
			case -7:
			case Canvas.KEY_STAR:
					if (Main.go_index == 2)
					{
						processed = true;
						Main.pause();
					}
		}
	}

	void update_skijump_2()
	{
    	if (j_wind != j_wind_dest)
    	{
    		j_wind += j_wind_d;
    		if (j_wind > 15) j_wind = 0;
    		if (j_wind < 0) j_wind = 15;
    	}
    	if (j_wind_power > jw) j_wind_power--;
    	else
    	if (j_wind_power < jw) j_wind_power++;
    }

    void update_skijump_3()
    {
		j_dy = j_y;
		switch (j_state)
		{
		case 1:
			if (-- j_t1 <= 0)	// starts to slide by itself
			{
				if (!isGhost) Main.points -= 5;
				j_state = 10;
			}
			break;
		case 10: // ramp diagonal
			j_v += 5;
			if (j_v > 160) j_v = 160;

			j_s += j_v;

			j_dx = j_x;
			j_x = j_s >> 5;
			j_dx = j_x - j_dx;

			j_y = Main.start_y + j_x * 34 / 48; 

			if (j_x >= track_x_sum)
			{
				j_state = 11;
				track_x_sum += Main.track_x[1];
			}
			break;
		case 11: // ramp horiz part 1
			j_x += j_dx;
			j_y += (j_dx >> 2); 

			if (j_x >= track_x_sum)
			{
				j_state = 12;
				track_x_sum += Main.track_x[2];
			}
			break;
		case 12: // ramp horiz part 2
			j_x += j_dx;
			if (j_x >= track_x_sum)
			{
				j_x0 = track_x_sum;
				j_y0 = j_y;

				j_state = 14;		// falling!
				track_x_sum += Main.track_x[3];
				j_dy = j_y;

				j_jx = j_x; // coords of jump
				j_jy = j_y;

				j_vy = 0;
				j_sy = 0;

//				y_bound_bottom = s_h - 30;
			}
			break;
		case 13: // fly
		case 14:
		case 20:
			j_s += 8192 + (Main.cos[j_wind] * j_wind_power >> 5);

			j_dx = j_x;
			j_x = j_jx + (j_s / 1600);
			j_dx = j_x - j_dx;

			j_vy += j_ay - (j_vy >> 1) - (Main.sin[j_wind] * j_wind_power >> 5);


			j_sy += j_vy;
			j = j_state == 14 ? 900 : 1800;
			j_y = j_jy + (j_sy / j); 

			y = j_y0 + J_HEIGHT + ((j_x - j_x0) >> 1); // check the surface touch
			if (j_y >= y)
			{
				if ((j_state == 13)	|| (j_state == 14) || (j_y - j_h > 100))// was not prepared - fall down
				{
					j_jx = j_x;
					j_s = j_x << 5;

//					if (j_state == 14) 
					j_v = j_dx << 5;

					j_y = j_jy = y;
					if (!isGhost) Main.y_bound_bottom = Main.s_h * 3 / 4;

					j_state = 18;
				}
				else
				{
					j_dx ++;
					j_v = j_dx << 5;
				
					j_state = 15;
					j_jx = j_x;
					j_y = j_jy = y;

					if (!isGhost)
					{
						Main.distance = (j_x - j_jxr) * 10 / 32;
						Main.total_points = Main.distance + Main.distance + Main.points;
						Main.m_v1 = Main.distance;
						Main.m_v2 = Main.points;
						Main.y_bound_bottom = Main.s_h * 3 / 4;
					}
				}
			}
			break;
		case 15: // landing_diagonal
			j_x += j_dx;
			j_y = j_jy + ((j_x - j_jx) >> 1); 
			if (j_x >= track_x_sum)
			{
				j_state = 16;
				track_x_sum += Main.track_x[4];
				j_s = j_x << 5;
			}
			break;
		case 16:
		case 17: // landing horiz 
			if (j_x < track_x_sum)
			{
				j_v -= 3;
				if ((j_v < 110) && (j_state == 16))
				{
					j_state = 17;
					if (!isGhost)
					{
						Main.go_delay = 40;
						Main.go_index = 3;
					}
				}
				if (j_v < 0) j_v = 0;

				j_s += j_v;

				j_dx = j_x;
				j_x = j_s >> 5;
				j_dx = j_x - j_dx;
			}
			break;
		case 18: // landing_diagonal after falling
			if ((j_x + 18 < track_x_sum) && (j_v > 0))
			{
				j_v -= 4;
				j_s += j_v;
				j_x = j_s >> 5;
				j_y = j_jy + ((j_x - j_jx) >> 1); 
			}
			else
			{
				j_v = 0;

				if (!isGhost)
				if (Main.go_index != 3)
				{
					Main.go_index = 3;
					Main.go_delay = 40;
				}
			}
		}

		j_dy = j_y - j_dy;
    }

    void drawSJ()
    {
    	y = j_y;
    	if (!isGhost) y += 3;
		// drawing ski man

//#if Nokia
		if (j_state <= 10) Main.fSn[0].draw(j_x - Main.a_x_d - 11, y - Main.a_y_d - 24);
		if ((j_state == 11) || (j_state == 12)) Main.fSn[1].draw(j_x - Main.a_x_d - 16, y - Main.a_y_d - 28);
		if (j_state == 13)
		{
			Main.fSn[2].draw(j_x - Main.a_x_d, y - Main.a_y_d - 26,j_i1);
			Main.fSn[3].draw(j_x - Main.a_x_d - 12, y - Main.a_y_d - 8,j_i2);
		}
		if (j_state == 14) 
		{
			Main.fSn[2].draw(j_x - Main.a_x_d, y - Main.a_y_d - 26,0);
			Main.fSn[3].draw(j_x - Main.a_x_d - 12, y - Main.a_y_d - 8,4);
		}
		if ((j_state == 15) || (j_state == 20)) Main.fSn[4].draw(j_x - Main.a_x_d - 20, y - Main.a_y_d - 30);
		if (j_state == 16) Main.fSn[5].draw(j_x - Main.a_x_d - 20, y - Main.a_y_d - 32);
		if (j_state == 17) Main.fSn[6].draw(j_x - Main.a_x_d - 20, y - Main.a_y_d - 32);
		if (j_state == 18) 
		{
			Main.fSn[7].draw(j_x - Main.a_x_d - 20, y - Main.a_y_d - 12);
			Main.fSnow.draw(j_x - Main.a_x_d + 10, y - Main.a_y_d + 10);
		}
//#else
		if (j_state <= 10) Main.fSn[0].draw(j_x - Main.a_x_d - 11, y - Main.a_y_d - 24);
		if ((j_state == 11) || (j_state == 12)) Main.fSn[1].draw(j_x - Main.a_x_d - 16, y - Main.a_y_d - 28);
		if (j_state == 13)
		{
			Main.fSn[2 + j_i1].draw(j_x - Main.a_x_d, y - Main.a_y_d - 26);
			Main.fSn[7 + j_i2].draw(j_x - Main.a_x_d - 12, y - Main.a_y_d - 8);
		}
		if (j_state == 14) 
		{
			Main.fSn[2].draw(j_x - Main.a_x_d, y - Main.a_y_d - 26);
			Main.fSn[11].draw(j_x - Main.a_x_d - 12, y - Main.a_y_d - 8);
		}
		if ((j_state == 15) || (j_state == 20)) Main.fSn[12].draw(j_x - Main.a_x_d - 20, y - Main.a_y_d - 30);
		if (j_state == 16) Main.fSn[13].draw(j_x - Main.a_x_d - 20, y - Main.a_y_d - 32);
		if (j_state == 17) Main.fSn[14].draw(j_x - Main.a_x_d - 20, y - Main.a_y_d - 32);
		if (j_state == 18) 
		{
			Main.fSn[15].draw(j_x - Main.a_x_d - 20, y - Main.a_y_d - 12);
			Main.fSnow.draw(j_x - Main.a_x_d + 10, y - Main.a_y_d + 10);
		}

//#endif
    }
}

⌨️ 快捷键说明

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