📄 zappercanvas.java
字号:
// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi
import com.nokia.mid.ui.*;
import java.io.PrintStream;
import java.util.Enumeration;
import java.util.Hashtable;
import javax.microedition.lcdui.*;
class ZapperCanvas extends FullCanvas
{
int page;
private Command cmdExit;
private Command cmdClear;
protected int fireKey;
protected int leftKey;
protected int rightKey;
protected int upKey;
protected int downKey;
protected int oneKey;
int WIDTH;
int HEIGHT;
Image offscreen;
Image logo;
//************************
private int targetFPS=5;
private int introTimer=0;
Image logo1;
//*************************
Image arrow;
int ttt;
Road road;
int id;
int keyTemp;
ZASM midlet;
Hashtable Cars;
boolean showBump;
boolean accel;
int quadrant;
int lane;
int opponents;
int music;
int music1;
boolean changeLaneUp;
boolean changeLaneDn;
boolean gameStart;
boolean gameOver;
boolean timeOut;
boolean outoffuel;
boolean showSignals;
int signalCtr;
boolean paused;
timeKeeper time;
Image signal;
int joyStickctr;
int score[];
int level;
Image outoftime;
int speed;
Image inner;
//Image flagImg;
//Image indiagames;
Image zapperImg;
Image tcarimg;
int inx[];
int iny[];
int selRectPos;
int fuel;
int rank;
boolean loaded;
Image fuelImg;
public static boolean medialoaded = false;
public static int totalMedia = 20;
public static int loadedMedia = 0;
boolean hiScore;
int loadCtr;
int cpage;
public Image kbImg;
static GameDataManager gdm;
static String rname = new String();
int rscore;
static String rnames[];
int rscores[];
int MAX_TOP_SCORES;
int Score;
SoundPlayer gamesound;
static boolean sndEnable = true;
int about;
int hCtr;
public ZapperCanvas(ZASM zapper)
{
page = 0;
ttt = 0;
keyTemp = 0;
Cars = new Hashtable();
showBump = false;
accel = false;
quadrant = 0;
lane = 4;
music = 0;
music1 = 0;
changeLaneUp = false;
changeLaneDn = false;
gameStart = false;
gameOver = false;
timeOut = false;
outoffuel = false;
showSignals = true;
paused = false;
joyStickctr = 0;
score = new int[4];
level = 3;
speed = 0;
fuel = 100;
rank = 0;
loaded = false;
loadCtr = 0;
cpage = 1;
MAX_TOP_SCORES = 3;
about = 0;
midlet = zapper;
WIDTH = getWidth();
HEIGHT = getHeight();
fireKey = getKeyCode(8);
leftKey = getKeyCode(2);
rightKey = getKeyCode(5);
upKey = getKeyCode(1);
downKey = getKeyCode(6);
if(!isDoubleBuffered())
offscreen = Image.createImage(WIDTH, HEIGHT);
try
{
kbImg = Image.createImage("/keyboard.png");
logo = Image.createImage("/logo.png");
}
catch(Exception exception)
{
System.out.println("异常" + exception);
}
gamesound = new SoundPlayer(zapper);
road = new Road();
gdm = new GameDataManager(this);
rnames = new String[MAX_TOP_SCORES];
rscores = new int[MAX_TOP_SCORES];
for(int i = 0; i < MAX_TOP_SCORES; i++)
{
rnames[i] = new String("");
rscores[i] = 0;
}
gdm.SetupKeyBoard(kbImg);
gdm.object.getRecords();
try
{
fuelImg = Image.createImage("/fuel.png");
outoftime = Image.createImage("/outoftime.png");
loadedMedia = 1;
signal = Image.createImage("/signal.png");
loadedMedia = 2;
//indiagames = Image.createImage("/indiagames.png");
loadedMedia = 5;
//zapperImg = Image.createImage("/zapper.png");
loadedMedia = 6;
//inner = Image.createImage("/inside.png");
inner = Image.createImage("/title.png");
loadedMedia = 7;
//flagImg = Image.createImage("/flag2.png");
loadedMedia = 8;
arrow = Image.createImage("/arrow.png");
loadedMedia = 9;
logo = Image.createImage("/p1.png");//logo = Image.createImage("/logo.png");
loadedMedia = 10;
logo1 = Image.createImage("/p2.png");
loadedMedia = 11;
}
catch(Exception exception1)
{
System.out.println("图片不存在" + exception1);
}
initBG();
medialoaded = true;
}
public void initBG()
{
int i = 3 + 176 / inner.getWidth();
int j = 3 + 208 / inner.getHeight();
inx = new int[i];
iny = new int[j];
for(int k = 0; k < i; k++)
inx[k] = k * inner.getWidth();
for(int l = 0; l < j; l++)
iny[l] = l * inner.getHeight();
System.gc();
}
public void DrawBGS(Graphics g)
{
//int i = WIDTH / inner.getWidth() + 3;
//int j = HEIGHT / inner.getHeight() + 3;
//for(int k = 0; k < i; k++)
//{
//for(int l = 0; l < j; l++)
//g.drawImage(inner, inx[k], iny[l], 0x10 | 0x4);
g.drawImage(inner, 0, 0, 0x10 | 0x4);
//}
//if(inx[0] > -1 * inner.getWidth())
// {
//for(int i1 = 0; i1 < i; i1++)
//inx[i1] -= 6;
// for(int j1 = 0; j1 < j; j1++)
//iny[j1] -= 8;
//}
//else
//{
// initBG();
// }
if(page == 1)
{
DirectGraphics directgraphics = DirectUtils.getDirectGraphics(g);
//g.drawImage(flagImg, 10, 15, 0x10 | 0x4);
//directgraphics.drawImage(flagImg, 90, 15, 0x10 | 0x4, 8192);
//g.setColor(255, 255, 255);
//g.drawImage(indiagames, WIDTH / 2 - indiagames.getWidth() / 2, (HEIGHT / 2 - indiagames.getHeight()) + 10, 0x10 | 0x4);
//g.drawImage(zapperImg, WIDTH / 2 - zapperImg.getWidth() / 2, 5, 0x10 | 0x4);
byte byte0 = 30;
g.setColor(255, 255, 255);
g.setFont(Font.getFont(0, 1, 8));
if(joyStickctr % 2 == 0)
{
g.drawString("按5键开始比赛", 50, 185, 20);
joyStickctr = 0;
}
joyStickctr++;
} else
{
// g.drawImage(zapperImg, WIDTH / 2 - zapperImg.getWidth() / 2, 5, 0x10 | 0x4);
}
}
public void paint(Graphics g)
{
Graphics g1 = g;
if(offscreen != null)
g = offscreen.getGraphics();
if(page == 1 && sndEnable)
gamesound.playBg();
if(page == 9 && sndEnable && music1 < 2)
{
gamesound.stopSounds();
gamesound.playHall();
music1++;
}
if(page == 0)
{
//g.setColor(0, 0, 0);
//g.fillRect(0, 0, 176, 208);
//g.setColor(255, 0, 0);
//g.setColor(255, 255, 255);
//g.fillRect(28, 170, 120, 10);
//g.setColor(255, 0, 0);
//g.fillRect(28, 170, (120 / totalMedia) * loadCtr, 10);
//g.drawImage(logo, 0, 0, 0x4 | 0x10);//g.drawImage(logo, 32, 60, 0x4 | 0x10);
//g.setColor(252, 255, 0);
//g.drawRect(28, 170, 120, 10);
//*******************************
if(introTimer < targetFPS *2)
{
g.drawImage(logo, 0, 0, 0x4 | 0x10);
}
else if(introTimer >= targetFPS * 2 && introTimer < targetFPS * 4){
g.drawImage(logo1, 0, 0, 0x4 | 0x10);
}
introTimer++;
//********************************
loadCtr++;
if(loadCtr >= totalMedia)
page = 1;
} else
if(page == 1)
//g.setColor(0, 0, 0);
//g.fillRect(0, 0, 176, 208);
DrawBGS(g);
if(page == 2)
{
if(paused || timeOut || outoffuel)
{
Cars.clear();
paused = false;
gameOver = false;
gameStart = false;
showSignals = true;
changeLaneUp = false;
changeLaneDn = false;
outoffuel = false;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -