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

📄 gamecanvas.java

📁 极限运动攀岩 wtk编译就能运行.有详细源码
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
				else if( gState == 6 )
				{
					// 回主界面
					str[0] = "比分登记完成";
					// 消息
					str[1] = "完成";
					str[2] = "继续";
					str[3] = "";
					str[4] = "";
				}
				// 通讯错误 (high score发送时)
				else if( gState == 7 )
				{
					// 回主界面
					str[0] = "通讯错误";
					// 消息
					str[1] = "是否继续联接";
					str[2] = "联接";
					str[3] = "退出";
					str[4] = "  ";
				}
				// 没有high score
				else if( gState == 8 )
				{
					// 回主界面 
					str[0] = "数据错误";
					// 消息
					str[1] = "最佳并列";
					str[2] = "没有过关";
					str[3] = "以后再登记";
					str[4] = "是...";
				}
				// 排列次序确认
				else if( gState == 9 )
				{
					// 回主界面
					str[0] = "确认顺序";
					// 消息
					str[1] = "立刻排序";
					str[2] = "确认排列次序吗?";
					str[3] = "";
					str[4] = "";
				}

				// 文字列宽度取得
				i = font.stringWidth(str[0])/2;
				j = font.stringWidth(str[1])/2;

				// 回主界面
				offg.setColor( 0xff0000 );
 				// g.setColor( 0xff0000 );
				DrawText( str[0], 60-i, 20 );

				// 消息
 				// g.setColor( 0x000000 );
				offg.setColor( 0x000000 );
				DrawText( str[1], 60-j, 45 );
				DrawText( str[2], 60-j, 63 );
				DrawText( str[3], 60-j, 81 );
				DrawText( str[4], 60-j, 99 );
				break;
			}
			//------------------------------------------------------------------
			// 操作说明画面绘画
			//------------------------------------------------------------------
			case 11:
			{
				// 背景绘画
				for( i = 2;i >= 0;i--)
					for( j = 2;j >= 0;j--)
						DrawImage( 0, i*40, j*40);

				// 说明文设定
				if( gState == 1 )
				{
					str[0] = "游戏说明1";
					str[1] = "玩家控制游戏角色的";
					str[2] = "左右手来爬上墙壁";
					str[3] = "左手:";
					str[4] = "向左,向上,向下键";		
					str[5] = "右手:";
					str[6] = "向右,向上,向下键";
				}
				else if( gState == 2 )
				{
					str[0] = "游戏说明2";
					str[1] = "控制左手时按向右键";
					str[2] = "或在控制右手时按左";
					str[3] = "键可以切换要控制的";
					str[4] = "手臂,按左软键可以";
					str[5] = "选择进入跳跃模式,";
					str[6] = "或选择回到攀登模式";
					
				}
				else if( gState == 3 )
				{
					str[0] = "游戏说明3";
					str[1] = "练习就能知道游戏中";
					str[2] = "可以供角色抓住的";
					str[3] = "东西--支点的位置";
					str[4] = "即攀登或跳跃能到达";
					str[5] = "的位置";
					str[6] = "";
				}
				else if( gState == 4 )
				{
					str[0] = "游戏说明 4";
					str[1] = "抓住支点的时候,右";
					str[2] = "边能量槽会不断减少";
					str[3] = "只要切换当前控制";
					str[4] = "的手臂,能量槽就能";
					str[5] = "恢复";
					str[6] = "";
				}
				else if( gState == 5 )
				{
					str[0] = "游戏说明 5";
					str[1] = "如果能量槽数值为零";
					str[2] = "判为失误,攀登时间";
					str[3] = "加10秒,并且要从画";
					str[4] = "面的最下方重新开始";
					str[5] = "";
					str[6] = "";
				}
				else if( gState == 6 )
				{
					str[0] = "游戏说明6";
					str[1] = "请在限定的三分钟内";
					str[2] = "到达终点,超过三分";
					str[3] = "钟,则游戏结束";
					str[4] = "(game over)";
					str[5] = "";
					str[6] = "";
				}
		

				// 说明框框绘画
 				// g.setColor( 0xffffff );
				offg.setColor( 0xffffff );
				k = font.stringWidth(str[0])/2;
				i = font.stringWidth(str[1])/2;
				j = font.getHeight()+5;
 				// g.fillRect( sys[SYS_DISP_W]/2-sys[SYS_DRAW_X]-i-3, sys[SYS_DISP_H]/2-sys[SYS_DRAW_Y]-j*7/2, i*2+6, j*7+5 );
				offg.fillRect( width/2-midWidth-i-3, height/2-midHeight-j*7/2, i*2+6, j*7+5 );

				// 消息绘画
 				// g.setColor( 0x000000 );
				offg.setColor( 0x000000 );
				DrawText(str[0], width/2-midWidth-k, height/2-midHeight-j*7/2+2);
				DrawText(str[1], width/2-midWidth-i, height/2-midHeight-j*7/2+j+4);
				DrawText(str[2], width/2-midWidth-i, height/2-midHeight-j*7/2+j*2+4);
				DrawText(str[3], width/2-midWidth-i, height/2-midHeight-j*7/2+j*3+4);
				DrawText(str[4], width/2-midWidth-i, height/2-midHeight-j*7/2+j*4+4);
				DrawText(str[5], width/2-midWidth-i, height/2-midHeight-j*7/2+j*5+4);
				DrawText(str[6], width/2-midWidth-i, height/2-midHeight-j*7/2+j*6+4);

				// 箭形符号表示
				if( gState > 1 )
					DrawImage(54, width/2-midWidth-i-15, height/2-midHeight-5,120,0,10,16);
				if( gState < 6 )
					DrawImage(54, width/2-midWidth+i+5, height/2-midHeight-5,130,0,10,16);
				break;
			}
		}

		g.drawImage(backImg,0,0,Graphics.LEFT | Graphics.TOP);

		//------------------------------------------------------------------------------
		// 全面涂抹游戏画面以外的部分(全景色共通)
		//------------------------------------------------------------------------------
		g.translate( -g.getTranslateX() , -g.getTranslateY()  );
		g.setColor(0x141414);

		if( midHeight > 0 )
		{
		    // 上和下的余白
		    g.fillRect( 0, 0, width, midHeight );
		    g.fillRect( 0, midHeight + 120, width, midHeight+1 );
		}

		if( midWidth > 0 )
		{
		    // 左右的余白
		    g.fillRect( 0, midHeight, midWidth, 120 );
		    g.fillRect( midWidth + 120, midHeight, midWidth, 120 );
		}
		if(iMenu&&((gameState==5)||(gameState==7)))		
		{	// 画菜单
			// g.setClip(0,height-62,65,62);
       		g.setColor(0x103C9C);
       		g.drawRect(1,height-54,60,50);
			g.setColor(0x000000);
       		g.fillRect(2,getHeight()-53,58,48);
       		g.setColor(0xFFFFFF);
			g.drawString(okStr,8,height-45,20);
			g.drawString(cancelStr,8,height-25,20);
			g.setColor(0xcccccc);
       		g.drawRect(2,height-49+rowIndex*20,56,20);
		}
		// 绘画结束
		sysData[13] = 0;
		gameData[30] = 0;			
	}

	//------------------------------------------------------------------------------
	//
	// 全面涂抹游戏画面以外的部分
	//
	//------------------------------------------------------------------------------
	public final void ClearOuterSpace()
	{
 		// g.translate( -g.getTranslateX(), -g.getTranslateY() );
 		// g.setColor( 0x111111 );
		offg.translate( -g.getTranslateX(), -g.getTranslateY() );
		offg.setColor( 0x111111 );
		if( midHeight != 0 )
		{
			// 上和下的余白
 			// g.fillRect( 0, 0, sys[SYS_DISP_W], sys[SYS_DRAW_Y] );
			// g.fillRect( 0, sys[SYS_DRAW_Y] + DRAW_H, sys[SYS_DISP_W], sys[SYS_DRAW_Y] );
			offg.fillRect( 0, 0, width, midHeight );
			offg.fillRect( 0, midHeight + 120, width, midHeight );
		}
		if( midWidth != 0 )
		{
			// 左右的余白
			// g.fillRect( 0, sys[SYS_DRAW_Y], sys[SYS_DRAW_X], DRAW_H );
 			// g.fillRect( sys[SYS_DRAW_X] + DRAW_W, sys[SYS_DRAW_Y], sys[SYS_DRAW_X], DRAW_H );
			offg.fillRect( 0, midHeight, midWidth, 120 );
			offg.fillRect( midWidth + 120, midHeight, midWidth, 120 );
		}
	}

	// 画手
	private static final void drawHand()
	{
		// 画左手
		if( leftHand == 0 )
		{
			DrawImage( 32, gameData[14]-10, gameData[15]+5,0,0,10,10 );
		}
		else if( leftHand == 2 )
		{
			if( count2 > 0 )
				DrawImage( 57, gameData[14]-10, gameData[15]-5,0,0,10,15 );
			else
				DrawImage( 33, gameData[14]-10, gameData[15]-10,0,0,10,20 );
		}
		else if( leftHand == 4 )
		{
			if( count2 > 0 )
				DrawImage( 58, gameData[14]-14, gameData[15]+5,0,0,15,10 );
			else
				DrawImage( 34, gameData[14]-19, gameData[15]+5,0,0,20,10 );
		}
		else if( leftHand == 6 )
		{
			if( count2 > 0 )
				DrawImage( 59, gameData[14]-13, gameData[15]+4,0,0,13,13 );
			else
				DrawImage( 35, gameData[14]-16, gameData[15]+4,0,0,16,16 );
		}

		// 画右手
		if( rightHand == 0 )
		{
			DrawImage( 32, gameData[14]+12, gameData[15]+5,10,0,10,10 );
		}
		else if( rightHand == 2 )
		{
			if( count2 > 0 )
				DrawImage( 57, gameData[14]+12, gameData[15]-5,10,0,10,15 );
			else
				DrawImage( 33, gameData[14]+12, gameData[15]-10,10,0,10,20 );
		}
		else if( rightHand == 4 )
		{
			if( count2 > 0 )
				DrawImage( 58, gameData[14]+11, gameData[15]+5,15,0,15,10 );
			else
				DrawImage( 34, gameData[14]+11, gameData[15]+5,20,0,20,10 );
		}
		else if( rightHand == 6 )
		{
			if(  count2 > 0  )
				DrawImage( 59, gameData[14]+12, gameData[15]+4,13,0,13,13 );
			else
				DrawImage( 35, gameData[14]+12, gameData[15]+4,16,0,16,16 );
		}
	}

	// 画脚
	private static final void drawFoot()
	{
		// 画左脚
		if( leftFoot == 0 )
			DrawImage( 36, gameData[14]-15, gameData[15]+14,0,0,16,16 );
		else
			DrawImage( 37, gameData[14]-4, gameData[15]+18,0,0,12,24 );

		// 画右脚
		if( rightFoot == 0 )
			DrawImage( 36, gameData[14]+11, gameData[15]+14,16,0,16,16 );
		else
			DrawImage( 37, gameData[14]+4, gameData[15]+18,12,0,12,24 );
	}

	// 极限量规和高度关系的绘画
	private static final void drawChar()
	{
		int i,j,min,sec1,sec2,msec2,msec1;

		// 极限量规绘画
		DrawImage( 51, width-midWidth*2-11, 1);
		DrawImage( 52, width-midWidth*2-11, 119-gMax1+2);

		// 量规恢复MAX线绘画
		DrawImage( 53, width-midWidth*2-11, 119-gMax2);

		// 高度描画 
		if( gameState == 3 )
		{
			i = gameData[6] / 10;
			j = gameData[6] - i * 10;
		}
		else
		{
			i = gameData[7] / 10;
			j = gameData[7] - i * 10;
		}
		if( i > 9 )
			i%=10;
		DrawImage( 54, width/2-midWidth+20, 1,i*10,0,10,16);		// 第2位
		DrawImage( 54, width/2-midWidth+30, 1,j*10,0,10,16);		// 第1位
		DrawImage( 54, width/2-midWidth+40, 1,110,0,10,16);		// 绘画'M'
		// 时间绘画
		if( gameState == 3 && degree != 0 )
			usedTime = Score[degree-1];
		else if( gameState == 3 && degree == 0 )
			usedTime = 0;
		if( usedTime >= 180000 )
			usedTime = 180000;
		min = usedTime/60000;
		sec2 = (usedTime-min*60000)/10000;
		sec1 = (usedTime-min*60000-sec2*10000)/1000;
		msec2 = (usedTime-min*60000-sec2*10000-sec1*1000)/100;
		msec1 = (usedTime-min*60000-sec2*10000-sec1*1000-msec2*100)/10;
		DrawImage( 54, width/2-midWidth-50, 1,min*10,0,10,16);
		DrawImage( 54, width/2-midWidth-40, 1,100,0,10,16);
		DrawImage( 54, width/2-midWidth-35, 1,sec2*10,0,10,16);
		DrawImage( 54, width/2-midWidth-25, 1,sec1*10,0,10,16);
		DrawImage( 54, width/2-midWidth-15, 1,100,0,10,16);
		DrawImage( 54, width/2-midWidth-10, 1,msec2*10,0,10,16);
		DrawImage( 54, width/2-midWidth, 1,msec1*10,0,10,16);
	}

	// 练习方式时候的手到达的地方表示
	private static final void drawHighlight(int posx,int posy)
	{
		int x,y,k;
		int a[] = {-1,3,-3,2,-3,-2,1,3,3,2,3,-2}; //  从角色位置以跳跃传达的位置
		int b[] = {-1,1,-2,0,-2,-1,1,1,2,0,2,-1}; //  从角色位置手送到的位置

		x = posx*10;
		y = 120-(posy+1-pMove)*10;
		if( gameData[16] == 0 )
			k = 0;
		else
			k = 3;

		// 以跳跃能到达的位置
		if( degree == 0 || gameMode == 1 )
		{
			for(int i = 0+k;i < 3+k;i++)
			{
				offg.setColor(0x0000ff);

				if( (i == 2+k && posy < 5))// || (i > 3 && posy < 5))
					break;

				// 范围绘画
				if( posx+a[2*i] > -1 && posx+a[2*i] < 11
					&& posy+a[2*i+1]-pMove > -1 && posy+a[2*i+1]-pMove < 10
					&& route[posx+a[2*i]+11*(posy+a[2*i+1])] < 30 )
					offg.drawRect(x+10*a[2*i],y-10*a[2*i+1]+1,9,9);
			}
		}

		// 手送到的位置 
		if( degree == 0 )
		{
			for(int i = 0+k;i < 3+k;i++)
			{
				offg.setColor(0xff0000);

				if( (i == 2+k && posy < 4))// || (i > 3 && posy < 5))
					break;

				// 范围绘画
				if( posx+b[2*i] > -1 && posx+b[2*i] < 11
					&& posy+b[2*i+1]-pMove > -1 && posy+b[2*i+1]-pMove < 10
					&& route[posx+b[2*i]+11*(posy+b[2*i+1])] < 30 )
					offg.drawRect(x+10*b[2*i],y-10*b[2*i+1]+1,9,9);
			}
		}
	}

	//--------------------------------------------------------------------------
	//
	// 其他
	//
	//--------------------------------------------------------------------------
	//--------------------------------------------------------------------------
	//
	// 游戏内变量初始化 InitGame()
	//
	//--------------------------------------------------------------------------
	private static final void InitGame()
	{
		// 回主界面音乐再生标志设定
		musicOn = 0;

		// 时间设定
		timeSet = 0;
		usedTime = 0;

		// 落下回数设定
		gameData[28] = 0;

		// 最好成绩标志设定
		BestScore = 0;

		// 高度设定
		pHeight = 0;

		// 动画片用计数器
		count = 0;
		count2 = 0;

		// 游戏菜单的设定
		gMenu = 0;

		// 滚动判断
		isMove = 0;

		// 使之滚动的量
		pMove = 0;

		// 极限量规设定
		gMax1 = 119;//120;
		gMax2 = 119;//120;

		// 玩家手足的设定
		gameData[7] = 0;
		gameData[16]= 0;
		gameData[9] = 0;
		leftHand 	= 0;
		rightHand 	= 0;
		leftFoot 	= 2;
		rightFoot 	= 2;
		gameData[18]= 0;
		gameData[19]= 0;

		// 游戏开始位置
		gameData[14] = 49;
		gameData[15] = 80;

		gameData[30] = 3;

		posX = posX1 = -1;
		posY = posY1 = -1;

		// key flag的初始化
		KeyUp	=false;//全部推倒
		KeyDown	=false;
		KeyLeft	=false;
		KeyRight=false;
		KeyFire	=false;
		KeySound=false;
		soft1Key=false;
		soft2Key=false;
		// 弹出菜单
		iMenu   =false;
		rowIndex=0;
	}

	//------------------------------------------------------------------------------
	//
	// 跑道作成 makeCource()
	//
	//------------------------------------------------------------------------------
	private static final void makeCource()
	{
 		// METHOD_TRACE("MAKE COURCE IN");
		int i,j,k,l,a[] = {11,10,-1,-12,-11,-10,1,12}; // 从3×3集体中心周围8集体的位置信息
		// 练习方式时候与初级同样的设定

⌨️ 快捷键说明

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