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

📄 main.java

📁 一个关于商业化游戏的源代码
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
/*
    Marv the Miner for Nokia Series 30, 40 and 60 and for selected MIDP 1.0 supported phones
    Copyright (C) 2003-2004  Digital Entertainment Europe AS (http://www.digiment.no)

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
	
    If you have any questions, please contact support@digiment.no
*/
import javax.microedition.io.*;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import java.io.*;
import java.util.*;
//import com.nokia.mid.ui.*;

public class Main extends com.nokia.mid.ui.FullCanvas implements Runnable
//public class Main extends Canvas implements Runnable
{
    boolean isLogo2 = false;

    static int LOGO_TIME = 2000;

    static final int C_P = 0;	// platform
    static final int C_S = 1;	// stair
    static final int C_M = 2;	// moving platform

    static final int C_Sucker = 3;	
    static final int C_Slope = 4;	
    static final int C_Press = 5;	
    static final int C_Lift = 6;	
    static final int C_Wall = 7;	

    static final int C_Trap = 11;	
    static final int C_Teleport = 12;	

    static final int C_Alien = 13; 
    static final int C_Bonus = 14; 
    static final int C_Static = 15; 
    static final int C_Man = 16; 

   	static final int C_S2 = 50;	// stair upper edges
   	static final int C_Sl2 = 51;	// slope upper edges

    static int fxp[] = {2, 4, 6, 8, 10,12,14,16,18,20,22,24,26,28,30};
	static int fyp[] = {3, 6, 9, 11,13,15,16,17,16,15,13,11,9, 6, 3};

    static Miner midlet;
    Display display;
    Thread mainThread;

    static int step = 4;              // animation step in pixels

    static Hashtable hp = null;
    static Hashtable hi = null;

    static Frame fPanel0 = null;
    static Frame fPanel1 = null;
    static Frame fPanel2 = null;
    static Frame fLogo = null;
    static Frame fLogo2 = null;
    static Frame fHead = null;

    static Frame fB[] = null;
    static Frame fS[] = null;
    static Frame fM[] = null;
    static Frame fW[] = null;
    static Frame fSu[] = null;
    static Frame fSl[] = null;
    static Frame fPr[] = null;
    static Frame fTr[] = null;
    static Frame fLi[] = null;

    static Frame frm = null;

    /////////////////////////////////////////////////////
    static Image img[] = null;
    static String img_names[] = null;

    static int logo_index;
    static int intro_index;
    static int intro2_index;
    static int abc_index;
    static int back_index;

   	static int img_index;

	static int[] abcw = {8,5,8,8,7,8,8,7,8,8,8,7,8,8,7,7,8,8,4,8,8,7,10,8,8,7,8,8,7,8,8,8,10,8,8,7,7,4,4,6,4,9,9,4,4};
	static int[] abcx = new int[abcw.length];

    Dynamic dyn[] = null;

    Dynamic cur = null;
    static Dynamic man = null;
    Dynamic fire = null;

    static Hashtable hAnims = null;
    int image_index = 0;

    static String str,str2;
  	static int panel_x,panel_dx,panel_width,panel_height,panel_y,panel_dy;
  	static CObject aObj[] = null;
  	static CObject obj = null, obj2 = null;

  	static Vector vM = null;
  	M msg = null;

    static int a_w = -1;					// size of map in pixels
    static int a_h = -1;

    static int a_x_d = 0;					// displacement in map
    static int a_y_d = 0;

    static int t_x_d = 0;					// temporary displacement in map
    static int t_y_d = 0;

    static int disp_x_range= 0;				// displacement changing interval
    static int disp_y_range= 0;

    static int s_w = 0;					// physical screen size
    static int s_h = 0;

    int c_lvl = 0,c_st,c_dyn;

    static int i,j,k,x,y,x1,y1,x2,y2,xm,ym,i2,j2,w1,h1,w2,h2,len,dx,dy,p_num,num;
	int type;
	int subtype;

  	int x_bound,y_bound;                    // bounds
   	int rel_dx = 0;							// relative man position
  	int rel_dy = 0;					       //

  	int platform_count = 0;

  	static Vector v1,v2,v;

  	int scores = 0;
  	int lifes = 0;
  	static int closed_blocks,start_closed_blocks,delay;
  	boolean flag,running;
    static int action = -15;
    static int actionMask = 0;

    int damaged = 0;

  	static Random rand = null;

  	static long startTime,leaveTime,prevTime;
  	long levelTime,currentTime,bonusTime;
	long panelTime = 0;

  	static int state;

  	static int lifeDelay = 0;

    long hh,mm,ss;

	static char[] buf = null;

	static boolean initOK = false;
	boolean ld = false;

    Dynamic dBonus = null;
    boolean isBonus = false;

    static Image ioff = null;
    static Graphics g = null;
    static Graphics gd = null;
    static Graphics goff = null;

    static String nextLevel = null;

    static Vector vMenu = null;
    static Vector vState = null;
    static int menuIndex = 0;
    static String menuName = "";
	static int menuDisp,menuRange,menuHeight,menuTop;
    static boolean isPointer = true;
    static boolean isState = true;
    static boolean menuLast = false;

    static char editText[] = null;
    static String letters = "abcdefghijklmnopqrstuvwxyz._";
    static int editX, editY;

	static int maxLevel = 0;
	static String names[] = null;

	static DataInputStream in = null,in2 = null;
	char ch;

	int memorySize = 0;
	static int vibra_delay = 0;
	static int dumpTime = 0;

	Main(){}

	static void out(String str)
	{
		if (midlet.cheats) System.out.println(str);
	}
    static int vendor = 0;

	// network code - starts here ////////////////////////////////////////////////////////////////////////
	static int securityCode = 110000;
	static int place = -1;		// place a player has taken
	// NETWORK CODE REMOVED
	// network code - ends here
	//////////////////////////////////////////////////////////////////////////////////////////////////////
	static int sendScore(String player,int score)
	{
		return place;
	}

    static void initStaticData()
    {
    	try
    	{
    		j = 0;
    		for (int i = 0; i < abcw.length; i++)
    		{
    			abcx[i] = j;
    			j += abcw[i];
    		}
   			buf = new char[100]; // char buffer

        	fB = new Frame[120];
        	fS = new Frame[12];
        	fM = new Frame[6];

        	fW = new Frame[6];
        	fSu = new Frame[6];
        	fSl = new Frame[7];
        	fPr = new Frame[6];
        	fTr = new Frame[4];
        	fLi = new Frame[4];

    		for (i = 0; i < fB.length; i++) fB[i] = null;
    		for (i = 0; i < fS.length; i++) fS[i] = null;
    		for (i = 0; i < fM.length; i++) fM[i] = null;
    		for (i = 0; i < fW.length; i++) fW[i] = null;
    		for (i = 0; i < fSu.length; i++) fSu[i] = null;
    		for (i = 0; i < fSl.length; i++) fSl[i] = null;
    		for (i = 0; i < fPr.length; i++) fPr[i] = null;
    		for (i = 0; i < fTr.length; i++) fTr[i] = null;
    		for (i = 0; i < fLi.length; i++) fLi[i] = null;

    		img = new Image[55];
    		img_names = new String[img.length];
    		for (i = 0; i < img.length; i++)
    		{
    			img[i] = null;
    			img_names[i] = null;
			}
    		logo_index = img.length - 1;
    		intro_index = img.length - 2;
    		intro2_index = img.length - 3;
    		back_index = img.length - 4;
    		abc_index = img.length - 5;

			pk_offset = new int[img.length];
			pk_size = new int[img.length];
			pk_index = new int[img.length];

			filename = new byte[10];
		   	editText = new char[3];

    		for (i = 0; i < 100; i++) 
    			if (gp("n"+i) != null) maxLevel = i;
    		names = new String[40];
    		for (i = 0; i < names.length; i++) names[i] = gp("n" + i);
    		hp = null;
    		System.gc();
   			vM = new Vector();
    		state = 100;
    	}
    	catch(Exception ex){}
    	vendor = 0;
    	try
    	{
    		// Nokia
    		Class.forName("com.nokia.mid.sound.Sound");
			vendor = 1;
    		try
    		{
    			Class.forName("com.nokia.mid.ui.DeviceControl");
				com.nokia.mid.ui.DeviceControl.setLights(0,100);
				vendor = 2;
			}
			catch(Exception ex2){}
		}
		catch(Exception ex){}

    	try
    	{
    		// Vodafone
    		Class.forName("com.vodafone.v10.system.device.DeviceControl");
			com.vodafone.v10.system.device.DeviceControl.getDefaultDeviceControl().setDeviceActive(com.vodafone.v10.system.device.DeviceControl.BACK_LIGHT,true);
			vendor = 3;
		}
		catch(Exception ex){}

    	try
    	{
    		// Motorola
    		Class.forName("com.motorola.multimedia.Vibrator");
    		Class.forName("com.motorola.multimedia.Lighting");
    		com.motorola.multimedia.Lighting.backlightOn();
			vendor = 4;
		}
		catch(Exception ex){}
    }


    static void beep(int code)
    {
		// Nokia 3650, 7650
		if (vendor == 1)
		try
		{
			if (midlet.muteSound == 0)
			{
				com.nokia.mid.sound.Sound sound = new com.nokia.mid.sound.Sound(1000,100);
				sound.play(1);
			}
		}
		catch(Exception ex){}

		// All other Nokias
		if (vendor == 2)
		try
		{
			if (midlet.muteSound == 0)
			{
				com.nokia.mid.sound.Sound sound = new com.nokia.mid.sound.Sound(1000,100);
				sound.play(1);
			}
			if (midlet.useVibra == 1)
			{
				com.nokia.mid.ui.DeviceControl.startVibra(50,500);
			}
		}
		catch(Exception ex){}

		// Vodafone SDK
		if (vendor == 3)
		try
		{
			if (midlet.useVibra == 1)
			{
				com.vodafone.v10.system.device.DeviceControl.getDefaultDeviceControl().setDeviceActive(com.vodafone.v10.system.device.DeviceControl.VIBRATION,true);
				vibra_delay = 10;
			}
		}
		catch(Exception ex){}

		// Motorola 7.5 
		if (vendor == 4)
		try
		{
			if (midlet.useVibra == 1)
			{
				com.motorola.multimedia.Vibrator.setVibrateTone(com.motorola.multimedia.Vibrator.VIBRATE_LONG);
				com.motorola.multimedia.Vibrator.vibrateFor(500);
			}
		}
		catch(Exception ex){}
    }

    static int rnd(int interval)
    {
    	return (rand.nextInt() & 0x07FFFFFFF) % interval;
    }

    void init(Display d, int level)
    {
        this.display = display;
        c_lvl = level;
		a_w = s_w = getWidth();
		a_h = s_h = getHeight();
		lifes = 3;

        init();
    }

    void release()
    {
    	initOK = false;
    	g = null;                
    	gd = null;
    	goff = null;
    	ioff = null;
    	if (hp != null) hp.clear();
    	hp = null;
    	vMenu = null;
    	vState = null;
		for (i = 0; i < fB.length; i++) fB[i] = null;
   		for (i = 0; i < fS.length; i++) fS[i] = null;
   		for (i = 0; i < fM.length; i++) fM[i] = null;
   		for (i = 0; i < fW.length; i++) fW[i] = null;
   		for (i = 0; i < fSu.length; i++) fSu[i] = null;
   		for (i = 0; i < fSl.length; i++) fSl[i] = null;
   		for (i = 0; i < fPr.length; i++) fPr[i] = null;
   		for (i = 0; i < fTr.length; i++) fTr[i] = null;
   		for (i = 0; i < fLi.length; i++) fLi[i] = null;
    	frm = null;
		fPanel0 = null;
		fPanel1 = null;
		fPanel2 = null;
		fLogo = null;
		fLogo2 = null;
		fHead = null;
   		for (i = 0; i < img.length; i++)
   		if (i != abc_index)
   		{
   			img[i] = null;
   			img_names[i] = null;
		}
		dBonus = null;
      	aObj = null;
      	dyn = null;

      	cur = null;
      	man = null;
      	fire = null;
      	obj = null;
      	obj2 = null;
      	msg = null;
      	v1 = null;
      	v2 = null;
      	v = null;
      	hAnims = null;
      	hi = null;
      	str = null;
      	str2 = null;
      	rand = null;
      	in = null;
      	in2 = null;
      	state = 0;
		System.gc();
    }

    void initMenu(String name,boolean isPointer,boolean isState) 
    {
    	state = 70;
		menuIndex = menuDisp = 0;
		menuTop = 20;
		menuHeight = 16;
		menuRange = (s_h - menuTop + (menuHeight >> 1)) / menuHeight;
		menuName = name;
		this.isPointer = isPointer;
		this.isState = isState;
		vMenu = new Vector();
		if (isState) vState = new Vector();
    	w1 = 0;
    	if (enqueue_abc()) loadImages();
    	initOK = true;
    }

    void initEditor(String name) 
    {
    	menuName = name;
    	editText[0] = 'a';
    	editText[1] = 'a';
    	editText[2] = 'a';
    	editX = 0;
    	editY = 0;
    	menuDisp = 0;
    	state = 80;
    	if (enqueue_abc()) loadImages();
    	initOK = true;
    }

    void initPlaceScreen()
    {
		state = 60;
		LOGO_TIME = 2000;
		initOK = true;
    }


    boolean enqueue_abc()
    {
    	if (img[abc_index] == null)
    	{
	    	img_names[abc_index] = "abc.png";

⌨️ 快捷键说明

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