📄 town.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
// Source File Name: Town.java
package falcofinder.Wien;
import java.io.IOException;
import java.io.PrintStream;
import java.util.Vector;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.MIDlet;
// Referenced classes of package falcofinder.Wien:
// AreaA, Kid, M, Train,
// Bag
public class Town extends Canvas
{
private MIDlet midlet;
private Image homeImg;
private Image imgTicket;
int step;
int xcentro;
int ycentro;
int imgw2;
int imgh2;
int mode;
int color;
int width;
int height;
int changeCredits;
Kid kid;
AreaA areaa;
Train train;
M m;
protected String anwr;
int widthrr;
int heightrr;
public Town(MIDlet midlet)
{
step = 0;
mode = 0;
color = 255;
changeCredits = 0;
anwr = "";
this.midlet = midlet;
width = getWidth();
height = getHeight();
widthrr = Integer.parseInt("" + (width - 30) / 2);
heightrr = Integer.parseInt("" + (height - 30) / 2);
try
{
homeImg = Image.createImage("/falcofinder/icons/home.png");
imgTicket = Image.createImage("/falcofinder/icons/ticketoffice.png");
imgw2 = Integer.parseInt("" + homeImg.getWidth() / 2);
imgh2 = Integer.parseInt("" + homeImg.getHeight() / 2);
}
catch(IOException ioe)
{
System.out.println("Home icon not found" + ioe.getMessage());
}
areaa = new AreaA(getWidth(), getHeight());
kid = new Kid(this, areaa);
m = new M(kid, areaa);
train = new Train(this, areaa);
initgame();
xcentro = Integer.parseInt("" + width / 2);
ycentro = Integer.parseInt("" + height / 2);
}
public void paint(Graphics g)
{
if(mode == 0)
{
paintHome(g);
m.pause = true;
}
if(mode == 1)
{
paintGame(g);
m.pause = false;
}
if(mode == 2)
{
paintCredits(g);
m.pause = true;
}
}
public void paintGame(Graphics gc)
{
if(kid.status == 1)
{
gc.setColor(255, 255, 255);
gc.fillRect(xcentro - 40, ycentro - 20, 80, 20);
gc.setColor(0, 0, 0);
gc.setFont(Font.getFont(32, 0, 16));
gc.drawString("GAME OVER", xcentro, ycentro, 33);
return;
}
gc.setColor(0, 0, 0);
gc.setClip(0, 0, width, height);
gc.fillRect(0, 0, width, height);
gc.setColor(255, 255, 255);
if(areaa.dogFollowsKid)
{
areaa.sectionDog = areaa.section;
areaa.posDogx = kid.posx;
areaa.posDogy = kid.posy;
}
if(areaa.baloonFollowsKid)
{
areaa.sectionBaloon = areaa.section;
areaa.posBaloonx = kid.posx + 8;
areaa.posBaloony = kid.posy - 10;
}
areaa.drawSection(gc);
kid.drawKid(gc);
if(areaa.sectiontrain == areaa.section)
train.drawTrain(gc);
if(areaa.section == m.section)
drawM(gc);
if(kid.msg.equals("Ticket Office"))
{
m.pause = true;
areaa.pause = true;
drawTicketOffice(gc);
return;
}
m.pause = false;
areaa.pause = false;
if(kid.msg.equals("Bag"))
{
m.pause = true;
areaa.pause = true;
areaa.objects.drawBag(gc);
return;
}
m.pause = false;
areaa.pause = false;
if(kid.msg.compareTo("") != 0)
{
gc.setColor(255, 255, 255);
gc.setFont(Font.getFont(64, 2, 8));
gc.drawString(kid.msg, 0, height - 10, 36);
}
if(kid.status == 2)
{
gc.setColor(255, 255, 255);
gc.fillRect(xcentro - 40, ycentro - 30, 80, 30);
gc.setColor(0, 0, 0);
gc.setFont(Font.getFont(32, 0, 0));
gc.drawString("Mission 1", xcentro, ycentro - 12, 33);
gc.drawString("Completed", xcentro, ycentro, 33);
m.mIsALive = false;
}
}
public void paintCredits(Graphics g)
{
g.setColor(0, 0, 0);
g.setClip(0, 0, width, height);
g.fillRect(0, 0, width, height);
color = color - 6;
g.setColor(color, color, color);
g.setFont(Font.getFont(0, 0, 8));
switch(changeCredits)
{
case 0: // '\0'
g.setColor(0, 0, 0);
g.fillRect(xcentro - 60, 5, 43, 55);
g.setColor(color, color, color);
g.drawString("Credits:", 5, 10, 68);
g.drawString("F, Eine Stadt...", 5, 20, 68);
g.drawString("sucht einen M\366rder", 5, 30, 68);
break;
case 1: // '\001'
g.drawImage(homeImg, xcentro - 21, 5, 20);
g.setColor(0, 0, 0);
g.fillRect(xcentro + 24, 5, 43, 55);
break;
case 2: // '\002'
g.setColor(color, color, color);
g.drawString("by Ivan Crosignani", 0, 30, 68);
g.drawString("der_kommissar@iol.it", 0, 40, 68);
break;
case 3: // '\003'
g.drawImage(homeImg, xcentro - 60, 5, 20);
g.setColor(0, 0, 0);
g.fillRect(xcentro - 60, 5, 43, 55);
break;
case 4: // '\004'
g.drawString("Dedicated to ", 5, 10, 68);
g.drawString("F.Lang, P.Lorre", 5, 20, 68);
g.drawString("O.Welles, Falco", 5, 30, 68);
g.drawString("C.Reed and B&B", 5, 40, 68);
break;
}
if(color <= 40)
{
color = 255;
changeCredits++;
if(changeCredits == 5)
changeCredits = 0;
}
}
public void paintHome(Graphics g)
{
g.setColor(0, 0, 0);
g.setClip(0, 0, width, height);
g.fillRect(0, 0, width, height);
g.drawImage(homeImg, 0, 10, 20);
g.setColor(255, 255, 255);
g.setFont(Font.getFont(32, 0, 8));
g.drawString("Eine Stadt sucht einen", 1, 0, 20);
g.drawString("M", 90, 2, 20);
g.drawString("\366", 90, 11, 20);
g.drawString("r", 90, 20, 20);
g.drawString("d", 90, 29, 20);
g.drawString("e", 90, 38, 20);
g.drawString("r", 90, 46, 20);
}
protected void drawTicketOffice(Graphics g)
{
boolean money = false;
areaa.status = "office";
int idmoney = 0;
for(int i = 0; i < areaa.objects.size(); i++)
if(areaa.objects.elementAt(i).equals("Money"))
{
money = true;
idmoney = i;
}
g.setColor(255, 255, 255);
g.fillRect(0, 0, width, height);
g.drawImage(imgTicket, 0, height - 63, 20);
g.setColor(0, 0, 0);
g.setFont(Font.getFont(0, 0, 8));
if(anwr.equals("1"))
{
g.drawString("1-A Ticket to Steph.pltz", 1, 10, 20);
g.drawString("3-Nothing, thanks.", 1, 20, 20);
g.drawString("You're in Vienna!", 1, 40, 20);
} else
if(anwr.equals("3") || anwr.equals("11"))
{
g.drawString("One Euro please", 1, 40, 20);
if(money)
g.drawString("1-Thanks", 1, 1, 20);
else
g.drawString("3-Sorry, no money", 1, 1, 20);
} else
if(anwr.equals("9") || anwr.equals("13") || anwr.equals("113") || anwr.equals("33"))
{
areaa.pause = false;
areaa.status = "";
kid.pick = 0;
kid.msg = "I must found money";
kid.ismoving = true;
anwr = "";
kid.posy = kid.posy + 20;
} else
if(anwr.equals("111") || anwr.equals("31"))
{
areaa.objects.removeElementAt(idmoney);
areaa.objects.addElement("Ticket");
areaa.pause = false;
areaa.status = "";
kid.pick = 0;
kid.ismoving = true;
anwr = "";
kid.posy = kid.posy + 20;
kid.msg = "I've got UBahn ticket";
} else
{
anwr = "";
g.drawString("1-I must go to Wien", 1, 1, 20);
g.drawString("3-A Ticket to Steph.pltz", 1, 10, 20);
g.drawString("9-Nothing, thanks.", 1, 20, 20);
g.drawString("What do you need?", 1, 40, 20);
}
}
private void drawM(Graphics g)
{
g.setColor(255, 255, 255);
g.drawRect(m.posx, m.posy, 5, 5);
g.drawLine(m.posx - 2, m.posy + 5, m.posx + 8, m.posy + 5);
g.drawLine(m.posx + 1, m.posy + 5, m.posx + 1, m.posy + 8);
g.drawLine(m.posx + 5, m.posy + 5, m.posx + 5, m.posy + 8);
g.setColor(0, 0, 0);
g.fillRect(m.posx - 2, m.posy + 8, 8, 10);
g.setColor(255, 255, 255);
g.drawLine(m.posx - 2, m.posy + 8, m.posx + 8, m.posy + 8);
g.drawLine(m.posx - 2, m.posy + 8, m.posx - 5, m.posy + 18);
g.drawLine(m.posx + 8, m.posy + 8, m.posx + 11, m.posy + 18);
g.setColor(0, 0, 0);
g.fillRect(m.posx - 4, m.posy + 18, 14, 10);
g.setColor(255, 255, 255);
g.drawLine(m.posx - 5, m.posy + 18, m.posx + 11, m.posy + 18);
g.drawLine(m.posx - 4, m.posy + 18, m.posx - 4, m.posy + 28);
g.drawLine(m.posx + 10, m.posy + 18, m.posx + 10, m.posy + 28);
g.drawLine(m.posx - 4, m.posy + 28, m.posx + 10, m.posy + 28);
g.setFont(Font.getFont(64, 2, 8));
g.drawString("F", m.posx + 5, m.posy + 7, 17);
}
public void initgame()
{
kid.start();
m.start();
}
protected void keyPressed(int keyCode)
{
kid.ismoving = true;
kid.move(getGameAction(keyCode), getKeyName(keyCode));
}
protected void keyReleased(int keyCode)
{
kid.ismoving = false;
}
protected void keyRepeated(int i)
{
}
protected void pointerDragged(int i, int j)
{
}
protected void pointerPressed(int i, int j)
{
}
protected void pointerReleased(int i, int j)
{
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -