home *** CD-ROM | disk | FTP | other *** search
Java Source | 2017-09-21 | 15.1 KB | 475 lines |
- /*
- *
- * NTT-07P (JAVA Beta2)
- *
- * Nextage Y.Amemoto
- * 1996/01/01
- *
- */
- import java.io.InputStream;
- import java.awt.*;
- import java.net.*;
- import java.applet.AudioClip;
-
- public class Ntt_07p extends java.applet.Applet implements Runnable {
- Thread kicker = null;
- Image im,imLine;
- Graphics off,offLine;
- Image imBack;
- Image mkokusai,mkokunai,mgaikoku,mkaitei,mcompu,mtel,mfax,mtan;
- Ntt_07pLINE line[];
- Ntt_07pKIKI kiki[];
- Ntt_07pKOUKAN koukan[];
- Ntt_07pDENPA denpa[];
- Ntt_07pKAITEI kaitei;
- boolean first = true;
- int click = -1, step;
-
- public void init() {
- int lXY[][] = {
- { 55,205,100,185}, //compuA kokunaiA
- { 75,225,100,185}, //telA kokunaiA
- {105,225,100,185}, //faxA kokunaiA
- {135,215,100,185}, //tanA kokunaiA
- {100,185,150,170}, //kokunaiA kokusaiA
- {150,170,140,140}, //kokusaiA antenaA
- {395,205,335,185}, //compuB kokunaiB
- {365,225,335,185}, //telB kokunaiB
- {335,225,335,185}, //faxB kokunaiB
- {305,215,335,185}, //tanB kokunaiB
- {335,185,280,170}, // kokunaiB kokusaiB
- {280,170,300,140} // kokusaiB antenaB
- };
-
- im = createImage(size().width, size().height);
- off = im.getGraphics();
- imLine = createImage(size().width, size().height);
- offLine = imLine.getGraphics();
-
- kaitei = new Ntt_07pKAITEI(168,160, this);
-
- denpa = new Ntt_07pDENPA[2];
- denpa[0] = new Ntt_07pDENPA(155,115,210,60);
- denpa[1] = new Ntt_07pDENPA(280,115,220,60);
-
- line = new Ntt_07pLINE[12];
- for (int i = 0; i < 12; i++)
- line[i] = new Ntt_07pLINE(lXY[i][0],lXY[i][1],lXY[i][2],lXY[i][3]);
-
- koukan = new Ntt_07pKOUKAN[7];
- koukan[0] = new Ntt_07pKOUKAN(85,155,"kokunai", this);//kokunaiA
- koukan[1] = new Ntt_07pKOUKAN(135,135,"kokusai", this);//kokusaiA
- koukan[2] = new Ntt_07pKOUKAN(125,115,"antenaA", this);//antenaA
- koukan[3] = new Ntt_07pKOUKAN(200,20,"eisei", this);
- koukan[4] = new Ntt_07pKOUKAN(285,115,"antenaB", this);//antenaB
- koukan[5] = new Ntt_07pKOUKAN(265,135,"kokusai", this);//kokusaiB
- koukan[6] = new Ntt_07pKOUKAN(315,155,"kokunai", this);//kokunaiB
-
- kiki = new Ntt_07pKIKI[8];
- kiki[0] = new Ntt_07pKIKI( 35,185,"compu", "A", this);
- kiki[1] = new Ntt_07pKIKI( 60,195,"tel", "A", this);
- kiki[2] = new Ntt_07pKIKI( 90,210,"fax", "A", this);
- kiki[3] = new Ntt_07pKIKI(125,205,"tan", "A", this);
- kiki[4] = new Ntt_07pKIKI(379,185,"compu", "B", this);
- kiki[5] = new Ntt_07pKIKI(360,195,"tel", "B", this);
- kiki[6] = new Ntt_07pKIKI(315,210,"fax", "B", this);
- kiki[7] = new Ntt_07pKIKI(285,205,"tan", "B", this);
-
- imBack = getImage(getCodeBase(), "images/titlec.gif");
- mkokusai = getImage(getCodeBase(), "images/mkokusai.gif");
- mkokunai = getImage(getCodeBase(), "images/mkokunai.gif");
- mgaikoku = getImage(getCodeBase(), "images/mgaikoku.gif");
- mkaitei = getImage(getCodeBase(), "images/mkaitei.gif");
- mcompu = getImage(getCodeBase(), "images/mcompu.gif");
- mtel = getImage(getCodeBase(), "images/mtel.gif");
- mfax = getImage(getCodeBase(), "images/mfax.gif");
- mtan = getImage(getCodeBase(), "images/mtan.gif");
- }
-
- public void run() {
- Thread.currentThread().setPriority(Thread.MIN_PRIORITY);
- while (kicker != null) {
- if (click >= 0 && click < 4) {
- switch (++step) {
- case 0: kiki[click].CALL(); break;
- case 1: line[click].ON(); break;
- case 2: line[4].ON(); break;
- case 3: if ((int)(Math.random()*2) == 0) step = 4;
- else step = 9;
- continue;
- case 5: line[5].ON(); break;
- case 6: denpa[0].ON(); break;
- case 7: denpa[1].ON(); break;
- case 8: line[11].ON(); break;
- case 9: step++; continue;
- case 10: kaitei.ON(); break;
- case 11: line[10].ON(); break;
- case 12: line[click+6].ON(); break;
- case 13: kiki[click+4].RECEIVE(); break;
- case 14: break;
- case 15: allOff(); break;
- }
- repaint();
- try { Thread.sleep(500); } catch (InterruptedException e) { return; }
- }
-
- if (click >= 4 && click < 8) {
- switch (++step) {
- case 0: kiki[click].CALL(); break;
- case 1: line[click+2].ON(); break;
- case 2: line[10].ON(); break;
- case 3: if ((int)(Math.random()*2) == 0) step = 4;
- else step = 9;
- continue;
- case 5: line[11].ON(); break;
- case 6: denpa[1].ON(); break;
- case 7: denpa[0].ON(); break;
- case 8: line[5].ON(); break;
- case 9: step++; continue;
- case 10: kaitei.ON(); break;
- case 11: line[4].ON(); break;
- case 12: line[click-4].ON(); break;
- case 13: kiki[click-4].RECEIVE(); break;
- case 14: break;
- case 15: allOff(); break;
- }
- repaint();
- try { Thread.sleep(500); } catch (InterruptedException e) { return; }
- }
- repaint();
- try { Thread.sleep(10); } catch (InterruptedException e) { return; }
- }
- }
-
- public void allOff() {
- for (int i = 0; i < 12; i++)
- line[i].OFF();
- for (int i = 0; i < 8; i++)
- kiki[i].OFF();
- denpa[0].OFF();
- denpa[1].OFF();
- kaitei.OFF();
- click = -1;
- }
-
- public void paint(Graphics g) {
- update(g);
- }
- public void update(Graphics g) {
- offLine.drawImage(imBack,0,30,this);
- if (first) {
- off.drawString("Loading...",0,20);
- if (chkKiki() && chkKoukan()) {
- first = false;
- }
- }
- else {
- denpa[0].drawDENPA(offLine);
- denpa[1].drawDENPA(offLine);
- for (int i = 0; i < 12; i++) {
- line[i].drawLINE(offLine);
- }
- }
- off.drawImage(imLine,0,0,this);
- kaitei.drawKAITEI(off, this);
- for (int i = 0; i < 7; i++)
- koukan[i].drawKOUKAN(off, this);
- for (int i = 0; i < 8; i++)
- kiki[i].drawKIKI(off, this);
-
- off.drawImage(mkokusai,165,135,this);
- off.drawImage(mkokusai,305,135,this);
- off.drawImage(mkokunai, 30,160,this);
- off.drawImage(mgaikoku,340,160,this);
- off.drawImage(mkaitei,185,195,this);
- off.drawImage(mcompu, 2,220,this);
- off.drawImage(mcompu,385,220,this);
- off.drawImage(mtel, 50,240,this);
- off.drawImage(mtel,360,240,this);
- off.drawImage(mfax, 95,243,this);
- off.drawImage(mfax,325,243,this);
- off.drawImage(mtan,140,240,this);
- off.drawImage(mtan,270,240,this);
-
- g.drawImage(im, 0,0,this);
- if (first) g.drawString("Loading...",0,20);
- }
-
- boolean chkKiki() {
- for (int i = 0; i < 8; i++) {
- if (kiki[i].chkImage(this)==false) {
- return false;
- }
- }
- return true;
- }
- boolean chkKoukan() {
- for (int i = 0; i < 7; i++) {
- if (koukan[i].chkImage(this)==false) {
- return false;
- }
- }
- return true;
- }
- public void start() {
- if (kicker == null) {
- kicker = new Thread(this);
- kicker.start();
- }
- }
-
- public void stop() {
- kicker = null;
- }
- public boolean mouseDown(java.awt.Event evt, int x, int y) {
- if (click != -1) return true;
- for (int i = 0; i < 8; i++) {
- if (kiki[i].chkArea(x,y)==true) {
- click = i;
- step = -1;
- }
- }
- return true;
- }
- }
-
- class Ntt_07pKOUKAN {
- int X,Y;
- Image imKoukan;
- Ntt_07pKOUKAN(int x, int y, String im_name, Ntt_07p parent) {
- X = x;
- Y = y;
- imKoukan = parent.getImage(parent.getCodeBase(), "images/" + im_name + ".gif");
- }
- boolean chkImage(Ntt_07p parent) {
- if (parent.prepareImage(imKoukan, parent) == false)
- return false;
- return true;
- }
- void drawKOUKAN(Graphics OS, Ntt_07p parent) {
- OS.drawImage(imKoukan, X, Y, parent);
- }
- }
-
- class Ntt_07pKIKI {
- int X,Y, width,height;
- Image imKiki[];
- AudioClip auCall[];
- boolean GOT, ONOFF;
- Ntt_07pKIKI(int x, int y, String name, String ab, Ntt_07p parent) {
- GOT = ONOFF = false;
- X = x;
- Y = y;
- imKiki = new Image[2];
- auCall = new AudioClip[2];
- for (int i = 0; i < 2; i++) {
- imKiki[i] = parent.getImage(parent.getCodeBase(), "images/" + name + ab + i + ".gif");
- auCall[i] = parent.getAudioClip(parent.getCodeBase(), "audio/" + name + i + ".au");
- }
- }
- void OFF() {
- ONOFF = false;
- }
- void CALL() {
- ONOFF = true;
- auCall[0].play();
- }
- void RECEIVE() {
- ONOFF = true;
- auCall[1].play();
- }
- boolean chkImage(Ntt_07p parent) {
- for (int i = 0; i < 2; i++) {
- if (parent.prepareImage(imKiki[i], parent) == false) {
- return false;
- }
- }
- width = imKiki[0].getWidth(parent);
- height = imKiki[0].getHeight(parent);
- GOT = true;
- return true;
- }
- void drawKIKI(Graphics OS, Ntt_07p parent) {
- if (!ONOFF) {
- OS.drawImage(imKiki[0], X, Y, parent);
- }
- else {
- OS.drawImage(imKiki[1], X, Y, parent);
- }
- }
- boolean chkArea(int x, int y) {
- if (x > X && x < X+width && y > Y && y < Y+height)
- return true;
- return false;
- }
- }
-
- class Ntt_07pKAITEI {
- int X,Y;
- Image imKaitei[];
- boolean ONOFF;
- Ntt_07pKAITEI(int x, int y, Ntt_07p parent) {
- ONOFF = false;
- X = x;
- Y = y;
- imKaitei = new Image[2];
- for (int i = 0; i < 2; i++)
- imKaitei[i] = parent.getImage(parent.getCodeBase(), "images/kaitei" + i + ".gif");
- }
- void OFF() {
- ONOFF = false;
- }
- void ON() {
- ONOFF = true;
- }
- void drawKAITEI(Graphics OS, Ntt_07p parent) {
- if (ONOFF) {
- OS.drawImage(imKaitei[1], X, Y, parent);
- }
- else {
- OS.drawImage(imKaitei[0], X, Y, parent);
- }
- }
- }
-
- class Ntt_07pLINE {
- int X1, Y1, X2, Y2;
- boolean ONOFF;
- Ntt_07pLINE(int x1, int y1, int x2, int y2) {
- ONOFF = false;
- X1 = x1; Y1 = y1; X2 = x2; Y2 = y2;
- }
- void ON() {
- ONOFF = true;
- }
- void OFF() {
- ONOFF = false;
- }
- void drawLINE(Graphics OS) {
- if (ONOFF) {
- Line(Color.yellow, OS);
- }
- else {
- Line(Color.darkGray, OS);
- }
- }
- void Line(Color col, Graphics OS) {
- OS.setColor(col);
- if (X1 == X2) { // tate
- for (int i = -2; i <= 1; i++) {
- OS.drawLine(X1+i,Y1,X1+i,Y2);
- }
- }
- else {
- if (Y1 == Y2) { // yoko
- for (int i = -2; i <= 1; i++) {
- OS.drawLine(X1,Y1+i,X2,Y2+i);
- }
- }
- else {
- OS.drawLine(X1,Y1,X2,Y2);
- for (int i = 1; i <= 2; i++) {
- OS.drawLine(X1,Y1-i,X2-i,Y2);
- OS.drawLine(X1,Y1+i,X2-i,Y2);
- OS.drawLine(X1+i,Y1,X2,Y2+i);
- OS.drawLine(X1+i,Y1,X2,Y2-i);
- }
- }
- }
- }
- }
-
- class Ntt_07pDENPA {
- int XX1, YY1, XX2, YY2;
- boolean ONOFF;
- Ntt_07pDENPA(int x1, int y1, int x2, int y2) {
- ONOFF = false;
- XX1 = x1; YY1 = y1; XX2 = x2; YY2 = y2;
- }
- void ON() {
- ONOFF = true;
- }
- void OFF() {
- ONOFF = false;
- }
- void drawDENPA(Graphics OS) {
- if (ONOFF) {
- int tx1, ty1, tx2, ty2;
- if (XX1 < XX2) {
- tx1 = XX1+(XX2-XX1)/2+(int)(Math.random()*10)+5;
- tx2 = XX1+(XX2-XX1)/2-((int)(Math.random()*10)+5);
- }
- else {
- tx1 = XX1+(XX2-XX1)/2-(int)(Math.random()*10)+5;
- tx2 = XX1+(XX2-XX1)/2+((int)(Math.random()*10)+5);
- }
- ty1 = YY1+(YY2-YY1)/2+(int)(Math.random()*10)-5;
- ty2 = YY1+(YY2-YY1)/2+(int)(Math.random()*10)-5;
- Line(XX1,YY1,tx1,ty1,Color.yellow, OS);
- Line(tx1,ty1,tx2,ty2,Color.yellow, OS);
- Line(tx2,ty2,XX2,YY2,Color.yellow, OS);
- }
- }
- void Line(int X1, int Y1, int X2, int Y2, Color col, Graphics OS) {
- OS.setColor(col);
- if (X1 == X2) { // tate
- for (int i = -2; i <= 1; i++) {
- OS.drawLine(X1+i,Y1,X1+i,Y2);
- }
- }
- else {
- if (Y1 == Y2) { // yoko
- for (int i = -2; i <= 1; i++) {
- OS.drawLine(X1,Y1+i,X2,Y2+i);
- }
- }
- else {
- OS.drawLine(X1,Y1,X2,Y2);
- for (int i = 1; i <= 2; i++) {
- OS.drawLine(X1,Y1-i,X2-i,Y2);
- OS.drawLine(X1,Y1+i,X2-i,Y2);
- OS.drawLine(X1+i,Y1,X2,Y2+i);
- OS.drawLine(X1+i,Y1,X2,Y2-i);
- }
- }
- }
- }
- }
-
-
- /*---------------------not use
- class Ntt_07pKOUKAN {
- int X,Y;
- Image imKoukan[];
- boolean ONOFF;
- Ntt_07pKOUKAN(int x, int y, String im_name, Ntt_07p parent) {
- X = x;
- Y = y;
- ONOFF = false;
- imKoukan = new Image[2];
- for (int i = 0; i < 2; i++) {
- imKoukan[i] = parent.getImage(parent.getCodeBase(), "images/" + im_name + i + ".gif");
- }
- }
- boolean chkImage(Ntt_07p parent) {
- for (int i = 0; i < 2; i++)
- if (parent.prepareImage(imKoukan[i], parent) == false)
- return false;
- return true;
- }
- void ON() {
- ONOFF = true;
- }
- void OFF() {
- ONOFF = false;
- }
- void drawKOUKAN(Graphics OS, Ntt_07p parent) {
- if (ONOFF)
- OS.drawImage(imKoukan[1], X, Y, parent);
- else
- OS.drawImage(imKoukan[0], X, Y, parent);
- }
- }
- */
-
-