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

📄 miner.java

📁 之前有人传过`淘金者的游戏`网上大部分的都没有资源文件的`偶把资源文件和代码一起打包`希望对大家有帮助`
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
			    	menuLevel = 1;
					main.running = false;
					main.initMenu("About",false,false);
					main.addText(
						"Marv The Miner v.1.2.0 Copyright (c) 2003 Digital Entertainment Europe AS. "+
						"For support, email support@digiment.no. Check out more of our games at www.digiment.no");
					main.menuLast = true;
			        main.running = true;
			        set(main);
            	}
                else
                {
                	exitRequested();
                }
                break;
    		case 1:       // select level
    			int i = level - main.menuIndex;
                gc();
       			main.release();
   	           	main.state = 98;
   	           	main.scores = 0;
				main.init(Display.getDisplay(this),i);
   	           	s();
	           	break;
    		case 3: 
    			gc();
   				returnMenu();
   				break;
   			case 10: // pause menu
   				paused = true;
   				if (n == 0)
   				{
   					// continue
         			main.startTime += System.currentTimeMillis() - main.leaveTime;
         			main.bonusTime += System.currentTimeMillis() - main.leaveTime;
           			gc();
           			main.state = 0;
					s();
   				}
   				else
   				if (n == 1)
   				{
   					// exit level
		        	main.running = false;
		        	main.release();
   					menuLevel = 0;
   					paused = false;
   					returnMenu();
   				}
   				else
   				if (n == 2)
   				{
   					// options
   					menuLevel = 0;
   					menuOk(3);
   				}
   				else
   				if (n == 3)
   				{
   					// help
   					menuLevel = 0;
   					menuOk(4);
   				}
   				else
   				{
   					// quit
   					exitRequested();
   				}
	        default: break;
    	}
    }

    void gc()
    {
    	menuLevel = 0;
    	System.gc();
    }

    void storeScores()
    {
    	int id,found = 0,min = main.scores;
    	hsid = 32000;
   		startRead("*");
   	    while ((id = readNext()) != -1) 
		{
   			if ((r_level == 0) && (r_score > 0) && (r_player.charAt(0) != '#'))
			{
   		    	found = 1;
   		    	if (r_score < min)
   		    	{
   		    		hsid = id;
   		    		min = r_score;
   		    	}
    	    }
      	}

  	    if ((found == 0) || (hsid != 32000)) 
  	    {
    		main.running = false;
    		main.initEditor("NAME:");
    		main.running = true;
			set(main);
    	}
    	else
    	{
    		menuLevel = 0;
    		returnMenu();
    	}
    }

	String filter = null;

	// part of interface
    public boolean matches(byte[] candidate) throws IllegalArgumentException
    {
		if (this.filter == null) return false;
		if (this.filter.equals("*")) return true;

		DataInputStream in = new DataInputStream(new ByteArrayInputStream(candidate));
		String name = null;
		try 
		{
	    	int score = in.readInt();
		    name = in.readUTF();
		}
		catch (Exception ex) {}
		return (this.filter.equals(name));
    }

	public int compare(byte[] rec1, byte[] rec2)
    {
		DataInputStream in1 = new DataInputStream(new ByteArrayInputStream(rec1));
		DataInputStream in2 = new DataInputStream(new ByteArrayInputStream(rec2));
		int s1 = 0;
		int s2 = 0;
		try 
		{
		    s1 = in1.readInt();
		    s2 = in2.readInt();
		}
		catch (Exception ex) {}
		if (s1 < s2) 
			return RecordComparator.PRECEDES;
		else
		if (s1 > s2) 
			return RecordComparator.FOLLOWS;
		else 
	    	return RecordComparator.EQUIVALENT;
    }

    int r_level,r_score;
	String r_player = null;
    RecordEnumeration re = null;

    void startRead(String f)
    {
    	try 
    	{
	    	filter = f;
			re = rs.enumerateRecords(null, this, true);
    	}
    	catch (Exception ex) {}
    }

    int readNext()
    {
    	try 
    	{
	    	if (re.hasNextElement())
    		{
    			int id = re.nextRecordId();
	    		DataInputStream in = new DataInputStream(new ByteArrayInputStream(rs.getRecord(id)));
			    r_level = in.readInt();
			    r_score = in.readInt();
			    r_player = in.readUTF();
	    		return id;
	    	}
    	}
    	catch (Exception ex) {}
    	return -1;
    }

    int getVar(int type)
    {
    	startRead("#");		
   	    while(readNext() != -1) 
			if (r_player.charAt(0) == '#')
    			if (r_level == type) return r_score;
    	return 0;
    }

    void putVar(int type,int value)
    {
    	int foundId = -1,id;
    	startRead("#");		
   	    while((id = readNext()) != -1) 
			if (r_player.charAt(0) == '#')
    			if (r_level == type) 
    				foundId = id;
    	String oldPlayer = player;
    	player = "#";
		putRecord(foundId,type,value);
		player = oldPlayer;
    }

    int readMaxLevel()
    {
    	return getVar(T_LAST);
	}
	
    void storeLevel(int new_level)
    {
    	int id,foundId = -1,maxLevel = 0;
    	startRead("#");
   	    while (((id = readNext()) != -1) && (foundId == -1)) 
   	    {
		   	if ((r_player.charAt(0) == '#') && (r_level == T_LAST))
	    	{
		    	foundId = id;
        		if (maxLevel < r_score) maxLevel = r_score;
    	    }
    	}
   	    if ((maxLevel <= new_level) || (foundId == -1))
   	    {
	    	player = "#";
   	    	putRecord(foundId,T_LAST,new_level);
   	    }
    }

	void bestScores()
	{
		Hashtable h = new Hashtable();
		String str,ssc;
		int score,i,j;
		Integer ii;
  		startRead("*");
		while (readNext() != -1) 
		{
   		    if ((r_level == 0) && (r_score >= 0) && (r_player.charAt(0) != '#'))
			{
				h.put(new Integer(r_score),r_player);
				if (r_player.equals("dee")) cheats = true;
   		    }
		}
		as = new int[h.size()];
		Enumeration e = h.keys();
		for (i = 0; i < as.length; i++)
		{
			as[i] = ((Integer)e.nextElement()).intValue();
		}
		sort(0,as.length - 1);

		for (j = as.length - 1, i = 0; (i < 9) && (j >= 0); i++, j--)
		{
			str = (String)h.get(new Integer(as[j]));
			if (str.length() < 2) str += " ";
			if (str.length() < 3) str += " ";
			ssc = as[j] + "";
			if (as[j] < 10) ssc = "0" + ssc;
			if (as[j] < 100) ssc = "0" + ssc;
			if (as[j] < 1000) ssc = "0" + ssc;
			if (as[j] < 10000) ssc = "0" + ssc;
			main.addItem((i + 1) + ".&" + str + "%" + ssc);
		}
		as = null;
		e = null;
		h = null;
		System.gc();
	}

	int as[] = null;
	int part(int l, int r)
	{
		int i,j;
		int v,b;
		v = as[r];
		i = l - 1;
		j = r;
		do
		{
			do
			{
				j--;
			}
			while ((as[j] > v) && (j != (i + 1)));

			do
			{
				i++;
			}
			while ((as[i] < v) && (i != (j - 1)));
			b = as[i];
			as[i] = as[j];
			as[j] = b;
		}
		while (i < j);
		as[j] = as[i];
		as[i] = as[r];
		as[r] = b;
		return i;
	}

	// QuickSort procedure: arr - any array, l - lower index, t - upper index
	void sort(int l,int t)
	{
		int i;
		if (l < t) 
		{
			i = part(l,t);
			sort(l,i-1);
			sort(i+1,t);
		}
	}

    void putRecord(int remove_id,int l,int s)
    {
    	try
    	{
    		ByteArrayOutputStream baos = new ByteArrayOutputStream();
    		DataOutputStream out = new DataOutputStream(baos);
    		out.writeInt(l);
    		out.writeInt(s);
    		out.writeUTF(player);
    		byte[] b = baos.toByteArray();

			if ((remove_id != 32000) && (remove_id != -1)) rs.setRecord(remove_id, b, 0, b.length);
			else rs.addRecord(b, 0, b.length);
    	}
    	catch(Exception ex){}
    }

    public void pauseApp() {}
    
    public void destroyApp(boolean unconditional) {}

    void exitRequested()
    {
    	if (main != null) main.stop();
        destroyApp(false);
        notifyDestroyed();
    }
}

⌨️ 快捷键说明

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