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

📄 basketball.java

📁 game for basketball. Midlet,support MIDP2.0
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
		"Low Screen",
		"High Post",
		"Low Post",
		"Pick N Roll",
		"Picket Fence",
		"Give N Go",
		"Corner 3",
		"Perimeter",
		"Man",
		"Zone",
		"Press"*/
	        "拉开单打",
			"高位掩护",
			"低位掩护",
			"高位单打",
			"低位单打",
			"档差",
			"双重掩护",
			"传切配合",
			"3分战术",
			"投篮",
			"一对一",
			"联防",
			"紧逼防守"
		};
	public static void userButtonWinPaint(Graphics g, win pWin)
	{
		pWin.highColor = 0xFF00FF;
		pWin.backColor = 0xFF00FF;
		int x = pWin.x;
		int y = pWin.y;
		int ID = pWin.ID;
		int style = pWin.style;
		Basketball.hMenuWnd.ChkToggleButtons(pWin, ID);
		if(Basketball.hMenuWnd != null &&(Basketball.hMenuWnd.GetState()== 40 || Basketball.hMenuWnd.GetState()== 41))
		{
			bhCanvas.debugText += "g";
			DrawSelPlayButtons(g, ID, style, x, y);
			return;
		}
		bhCanvas.debugText += "m";
		int iButtonType;
		if(0x2000 ==(style & 0x2000))
		{
			iButtonType = 1;
		}
		else if(0x4000 ==(style & 0x4000))
		{
			iButtonType = 2;
		}
		else
		{
			iButtonType = 0;
		}
		int iSrcX = 0;
		int iSrcY = BUTTON_LAYOUT[iButtonType][1];
		int iDestX = 4;
		int iDestY = BUTTON_LAYOUT[iButtonType][3];
		g.setClip(0, 0, 176, 208);
		g.clipRect(x, y, iDestX, iDestY);
		g.drawImage(Basketball.pButton, x - iSrcX, y - iSrcY, 0);
		iSrcX = 14;
		g.setClip(0, 0, 176, 208);
		g.clipRect(x + 84, y, iDestX, iDestY);
		g.drawImage(Basketball.pButton, x + 84 - iSrcX, y - iSrcY, 0);
		iSrcX = 4;
		iDestX = 10;
		for(int i = 0; i < 8; i++)
		{
			int iPosX = x + 4 +(i * iDestX);
			int iPosY = y;
			g.setClip(0, 0, 176, 208);
			g.clipRect(iPosX, iPosY, iDestX, iDestY);
			g.drawImage(Basketball.pButton, iPosX - iSrcX, iPosY - iSrcY, 0);
		}
		g.setClip(0, 0, 176, 208);;
		g.clipRect(x, y, 88, iDestY);
		return;
	}
	static void DrawSelPlayButtons(Graphics g, int ID, int style, int x, int y)
	{
		if(0x2000 !=(style & 0x2000))
		{
			return;
		}
		int iSrcX = 0;
		int iSrcY = BUTTON_LAYOUT[1][1];
		int iDestX = 4;
		int iDestY = BUTTON_LAYOUT[1][3];
		g.setClip(0, 0, 176, 208);;
		g.clipRect(x, y, iDestX, iDestY);
		g.drawImage(Basketball.pButton, x - iSrcX, y - iSrcY, 0);
		iSrcX = 14;
		g.setClip(0, 0, 176, 208);;
		g.clipRect(x + 54, y, iDestX, iDestY);
		g.drawImage(Basketball.pButton, x + 54 - iSrcX, y - iSrcY, 0);
		iSrcX = 4;
		iDestX = 10;
		for(int i = 0; i < 5; i++)
		{
			int iPosX = x + 4 +(i * iDestX);
			int iPosY = y;
			g.setClip(0, 0, 176, 208);;
			g.clipRect(iPosX, iPosY, iDestX, iDestY);
			g.drawImage(Basketball.pButton, iPosX - iSrcX, iPosY - iSrcY, 0);
		}
		g.setClip(0, 0, 176, 208);
		bhFont pFont = win.getColoredFont(0xFFFFFF, false);
		pFont.stringChar(g, x + 29, y + 4-3, PLAYNAMES[ID - 28], - 1, 0x02);
		if(Basketball.hMenuWnd.GetState()== 40)
		{
			if(ID > 28)
			{
				pFont.stringCharNew(g, x + 29, y - 6, "*", - 1, 0x02);
			}
			if(ID < 33)
			{
				pFont.stringCharNew(g, x + 29, y + 14, "+", - 1, 0x02);
			}
		}
		else
		{
			if(ID > 38)
			{
				pFont.stringCharNew(g, x + 29, y - 6, "*", - 1, 0x02);
			}
			if(ID < 40)
			{
				pFont.stringCharNew(g, x + 29, y + 14, "+", - 1, 0x02);
			}
		}
		return;
	}
	private static boolean AllocStaticArrays()
	{
		iOverallRating = new int[2];
		iOffenseRating = new int[2];
		iDefenseRating = new int[2];
		pHomeRemaps = new byte[2][][];
		pAwayRemaps = new byte[2][][];
		pAwayRemaps[0]= new byte[4][4];
		pAwayRemaps[1]= new byte[4][4];
		pHomeRemaps[0]= new byte[4][4];
		pHomeRemaps[1]= new byte[4][4];
		pPlayerStats_iSpeed = new byte[2][5];
		pPlayerStats_i2ptShotRating = new byte[2][5];
		pPlayerStats_i3ptShotRating = new byte[2][5];
		pPlayerStats_iDunkRating = new byte[2][5];
		pPlayerStats_iReboundRating = new byte[2][5];
		pPlayerStats_iBlockRating = new byte[2][5];
		pPlayerStats_iDribPassRating = new byte[2][5];
		pPlayerStats_pFirstName = new String[2][5];
		pPlayerStats_pLastName = new String[2][5];
		pTeamName = new String[2];
		pTeamCity = new String[2];
		pNickName = new String[2];
		pPlayerNames = new String[5];
		pPlayerStat = new String[2][5];
		return true;
	}
	public static void paintAllWindows()
	{
		Basketball.myCanvas.repaint();
	}
	public static int GetRand()
	{
		return ABS(Basketball.rand.nextInt());
	}
	private static byte[]GetFileBuf(String pName)
	{
		InputStream pIS = pName.getClass().getResourceAsStream(pName);
		DataInputStream pDS = new DataInputStream(pIS);
		int iSize = 0;
		try
		{
			iSize =(int)pDS.skip(0x7fffffff);
			pDS.close();
		}
		catch(Exception e)
		{
		}
		pIS = pName.getClass().getResourceAsStream(pName);
		pDS = new DataInputStream(pIS);
		byte pBuf[]= new byte[iSize];
		try
		{
			pDS.read(pBuf, 0, iSize);
			pDS.close();
			pIS.close();
		}
		catch(Exception e)
		{
		}
		return pBuf;
	}
	static Hashtable sounds = new Hashtable();
	private static int m_iSoundPlayerState;
	static boolean soundOnce;
	static Object o = new Object();
/*	static javax.microedition.media.Player player = null;
	public static javax.microedition.media.Player LoadSnd(String pName, String pSndType)
	{
		if(sounds.contains(pName))
			if(sounds.get(pName)!= null)
			return(javax.microedition.media.Player)sounds.get(pName);
		InputStream is = null;
		byte[]retData = null;
		ByteArrayOutputStream os = new ByteArrayOutputStream();
		System.out.println("Load sound trying to load file: " + pName);
		if(pName != null){
				try {
					is = o.getClass().getResourceAsStream(pName);
				int data = 0;
				while(data != -1){
						data = is.read();
					if(data == -1)
						break;
					os.write(data);
				}
				retData = os.toByteArray();
				os.close();
				is.close();
			}
			catch(Exception e){
					e.printStackTrace();
				System.out.println("loadTune : Exception while loading audio from stream");
			}
		}
		javax.microedition.media.Player p = null;
		try
		{
			byte[]b = new byte[3];
			b[0]= retData[8];
			b[1]= retData[9];
			b[2]= retData[10];
			String sig = new String(b);
			if(sig.equals("WAV"))
			{
				ByteArrayInputStream bs = new ByteArrayInputStream(retData);
				p = Manager.createPlayer(bs, "audio/x-wav");
			}
			else
			{
				ByteArrayInputStream bs = new ByteArrayInputStream(retData);
				p = Manager.createPlayer(bs, "audio/midi");
			}
			System.out.println("Created player");
		}
		catch(Exception e)
		{
			System.out.println("uh oh: " + e.getMessage());
		}
		sounds.put(pName, p);
		return p;
	}*/
	static boolean restartFlag = false;
	/*public static void Play(final javax.microedition.media.Player pSound, final int iRepeat)
	{
		if(Basketball.bSoundOn == false)
			return;
		if(pSound == null)
			return;
		if(m_iSoundPlayerState == -2)
			return;
		restartFlag = false;
		m_iSoundPlayerState = -2;
		if(pSound == pSndJingle)
		{
			System.out.println("Jingle Goodness");
			pSound.setLoopCount(5);
			restartFlag = true;
		}
		Thread t = new Thread(){
				public void run(){
				try
				{
					Stop();
					Thread.yield();
					if(pSound != null)
						pSound.start();
				}
				catch(Exception e)
				{
					System.out.println("uh oh: " + e.getMessage());
				}
			}
		};
		t.start();
	}
	static void Stop()
	{
		try
		{
			for(Enumeration e = sounds.elements(); e.hasMoreElements();){
					((javax.microedition.media.Player)e.nextElement()).stop();
				m_iSoundPlayerState = 0;
			}
		}
		catch(Exception e)
		{
		}
	}
	static void Restart()
	{
		if(player != null)
		{
//			if(restartFlag)
//				try { pSndJingle.start(); } catch(Exception e){ }
		}
	}
	public static void StopAllSounds()
	{
		Stop();
	}*/
	/*public static void Vibrate(int iduration)
	{
		DeviceControl.startVibra(100, iduration);
	}*/
	public static int GetState()
	{
		return m_iSoundPlayerState;
	}
/*	public static void SetSoundON(boolean bSoundON)
	{
		if(bSoundON == false)
		{
			Stop();
		}
	}*/
}

⌨️ 快捷键说明

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