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

📄 game.java

📁 一个非常好的赛车游戏代码
💻 JAVA
字号:
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;

public class Game extends MIDlet
{
  private Display display;
  
  public static CarStore cs = new CarStore();
  
  public StartForm form;
  
  public GarageClient garage;
	
  public void startApp()
  {
	// To begin, read values from storage
    if (!cs.readStore())
    {
    	// If we have problem use default values....
	cs.setCash(100);
	Weapon[] weapons = new Weapon[2];
	weapons[0] = new Weapon(Weapon.FLAME, 5,7,"Flame Thrower","Toasts Cars In Front");
	weapons[1] = new Weapon(Weapon.OIL, 15,2,"Oil Slick","Makes Cars Slide");
	cs.setWeapons(weapons);
    }
    // Be sure we have at least SOME ammo
    for (int i=0; i < cs.getWeapons().length; i++)
    {
    	if (cs.getWeapons()[i] != null && cs.getWeapons()[i].getWeaponAmmo() <= 0)
    		cs.getWeapons()[i].setWeaponAmmo(10);
    }
    garage = new GarageClient(this);
    display = Display.getDisplay(this);
    form = new StartForm(this);
    display.setCurrent(form);
  }

  public void pauseApp() {}
  
  public void destroyApp(boolean b) 
  {
        System.out.println("DestroyApp() called.  Writing data to RecordStore");
        cs.writeToStore();
  }
  
  public Display getDisplay()
  {
    return display;
  }

  public void exit()
  {
    destroyApp(false);
    notifyDestroyed();
  }
}

⌨️ 快捷键说明

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