home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 27 / IOPROG_27.ISO / SOFT / PACTAG.ZIP / PacTag.java
Encoding:
Text File  |  1999-05-17  |  37.2 KB  |  1,402 lines

  1. //****ALL CODE COPYRIGHT ⌐ DAVID KAPLAN 1999****\\
  2. //davkapl@aol.com
  3. //http://members.aol.com/davkapl
  4. //will work for low wages
  5. import java.awt.*;
  6. import java.applet.Applet;
  7. import java.util.Vector;
  8. import java.net.URL;
  9.  
  10. public class Pacman extends Applet    {
  11.     final static int appletWidth=425, appletHeight=440;
  12.     static Pacmen p=null, p2=null;
  13.     Wall w=null;
  14.     static int level, score, lives;
  15.     int size;
  16.     //int loading=0, xLoading=0;
  17.     //double kl=0;
  18.     //boolean loadingDir=true;
  19.     boolean started=false;
  20.     static Vector level1, level2, level3, levelCustom;
  21.     //MediaTracker pacImageTracker=null, DTracker=null, UTracker=null;
  22.     static Graphics gfx;
  23.     static boolean[][] customArray;
  24.     static boolean mapEditorOn;
  25.     Choice mapChoice, instructions, colorChoice, editorInstructions;
  26.     setPanel choicePanel;
  27.     ColorThread ct;
  28.     //Pacmen.PacRight=null;
  29.     //Pacmen.PacLeft=null;
  30.     //Pacmen.PacUp=null;
  31.     //Pacmen.PacDown=null;
  32.     //static Image i1,i2,i3,i4;
  33.     public void init()    {
  34.     //System.out.println("initialize MY ASS");
  35.         //pacImageTracker=new MediaTracker(this);
  36.         //pacLeftTracker=new MediaTracker(this);
  37.         //DTracker=new MediaTracker(this);
  38.         //UTracker=new MediaTracker(this);
  39.         //i1=getImage(getCodeBase(),"PacRight.gif");
  40.         //i2=getImage(getCodeBase(),"PacLeft.gif");
  41.         //i3=getImage(getCodeBase(),"PacUp.gif");
  42.         //i4=getImage(getCodeBase(),"PacDown.gif");
  43.         //pacImageTracker.addImage(i1,1);
  44.         //pacImageTracker.addImage(i2,1);
  45.         //UTracker.addImage(i3,1);
  46.         //DTracker.addImage(i4,1);
  47.         //pacImageTracker.checkID(1,true);
  48.         Pacmen.g=getGraphics();
  49.         level1=new Vector();
  50.         level2=new Vector();
  51.         level3=new Vector();
  52.         levelCustom=new Vector();
  53.         gfx=getGraphics();
  54.         ////////////////////////
  55.         gfx.drawString("DRAW MY ASS",200,200);
  56.         initLevel1();
  57.         level=0;
  58.         choicePanel=new setPanel(425,58);
  59.         setLayout(new BorderLayout(4,4));
  60.         add("South",choicePanel);
  61.         mapChoice=new Choice();
  62.         mapChoice.addItem("Map 1: The Fork");
  63.         mapChoice.addItem("Map 2: Garden Maze");
  64.         mapChoice.addItem("Map 3: Ode to Tetris");
  65.         mapChoice.addItem("Map 4: Custom");
  66.         mapChoice.addItem("Level Editor");
  67.         choicePanel.add(mapChoice);
  68.         instructions=new Choice();
  69.         instructions.addItem("INSTRUCTIONS (pull down)");
  70.         instructions.addItem("The object of the game is for the");
  71.         instructions.addItem("IT pac-person to tag the other one.");
  72.         instructions.addItem("Player one starts being IT, and they");
  73.         instructions.addItem("use the W, A, S, and D keys to move.");
  74.         instructions.addItem("Player two uses the arrow keys");
  75.         instructions.addItem("Copyright ⌐ 1999 David Kaplan");
  76.         instructions.addItem("davkapl@aol.com");
  77.         instructions.addItem("http://members.aol.com/davkapl");
  78.         choicePanel.add(instructions);
  79.         colorChoice=new Choice();
  80.         editorInstructions=new Choice();
  81.         colorChoice.addItem("Color List (for editor)");
  82.         colorChoice.addItem("Random");
  83.         colorChoice.addItem("Red");
  84.         colorChoice.addItem("Green");
  85.         colorChoice.addItem("Blue");
  86.         colorChoice.addItem("Magenta");
  87.         colorChoice.addItem("Yellow");
  88.         colorChoice.addItem("Orange");
  89.         colorChoice.addItem("White");
  90.         choicePanel.add(colorChoice);
  91.         editorInstructions.addItem("Level Editor Instructions");
  92.         editorInstructions.addItem("Click once to draw a wall,");
  93.         editorInstructions.addItem("and click again to erase it.");
  94.         editorInstructions.addItem("Select wall color using the");
  95.         editorInstructions.addItem("pull-down.  Then select the");
  96.         editorInstructions.addItem("'Custom' map and enjoy!");
  97.         choicePanel.add(editorInstructions);
  98.         customArray=new boolean[17][16];
  99.         ct=new ColorThread();
  100.     //System.out.println("initialize MY ASS");
  101.     }
  102.     public void start()    {
  103.     //try    {
  104.     //pacImageTracker.waitForID(1);
  105.     ///pacLeftTracker.waitForID(1);
  106.     //DTracker.waitForID(1);
  107.     //UTracker.waitForID(1);
  108.     //} catch (Exception e) {}
  109.     //System.out.println("start MY ASS");
  110.     //    gfx.drawString("PLEASE wklahjsldfhdlksnfkln",200,200);
  111.         //while ((!pacImageTracker.checkAll(true)))    {
  112.         //    System.out.println("loop MY ASS");
  113.         //    System.out.println(level);
  114.         //    System.out.println(pacImageTracker.checkAll(true));
  115.         //    System.out.println(DTracker.checkAll(true));
  116.         //    System.out.println(UTracker.checkAll(true));
  117.         //    if (pacImageTracker.checkAll(true))
  118.         //        System.out.println("TWO IS>>>IS WHAT I GOT");
  119.         //try{
  120.         //    Thread.sleep(20);
  121.         //} catch (Exception e){}
  122.             repaint();
  123.         //    if (kl%10000==0)    {
  124.         //        if (loadingDir)    {
  125.         //            if (xLoading<270)
  126.         //                xLoading++;
  127.         //            else
  128.         //                loadingDir=!loadingDir;
  129.         //        }
  130.         //        else    {
  131.         //            if (xLoading>0)
  132.         //                xLoading--;
  133.         //            else
  134.         //                loadingDir=!loadingDir;
  135.         //        }
  136.         //    }
  137.         //    if (kl%200000==0)
  138.         //        loading++;
  139.         //}
  140.     //    while (!pacImageTracker.checkAll(true))    {
  141.     //        repaint();
  142.     //    }
  143.         //level=1;
  144.         //if ((pacImageTracker.checkAll(true)))    {
  145.             p=new Pacmen(375,350,true,true);
  146.             p2=new Pacmen(25,25,false,false);
  147.         //}
  148.     }
  149.     public void paint(Graphics g)    {
  150.         //if ((pacImageTracker.checkAll(true)) && (UTracker.checkAll(true)) && (DTracker.checkAll(true)))    {
  151.             g.setColor(Color.black);
  152.             g.fillRect(0,0,appletWidth,appletHeight);
  153.         //    System.out.println("PLEASE ESPERA");
  154.         //} else    {
  155.         //    g.setColor(Color.green);
  156.         //    g.drawString("PLEASE WAIT",200,150);
  157.         //    g.setColor(Color.blue);
  158.         //    g.fillRect(40,180,40,30);
  159.         //    System.out.println("PLEASE ESPERA");
  160.         //}
  161.         if (level==1)    {
  162.             for (int i=0;i<level1.size();i++)    {
  163.                 w=(Wall)level1.elementAt(i);
  164.                 w.draw(g);
  165.             }
  166.         }
  167.         else if (level==2)    {
  168.             for (int i=0;i<level2.size();i++)    {
  169.                 w=(Wall)level2.elementAt(i);
  170.                 w.draw(g);
  171.             }
  172.         }
  173.         else if (level==3)    {
  174.             for (int i=0;i<level3.size();i++)    {
  175.                 w=(Wall)level3.elementAt(i);
  176.                 w.draw(g);
  177.             }
  178.         }
  179.         else if (level==4)    {
  180.             if (colorChoice.getSelectedIndex()==2)    {
  181.                 Wall.wallColor=Color.red;
  182.                 Wall.bricks=true;
  183.             }
  184.             else if (colorChoice.getSelectedIndex()==3)    {
  185.                 Wall.wallColor=Color.green;
  186.                 Wall.bricks=true;
  187.             }
  188.             else if (colorChoice.getSelectedIndex()==4)    {
  189.                 Wall.wallColor=Color.blue;
  190.                 Wall.bricks=true;
  191.             }
  192.             else if (colorChoice.getSelectedIndex()==5)    {
  193.                 Wall.wallColor=Color.magenta;
  194.                 Wall.bricks=true;
  195.             }
  196.             else if (colorChoice.getSelectedIndex()==6)    {
  197.                 Wall.wallColor=Color.yellow;
  198.                 Wall.bricks=true;
  199.             }
  200.             else if (colorChoice.getSelectedIndex()==7)    {
  201.                 Wall.wallColor=Color.orange;
  202.                 Wall.bricks=true;
  203.             }
  204.             else if (colorChoice.getSelectedIndex()==8)    {
  205.                 Wall.wallColor=Color.white;
  206.                 Wall.bricks=true;
  207.             }
  208.             for (int i=0;i<levelCustom.size();i++)    {
  209.                 if (colorChoice.getSelectedIndex()==1)    {
  210.                     int r=(int)(Math.random()*225)+30;
  211.                     int green=(int)(Math.random()*195)+60;
  212.                     int b=(int)(Math.random()*165)+90;
  213.                     Wall.wallColor=new Color(r,green,b);
  214.                     Wall.bricks=false;
  215.                 }
  216.                 w=(Wall)levelCustom.elementAt(i);
  217.                 w.draw(g);
  218.             }
  219.         }
  220.         else if (level==5)    {
  221.             g.setColor(Color.red);
  222.             for (int i=0;i<17;i++)    {
  223.                 for (int j=0;j<16;j++)    {
  224.                     if (customArray[i][j])
  225.                         g.fillRect(25*i,25*j,25,25);
  226.                 }
  227.             }
  228.             g.drawString("P1",25,35);
  229.             g.drawString("P2",375,360);
  230.             g.drawString("start",25,45);
  231.             g.drawString("start",375,370);
  232.         }
  233.         if (!started)    {
  234.             g.setColor(Color.green);
  235.             g.drawString("Click to begin",200,200);
  236.         }
  237.         g.setColor(Color.white);
  238.         g.fillRect(0,appletHeight-40,appletWidth,40);
  239.         g.setColor(Color.black);
  240.         //if ((level>0) && ((pacImageTracker.checkAll(true)) && (!UTracker.checkAll(true)) && (!DTracker.checkAll(true))))
  241.         if (level>0)
  242.             Pacman.updateStatusBar();
  243.     }
  244.     public boolean keyDown(Event e,int key)    {
  245.         if (key==1004)    {
  246.             if (p.checkUp())
  247.                 p.dir='u';
  248.             else
  249.                 p.waitingUp=true;
  250.         }
  251.         if (key==1005)    {
  252.             if (p.checkDown())
  253.                 p.dir='d';
  254.             else
  255.                 p.waitingDown=true;
  256.         }
  257.         if (key==1006)    {
  258.             if (p.checkLeft())
  259.                 p.dir='l';
  260.             else
  261.                 p.waitingLeft=true;
  262.         }
  263.         if (key==1007)    {
  264.             if (p.checkRight())
  265.                 p.dir='r';
  266.             else
  267.                 p.waitingRight=true;
  268.         }
  269.         if (key==119)    {
  270.             if (p2.checkUp())
  271.                 p2.dir='u';
  272.             else
  273.                 p2.waitingUp=true;
  274.         }
  275.         if (key==115)    {
  276.             if (p2.checkDown())
  277.                 p2.dir='d';
  278.             else
  279.                 p2.waitingDown=true;
  280.         }
  281.         if (key==97)    {
  282.             if (p2.checkLeft())
  283.                 p2.dir='l';
  284.             else
  285.                 p2.waitingLeft=true;
  286.         }
  287.         if (key==100)    {
  288.             if (p2.checkRight())
  289.                 p2.dir='r';
  290.             else
  291.                 p2.waitingRight=true;
  292.         }
  293.         return super.keyDown(e,key);
  294.     }
  295.     public boolean keyUp(Event e, int key)    {
  296.         if (key==1004)    {
  297.             p.waitingUp=false;
  298.         }
  299.         if (key==1005)    {
  300.             p.waitingDown=false;
  301.         }
  302.         if (key==1006)    {
  303.             p.waitingLeft=false;
  304.         }
  305.         if (key==1007)    {
  306.             p.waitingRight=false;
  307.         }
  308.         if (key==119)    {
  309.             p2.waitingUp=false;
  310.         }
  311.         if (key==115)    {
  312.             p2.waitingDown=false;
  313.         }
  314.         if (key==97)    {
  315.             p2.waitingLeft=false;
  316.         }
  317.         if (key==100)    {
  318.             p2.waitingRight=false;
  319.         }
  320.         return super.keyDown(e, key);
  321.     }
  322.     public boolean mouseDown(Event e, int x, int y)    {
  323.         if (!started)    {
  324.             started=true;
  325.             repaint();
  326.             p.start();
  327.             p2.start();
  328.             ct.start();
  329.             level=1;
  330.         }
  331.         if (mapEditorOn)    {
  332.             int a1=x/25;
  333.             int a2=y/25;
  334.             if (!(((a1==1) && (a2==1)) || ((a1==15) && (a2==14))))    {
  335.                 customArray[a1][a2]=!customArray[a1][a2];
  336.                 repaint();
  337.             }
  338.         }
  339.         return super.mouseDown(e, x, y);
  340.     }
  341.     static public void updateStatusBar()    {
  342.         gfx.setColor(Color.white);
  343.         gfx.fillRect(0,appletHeight-40,400,40);
  344.         gfx.setColor(Color.black);
  345.         if (!p.it)    {
  346.             gfx.drawString("Player One: You're it!  Tag player two!",100,appletHeight-28);
  347.             gfx.drawString("Player Two: Escape!  Don't let player one get you!",100,appletHeight-17);
  348.         } else    {
  349.             gfx.drawString("Player One: Escape!  Don't let player two get you!",100,appletHeight-28);
  350.             gfx.drawString("Player Two: You're it!  Tag player one!",100,appletHeight-17);
  351.         }
  352.     }
  353.     public void initLevel1()    {
  354.         w=new Wall(0,0,425,false);
  355.         level1.addElement(w);
  356.         w=new Wall(0,375,425,false);
  357.         level1.addElement(w);
  358.         w=new Wall(0,25,150,true);
  359.         level1.addElement(w);
  360.         w=new Wall(0,200,175,true);
  361.         level1.addElement(w);
  362.         w=new Wall(400,25,150,true);
  363.         level1.addElement(w);
  364.         w=new Wall(400,200,175,true);
  365.         level1.addElement(w);
  366.         w=new Wall(100,275,50,false);
  367.         level1.addElement(w);
  368.         w=new Wall(175,275,75,false);
  369.         level1.addElement(w);
  370.         w=new Wall(275,275,50,false);
  371.         level1.addElement(w);
  372.         w=new Wall(50,325,50,false);
  373.         level1.addElement(w);
  374.         w=new Wall(325,325,50,false);
  375.         level1.addElement(w);
  376.         w=new Wall(125,300,50,true);
  377.         level1.addElement(w);
  378.         w=new Wall(275,300,50,true);
  379.         level1.addElement(w);
  380.         w=new Wall(150,325,25,false);
  381.         level1.addElement(w);
  382.         w=new Wall(250,325,25,false);
  383.         level1.addElement(w);
  384.         w=new Wall(200,325,50,true);
  385.         level1.addElement(w);
  386.         w=new Wall(50,200,50,true);
  387.         level1.addElement(w);
  388.         w=new Wall(25,275,50,false);
  389.         level1.addElement(w);
  390.         w=new Wall(350,200,50,true);
  391.         level1.addElement(w);
  392.         w=new Wall(350,275,50,false);
  393.         level1.addElement(w);
  394.         w=new Wall(50,100,75,true);
  395.         level1.addElement(w);
  396.         w=new Wall(50,50,50,false);
  397.         level1.addElement(w);
  398.         w=new Wall(350,100,75,true);
  399.         level1.addElement(w);
  400.         w=new Wall(325,50,50,false);
  401.         level1.addElement(w);
  402.         w=new Wall(100,225,225,false);
  403.         level1.addElement(w);
  404.         w=new Wall(100,100,100,false);
  405.         level1.addElement(w);
  406.         w=new Wall(225,100,100,false);
  407.         level1.addElement(w);
  408.         w=new Wall(100,150,75,true);
  409.         level1.addElement(w);
  410.         w=new Wall(125,50,50,true);
  411.         level1.addElement(w);
  412.         w=new Wall(150,125,75,true);
  413.         level1.addElement(w);
  414.         w=new Wall(200,150,125,true);
  415.         level1.addElement(w);
  416.         w=new Wall(250,125,75,true);
  417.         level1.addElement(w);
  418.         w=new Wall(275,50,50,true);
  419.         level1.addElement(w);
  420.         w=new Wall(300,150,75,true);
  421.         level1.addElement(w);
  422.         w=new Wall(175,50,75,false);
  423.         level1.addElement(w);
  424.         w=new Wall(200,25,25,true);
  425.         level1.addElement(w);
  426.     }
  427.     public void initLevel2()    {
  428.         w=new Wall(0,0,175,false);
  429.         level2.addElement(w);
  430.         w=new Wall(250,0,175,false);
  431.         level2.addElement(w);
  432.         w=new Wall(0,0,175,true);
  433.         level2.addElement(w);
  434.         w=new Wall(0,225,175,true);
  435.         level2.addElement(w);
  436.         w=new Wall(0,375,175,false);
  437.         level2.addElement(w);
  438.         w=new Wall(250,375,175,false);
  439.         level2.addElement(w);
  440.         w=new Wall(400,0,175,true);
  441.         level2.addElement(w);
  442.         w=new Wall(400,225,175,true);
  443.         level2.addElement(w);
  444.         w=new Wall(50,50,325,false);
  445.         level2.addElement(w);
  446.         w=new Wall(50,325,325,false);
  447.         level2.addElement(w);
  448.         w=new Wall(75,75,75,true);
  449.         level2.addElement(w);
  450.         w=new Wall(75,225,100,true);
  451.         level2.addElement(w);
  452.         w=new Wall(325,75,75,true);
  453.         level2.addElement(w);
  454.         w=new Wall(325,225,100,true);
  455.         level2.addElement(w);
  456.         w=new Wall(325,225,75,true);
  457.         level2.addElement(w);
  458.         w=new Wall(150,125,150,true);
  459.         level2.addElement(w);
  460.         w=new Wall(175,125,25,true);
  461.         level2.addElement(w);
  462.         w=new Wall(175,250,25,true);
  463.         level2.addElement(w);
  464.         w=new Wall(225,125,25,true);
  465.         level2.addElement(w);
  466.         w=new Wall(225,250,25,true);
  467.         level2.addElement(w);
  468.         w=new Wall(25,100,25,true);
  469.         level2.addElement(w);
  470.         w=new Wall(25,275,25,true);
  471.         level2.addElement(w);
  472.         w=new Wall(375,100,25,true);
  473.         level2.addElement(w);
  474.         w=new Wall(375,275,25,true);
  475.         level2.addElement(w);
  476.         w=new Wall(250,125,150,true);
  477.         level2.addElement(w);
  478.     }
  479.     public void initLevel3()    {
  480.         w=new Wall(0,0,100,false);
  481.         level3.addElement(w);
  482.         w=new Wall(325,375,100,false);
  483.         level3.addElement(w);
  484.         w=new Wall(50,50,50,false);
  485.         level3.addElement(w);
  486.         w=new Wall(50,75,50,false);
  487.         level3.addElement(w);
  488.         w=new Wall(325,300,50,false);
  489.         level3.addElement(w);
  490.         w=new Wall(325,325,50,false);
  491.         level3.addElement(w);
  492.         w=new Wall(150,25,50,false);
  493.         level3.addElement(w);
  494.         w=new Wall(150,50,50,false);
  495.         level3.addElement(w);
  496.         w=new Wall(225,325,50,false);
  497.         level3.addElement(w);
  498.         w=new Wall(225,350,50,false);
  499.         level3.addElement(w);
  500.         w=new Wall(0,150,100,true);
  501.         level3.addElement(w);
  502.         w=new Wall(0,325,75,true);
  503.         level3.addElement(w);
  504.         w=new Wall(25,175,25,true);
  505.         level3.addElement(w);
  506.         w=new Wall(25,350,25,true);
  507.         level3.addElement(w);
  508.         w=new Wall(25,275,25,true);
  509.         level3.addElement(w);
  510.         w=new Wall(50,125,75,true);
  511.         level3.addElement(w);
  512.         w=new Wall(50,250,75,true);
  513.         level3.addElement(w);
  514.         w=new Wall(100,125,50,false);
  515.         level3.addElement(w);
  516.         w=new Wall(100,175,100,true);
  517.         level3.addElement(w);
  518.         w=new Wall(100,325,75,false);
  519.         level3.addElement(w);
  520.         w=new Wall(125,275,75,false);
  521.         level3.addElement(w);
  522.         w=new Wall(125,100,50,false);
  523.         level3.addElement(w);
  524.         w=new Wall(150,175,50,true);
  525.         level3.addElement(w);
  526.         w=new Wall(150,350,25,true);
  527.         level3.addElement(w);
  528.         w=new Wall(175,150,50,true);
  529.         level3.addElement(w);
  530.         w=new Wall(175,250,50,true);
  531.         level3.addElement(w);
  532.         w=new Wall(225,100,75,false);
  533.         level3.addElement(w);
  534.         w=new Wall(225,125,25,true);
  535.         level3.addElement(w);
  536.         w=new Wall(225,200,50,true);
  537.         level3.addElement(w);
  538.         w=new Wall(250,25,25,true);
  539.         level3.addElement(w);
  540.         w=new Wall(250,50,75,false);
  541.         level3.addElement(w);
  542.         w=new Wall(250,175,50,true);
  543.         level3.addElement(w);
  544.         w=new Wall(250,275,50,false);
  545.         level3.addElement(w);
  546.         w=new Wall(275,250,50,false);
  547.         level3.addElement(w);
  548.         w=new Wall(300,125,100,true);
  549.         level3.addElement(w);
  550.         w=new Wall(350,75,75,true);
  551.         level3.addElement(w);
  552.         w=new Wall(350,200,75,true);
  553.         level3.addElement(w);
  554.         w=new Wall(375,100,25,false);
  555.         level3.addElement(w);
  556.         w=new Wall(375,25,25,true);
  557.         level3.addElement(w);
  558.         w=new Wall(375,200,25,false);
  559.         level3.addElement(w);
  560.         w=new Wall(400,0,75,true);
  561.         level3.addElement(w);
  562.         w=new Wall(400,150,100,true);
  563.         level3.addElement(w);
  564.     }
  565.     public void initLevelCustom()    {
  566.         levelCustom=new Vector();
  567.         for (int i=0;i<17;i++)    {
  568.             for (int j=0;j<16;j++)    {
  569.                 if (customArray[i][j])    
  570.                     levelCustom.addElement(new Wall(i*25,j*25,25,true));
  571.             }
  572.         }
  573.     }
  574.     static public void tag(int x, int y)    {
  575.         p.it=!p.it;
  576.         p2.it=!p2.it;
  577.         gfx.setColor(Color.black);
  578.         gfx.fillRect(p.x,p.y,25,25);
  579.         gfx.fillRect(p2.x,p2.y,25,25);
  580.         if (x<200)    {
  581.             if (p.it)    {
  582.                 p.x=375;
  583.                 p.y=350;
  584.                 //p.c=Pacmen.itColor;
  585.                 //p2.c=Color.yellow;
  586.             } else    {
  587.                 p2.x=375;
  588.                 p2.y=350;
  589.                 //p.c=Color.yellow;
  590.                 //p2.c=Pacmen.itColor;
  591.             }
  592.         } else    {
  593.             if (p.it)    {
  594.                 p.x=25;
  595.                 p.y=25;
  596.                 //p.c=Pacmen.itColor;
  597.                 //p2.c=Color.yellow;
  598.             } else    {
  599.                 p2.x=25;
  600.                 p2.y=25;
  601.                 //p.c=Color.yellow;
  602.                 //p2.c=Pacmen.itColor;
  603.             }
  604.         }
  605.         if (p.it)    {
  606.             p.delay=Pacmen.itDelay;
  607.             p2.delay=Pacmen.escapeDelay;
  608.         }    else    {
  609.             p.delay=Pacmen.escapeDelay;
  610.             p2.delay=Pacmen.itDelay;
  611.         }
  612.         updateStatusBar();
  613.     }
  614.     public boolean action(Event e, Object arg)    {
  615.         if (e.target==mapChoice)    {
  616.             int i=mapChoice.getSelectedIndex();
  617.             Pacman.level=i+1;
  618.             if (i==0)    {
  619.                 initLevel1();
  620.                 mapEditorOn=false;
  621.                 level=1;
  622.                 Wall.wallColor=Color.red;
  623.                 Wall.bricks=true;
  624.             }
  625.             else if (i==1)    {
  626.                 initLevel2();
  627.                 mapEditorOn=false;
  628.                 level=2;
  629.                 Wall.wallColor=Color.green;
  630.                 Wall.bricks=true;
  631.             }
  632.             else if (i==2)    {
  633.                 initLevel3();
  634.                 mapEditorOn=false;
  635.                 level=3;
  636.                 Wall.wallColor=Color.blue;
  637.                 Wall.bricks=false;
  638.             }
  639.             else if (i==3)    {
  640.                 initLevelCustom();
  641.                 mapEditorOn=false;
  642.                 level=4;
  643.                 Wall.wallColor=Color.magenta;
  644.                 Wall.bricks=false;
  645.             }
  646.             else if (i==4)    {
  647.                 initLevelCustom();
  648.                 mapEditorOn=true;
  649.                 level=5;
  650.                 p.stop();
  651.                 p2.stop();
  652.                 gfx.setColor(Color.black);
  653.                 gfx.fillRect(0,0,425,400);
  654.                 gfx.setColor(Color.red);
  655.                 gfx.drawString("P1",25,35);
  656.                 gfx.drawString("P2",375,360);
  657.                 gfx.drawString("start",25,45);
  658.                 gfx.drawString("start",375,370);
  659.                 repaint();
  660.             }
  661.             if (i<4)
  662.                 newGame();
  663.         }
  664.         if (e.target==instructions)    {
  665.             if (instructions.getSelectedIndex()==8)
  666.                 try    {
  667.                     getAppletContext().showDocument(new URL("http://members.aol.com/davkapl"));
  668.                 } catch(Exception malformedurl) {}
  669.         }
  670.         return super.action(e, arg);
  671.     }
  672.     public void newGame()    {
  673.         p.stop();
  674.         p2.stop();
  675.         p=new Pacmen(25,25,true,true);
  676.         p2=new Pacmen(375,350,false,false);
  677.         p.start();
  678.         p2.start();
  679.         repaint();
  680.         updateStatusBar();
  681.     }
  682.     public void destroy()    {
  683.     }
  684. }
  685. class ColorThread extends Thread    {
  686.     int R=255;
  687.     int G=255;
  688.     int B=0;
  689.     int R2=0,G2=255,B2=255;
  690.     public void run()    {
  691.         while (Pacman.p.alive)    {
  692.             Pacmen.itColor=new Color(R,G,B);
  693.             Pacmen.itColor2=new Color(B,G,R);
  694.             try    {
  695.                 sleep(10);
  696.             } catch (Exception e)    {}
  697.             if (Pacmen.toYellow)    {
  698.                 if (G>0)
  699.                     G--;
  700.                 else    {
  701.                     G++;
  702.                     Pacmen.toYellow=false;
  703.                 }
  704.             }
  705.             else     {
  706.                 if (G<255)
  707.                     G++;
  708.                 else {
  709.                     G--;
  710.                     Pacmen.toYellow=true;
  711.                 }
  712.             }
  713.         }
  714.     }
  715. }
  716.             
  717. class Pacmen extends Thread    {
  718.     //static Image PacRight, PacUp, PacLeft, PacDown;
  719.     //Color c=new Color(127,127,0);
  720.     static Color itColor=new Color(255,255,0), itColor2=new Color(0,0,255);
  721.     static Graphics g;
  722.     char dir='r';
  723.     boolean p;
  724.     int x, y;
  725.     int stage=44;
  726.     boolean closing=true;
  727.     static boolean toYellow=true, toGreen=false;
  728.     final static int escapeDelay=8;
  729.     final static int itDelay=6;
  730.     static boolean alive=true;
  731.     boolean it;
  732.     static Font itFont=new Font("Geneva",Font.PLAIN,10);
  733.     boolean waitingUp=false, waitingDown=false, waitingRight=false, waitingLeft=false;
  734.     short delay;
  735.     final static int pacWidth=25, pacHeight=25;
  736.     Pacmen(int x, int y, boolean it, boolean p)    {
  737.         this.x=x;
  738.         this.y=y;
  739.         this.it=it;
  740.         this.p=p;
  741.         if (it)    {
  742.             this.delay=itDelay;
  743.             //this.c=Color.orange;
  744.         }
  745.         else    {
  746.             this.delay=escapeDelay;
  747.             //this.c=Color.yellow;
  748.         }
  749.     }
  750.     public void run()    {
  751.         while (alive)    {
  752.             if (closing)    {
  753.                 if (stage>0)
  754.                     stage-=2;
  755.                 else    {
  756.                     stage+=2;
  757.                     closing=false;
  758.                 }
  759.             }
  760.             else    {
  761.                 if (stage<44)
  762.                     stage+=2;
  763.                 else    {
  764.                     stage-=2;
  765.                     closing=true;
  766.                 }
  767.             }
  768.             if (this.dir=='r')    {
  769.                     //g.drawImage(PacRight,this.x,this.y,new Pacman());
  770.                     if (this.it)    {
  771.                         if (this.p)
  772.                             g.setColor(itColor);
  773.                         else
  774.                             g.setColor(itColor2);
  775.                     }
  776.                     else    {
  777.                         if (this.p)
  778.                             g.setColor(Color.yellow);
  779.                         else
  780.                             g.setColor(Color.blue);
  781.                     }
  782.                     g.fillArc(this.x, this.y,25,25,this.stage*1,360-this.stage*2*1);
  783.                     g.setColor(Color.black);
  784.                     g.drawOval(this.x+7,this.y+3,5,5);
  785.                     g.fillOval(this.x+10,this.y+5,3,3);
  786.                     if (this.it)    {
  787.                         g.setColor(Color.black);
  788.                         g.setFont(itFont);
  789.                         g.drawString("IT",this.x+9,this.y+17);
  790.                     }
  791.                     try    {
  792.                         sleep((int)this.delay);
  793.                     } catch (Exception e)    {}
  794.                     g.setColor(Color.black);
  795.                     g.fillRect(this.x,this.y,pacHeight,pacHeight);
  796.                     if (checkRight())    {
  797.                         this.x+=1;
  798.                         if (this.x>=Pacman.appletWidth)    {
  799.                             this.x=0;
  800.                         }
  801.                         if (this.waitingDown)    {
  802.                             if (checkDown())
  803.                                 this.dir='d';
  804.                         }
  805.                         if (this.waitingLeft)    {
  806.                             if (checkLeft())
  807.                                 this.dir='l';
  808.                         }
  809.                         if (this.waitingUp)    {
  810.                             if (checkUp())
  811.                                 this.dir='u';
  812.                         }
  813.                         if (this==Pacman.p)    {
  814.                             if ((this.x+25>Pacman.p2.x) && (this.x<Pacman.p2.x+25) && (this.y+25>Pacman.p2.y) && (this.y<Pacman.p2.y+25))    {
  815.                                 Pacman.tag(this.x, this.y);
  816.                             }
  817.                         } else    {
  818.                             if ((this.x+25>Pacman.p.x) && (this.x<Pacman.p.x+25) && (this.y+25>Pacman.p.y) && (this.y<Pacman.p.y+25))    {
  819.                                 Pacman.tag(this.x, this.y);
  820.                             }
  821.                         }
  822.                     }
  823.             }
  824.             if (this.dir=='u')    {
  825.                     //g.drawImage(PacUp, this.x, this.y, new Pacman());
  826.                     if (this.it)    {
  827.                         if (this.p)
  828.                             g.setColor(itColor);
  829.                         else
  830.                             g.setColor(itColor2);
  831.                     }
  832.                     else    {
  833.                         if (this.p)
  834.                             g.setColor(Color.yellow);
  835.                         else
  836.                             g.setColor(Color.blue);
  837.                     }
  838.                     g.fillArc(this.x, this.y,25,25,90+this.stage*1,360-this.stage*2*1);
  839.                     g.setColor(Color.black);
  840.                     g.drawOval(this.x+3,this.y+14,5,5);
  841.                     g.fillOval(this.x+5,this.y+14,3,3);
  842.                     if (this.it)    {
  843.                         g.setColor(Color.black);
  844.                         g.setFont(itFont);
  845.                         g.drawString("IT",this.x+9,this.y+17);
  846.                     }
  847.                     try    {
  848.                         sleep((int)this.delay);
  849.                     } catch (Exception e)    {}
  850.                     g.setColor(Color.black);
  851.                     g.fillRect(this.x,this.y,pacHeight,pacHeight);
  852.                     if (checkUp())    {
  853.                         this.y-=1;
  854.                         if (this.y<=-pacHeight)
  855.                             this.y=Pacman.appletHeight-40-25;
  856.                         if (this.waitingRight)    {
  857.                             if (checkRight())
  858.                                 this.dir='r';
  859.                         }
  860.                         if (this.waitingLeft)    {
  861.                             if (checkLeft())
  862.                                 this.dir='l';
  863.                         }
  864.                         if (this.waitingDown)    {
  865.                             if (checkDown())
  866.                                 this.dir='d';
  867.                         }
  868.                         if (this==Pacman.p)    {
  869.                             if ((this.x+25>Pacman.p2.x) && (this.x<Pacman.p2.x+25) && (this.y+25>Pacman.p2.y) && (this.y<Pacman.p2.y+25))    {
  870.                                 Pacman.tag(this.x, this.y);
  871.                             }
  872.                         } else    {
  873.                             if ((this.x+25>Pacman.p.x) && (this.x<Pacman.p.x+25) && (this.y+25>Pacman.p.y) && (this.y<Pacman.p.y+25))    {
  874.                                 Pacman.tag(this.x, this.y);
  875.                             }
  876.                         }
  877.                     }
  878.             }
  879.             if (this.dir=='l')    {
  880.                     //g.drawImage(PacLeft, this.x, this.y, new Pacman());
  881.                     if (this.it)    {
  882.                         if (this.p)
  883.                             g.setColor(itColor);
  884.                         else
  885.                             g.setColor(itColor2);
  886.                     }
  887.                     else    {
  888.                         if (this.p)
  889.                             g.setColor(Color.yellow);
  890.                         else
  891.                             g.setColor(Color.blue);
  892.                     }
  893.                     g.fillArc(this.x, this.y,25,25,180+this.stage*1,360-this.stage*2*1);
  894.                     g.setColor(Color.black);
  895.                     g.drawOval(this.x+12,this.y+3,5,5);
  896.                     g.fillOval(this.x+12,this.y+5,3,3);
  897.                     if (this.it)    {
  898.                         g.setColor(Color.black);
  899.                         g.setFont(itFont);
  900.                         g.drawString("IT",this.x+9,this.y+17);
  901.                     }
  902.                     try    {
  903.                         sleep((int)this.delay);
  904.                     } catch (Exception e)    {}
  905.                     g.setColor(Color.black);
  906.                     g.fillRect(this.x,this.y,pacHeight,pacHeight);
  907.                     if (checkLeft())    {
  908.                         this.x-=1;
  909.                         if (this.x<=-pacWidth)
  910.                             this.x=Pacman.appletWidth-pacWidth;
  911.                         if (this.waitingRight)    {
  912.                             if (checkRight())
  913.                                 this.dir='r';
  914.                         }
  915.                         if (this.waitingDown)    {
  916.                             if (checkDown())
  917.                                 this.dir='d';
  918.                         }
  919.                         if (this.waitingUp)    {
  920.                             if (checkUp())
  921.                                 this.dir='u';
  922.                         }
  923.                         if (this==Pacman.p)    {
  924.                             if ((this.x+25>Pacman.p2.x) && (this.x<Pacman.p2.x+25) && (this.y+25>Pacman.p2.y) && (this.y<Pacman.p2.y+25))    {
  925.                                 Pacman.tag(this.x, this.y);
  926.                             }
  927.                         } else    {
  928.                             if ((this.x+25>Pacman.p.x) && (this.x<Pacman.p.x+25) && (this.y+25>Pacman.p.y) && (this.y<Pacman.p.y+25))    {
  929.                                 Pacman.tag(this.x, this.y);
  930.                             }
  931.                         }
  932.                     }
  933.             }
  934.             if (this.dir=='d')    {
  935.                     //g.drawImage(PacDown, this.x, this.y, new Pacman());
  936.                     if (this.it)    {
  937.                         if (this.p)
  938.                             g.setColor(itColor);
  939.                         else
  940.                             g.setColor(itColor2);
  941.                     }
  942.                     else    {
  943.                         if (this.p)
  944.                             g.setColor(Color.yellow);
  945.                         else
  946.                             g.setColor(Color.blue);
  947.                     }
  948.                     g.fillArc(this.x, this.y,25,25,270+this.stage*1,360-this.stage*2*1);
  949.                     g.setColor(Color.black);
  950.                     g.drawOval(this.x+18,this.y+11,5,5);
  951.                     g.fillOval(this.x+19,this.y+14,3,3);
  952.                     if (this.it)    {
  953.                         g.setColor(Color.black);
  954.                         g.setFont(itFont);
  955.                         g.drawString("IT",this.x+9,this.y+17);
  956.                     }
  957.                     try    {
  958.                         sleep((int)this.delay);
  959.                     } catch (Exception e)    {}
  960.                     g.setColor(Color.black);
  961.                     g.fillRect(this.x,this.y,pacHeight,pacHeight);
  962.                     if (checkDown())    {
  963.                         if (this.y>=Pacman.appletHeight-40-25)    {
  964.                             g.setColor(Color.black);
  965.                             g.fillRect(this.x,375,25,25);
  966.                             this.y=-25;
  967.                         }
  968.                         this.y+=1;
  969.                         if (this.waitingRight)    {
  970.                             if (checkRight())
  971.                                 this.dir='r';
  972.                         }
  973.                         if (this.waitingLeft)    {
  974.                             if (checkLeft())
  975.                                 this.dir='l';
  976.                         }
  977.                         if (this.waitingUp)    {
  978.                             if (checkUp())
  979.                                 this.dir='u';
  980.                         }
  981.                         if (this==Pacman.p)    {
  982.                             if ((this.x+25>Pacman.p2.x) && (this.x<Pacman.p2.x+25) && (this.y+25>Pacman.p2.y) && (this.y<Pacman.p2.y+25))    {
  983.                                 Pacman.tag(this.x, this.y);
  984.                             }
  985.                         } else    {
  986.                             if ((this.x+25>Pacman.p.x) && (this.x<Pacman.p.x+25) && (this.y+25>Pacman.p.y) && (this.y<Pacman.p.y+25))    {
  987.                                 Pacman.tag(this.x, this.y);
  988.                             }
  989.                         }
  990.                     }
  991.             }
  992.         }
  993.     }
  994.     public boolean checkRight()    {
  995.         boolean OK=true;
  996.         Wall w;
  997.         if (Pacman.level==1)    {
  998.             for (int i=0;i<Pacman.level1.size();i++)    {
  999.                 w=(Wall)Pacman.level1.elementAt(i);
  1000.                 if (w.vertical)    {
  1001.                     if (((!(this.x+25<w.x1)) && (this.y+25>w.y1) && (this.y<w.y1+w.length)) && !(this.x+25>w.x1))
  1002.                         OK=false;
  1003.                 } else    {
  1004.                     if (((!(this.x+25<w.x1)) && (this.y+25>w.y1) && (this.y<w.y1+Wall.width)) && !(this.x+25>w.x1))
  1005.                     OK=false;
  1006.                 }
  1007.             }
  1008.         }
  1009.         else if (Pacman.level==2)    {
  1010.             for (int i=0;i<Pacman.level2.size();i++)    {
  1011.                 w=(Wall)Pacman.level2.elementAt(i);
  1012.                 if (w.vertical)    {
  1013.                     if (((!(this.x+25<w.x1)) && (this.y+25>w.y1) && (this.y<w.y1+w.length)) && !(this.x+25>w.x1))
  1014.                         OK=false;
  1015.                 } else    {
  1016.                     if (((!(this.x+25<w.x1)) && (this.y+25>w.y1) && (this.y<w.y1+Wall.width)) && !(this.x+25>w.x1))
  1017.                     OK=false;
  1018.                 }
  1019.             }
  1020.         }
  1021.         else if (Pacman.level==3)    {
  1022.             for (int i=0;i<Pacman.level3.size();i++)    {
  1023.                 w=(Wall)Pacman.level3.elementAt(i);
  1024.                 if (w.vertical)    {
  1025.                     if (((!(this.x+25<w.x1)) && (this.y+25>w.y1) && (this.y<w.y1+w.length)) && !(this.x+25>w.x1))
  1026.                         OK=false;
  1027.                 } else    {
  1028.                     if (((!(this.x+25<w.x1)) && (this.y+25>w.y1) && (this.y<w.y1+Wall.width)) && !(this.x+25>w.x1))
  1029.                     OK=false;
  1030.                 }
  1031.             }
  1032.             if (this.x>=400)    {
  1033.                 for (int i=0;i<Pacman.level3.size();i++)    {
  1034.                     w=(Wall)Pacman.level3.elementAt(i);
  1035.                     if (w.x1==0)    {
  1036.                         if (w.vertical)    {
  1037.                             if ((w.y1<this.y+25) && (w.y1+w.length>this.y))
  1038.                                 OK=false;
  1039.                         }
  1040.                         else    {
  1041.                             if ((w.y1<this.y+25) && (w.y1+Wall.width>this.y))
  1042.                                 OK=false;
  1043.                         }
  1044.                     }
  1045.                 }
  1046.             }
  1047.         }
  1048.         else if (Pacman.level==4)    {
  1049.             for (int i=0;i<Pacman.levelCustom.size();i++)    {
  1050.                 w=(Wall)Pacman.levelCustom.elementAt(i);
  1051.                 if (w.vertical)    {
  1052.                     if (((!(this.x+25<w.x1)) && (this.y+25>w.y1) && (this.y<w.y1+w.length)) && !(this.x+25>w.x1))
  1053.                         OK=false;
  1054.                 } else    {
  1055.                     if (((!(this.x+25<w.x1)) && (this.y+25>w.y1) && (this.y<w.y1+Wall.width)) && !(this.x+25>w.x1))
  1056.                     OK=false;
  1057.                 }
  1058.             }
  1059.             if (this.x>=400)    {
  1060.                 for (int i=0;i<Pacman.levelCustom.size();i++)    {
  1061.                     w=(Wall)Pacman.levelCustom.elementAt(i);
  1062.                     if (w.x1==0)    {
  1063.                         if (w.vertical)    {
  1064.                             if ((w.y1<this.y+25) && (w.y1+w.length>this.y))
  1065.                                 OK=false;
  1066.                         }
  1067.                         else    {
  1068.                             if ((w.y1<this.y+25) && (w.y1+Wall.width>this.y))
  1069.                                 OK=false;
  1070.                         }
  1071.                     }
  1072.                 }
  1073.             }
  1074.         }
  1075.         return OK;
  1076.     }
  1077.     public boolean checkUp()    {
  1078.         boolean OK=true;
  1079.         Wall w;
  1080.         if (Pacman.level==1)    {
  1081.             for (int i=0;i<Pacman.level1.size();i++)    {
  1082.                 w=(Wall)Pacman.level1.elementAt(i);
  1083.                 if (!w.vertical)    {
  1084.                     if (((!(this.y>w.y1+Wall.width)) && (this.x+25>w.x1) && (this.x<w.x1+w.length)) && !(this.y<w.y1))
  1085.                         OK=false;
  1086.                 } else    {
  1087.                     if (((!(this.y>w.y1+w.length)) && (this.x+25>w.x1) && (this.x<w.x1+Wall.width)) && !(this.y<w.y1))
  1088.                         OK=false;
  1089.                 }
  1090.             }
  1091.         }
  1092.         else if (Pacman.level==2)    {
  1093.             for (int i=0;i<Pacman.level2.size();i++)    {
  1094.                 w=(Wall)Pacman.level2.elementAt(i);
  1095.                 if (!w.vertical)    {
  1096.                     if (((!(this.y>w.y1+Wall.width)) && (this.x+25>w.x1) && (this.x<w.x1+w.length)) && !(this.y<w.y1))
  1097.                         OK=false;
  1098.                 } else    {
  1099.                     if (((!(this.y>w.y1+w.length)) && (this.x+25>w.x1) && (this.x<w.x1+Wall.width)) && !(this.y<w.y1))
  1100.                         OK=false;
  1101.                 }
  1102.             }
  1103.         }
  1104.         else if (Pacman.level==3)    {
  1105.             for (int i=0;i<Pacman.level3.size();i++)    {
  1106.                 w=(Wall)Pacman.level3.elementAt(i);
  1107.                 if (!w.vertical)    {
  1108.                     if (((!(this.y>w.y1+Wall.width)) && (this.x+25>w.x1) && (this.x<w.x1+w.length)) && !(this.y<w.y1))
  1109.                         OK=false;
  1110.                 } else    {
  1111.                     if (((!(this.y>w.y1+w.length)) && (this.x+25>w.x1) && (this.x<w.x1+Wall.width)) && !(this.y<w.y1))
  1112.                         OK=false;
  1113.                 }
  1114.             }
  1115.             if (this.y<=0)    {
  1116.                 for (int i=0;i<Pacman.level3.size();i++)    {
  1117.                     w=(Wall)Pacman.level3.elementAt(i);
  1118.                     if ((w.y1==375) || ((w.y1+w.length==400) && (w.vertical)))    {
  1119.                         if (w.vertical)    {
  1120.                             if ((this.x<w.x1+25) && (this.x+25>w.x1))
  1121.                                 OK=false;
  1122.                         }
  1123.                         else    {
  1124.                             if ((this.x<w.x1+w.length) && (this.x+25>w.x1))
  1125.                                 OK=false;
  1126.                         }
  1127.                     }
  1128.                 }
  1129.             }
  1130.         }
  1131.         else if (Pacman.level==4)    {
  1132.             for (int i=0;i<Pacman.levelCustom.size();i++)    {
  1133.                 w=(Wall)Pacman.levelCustom.elementAt(i);
  1134.                 if (!w.vertical)    {
  1135.                     if (((!(this.y>w.y1+Wall.width)) && (this.x+25>w.x1) && (this.x<w.x1+w.length)) && !(this.y<w.y1))
  1136.                         OK=false;
  1137.                 } else    {
  1138.                     if (((!(this.y>w.y1+w.length)) && (this.x+25>w.x1) && (this.x<w.x1+Wall.width)) && !(this.y<w.y1))
  1139.                         OK=false;
  1140.                 }
  1141.             }
  1142.             if (this.y<=0)    {
  1143.                 for (int i=0;i<Pacman.levelCustom.size();i++)    {
  1144.                     w=(Wall)Pacman.levelCustom.elementAt(i);
  1145.                     if (w.y1==375)    {
  1146.                         if (w.vertical)    {
  1147.                             if ((this.x<w.x1+25) && (this.x+25>w.x1))
  1148.                                 OK=false;
  1149.                         }
  1150.                         else    {
  1151.                             if ((this.x<w.x1+w.length) && (this.x+25>w.x1))
  1152.                                 OK=false;
  1153.                         }
  1154.                     }
  1155.                 }
  1156.             }
  1157.         }
  1158.         return OK;
  1159.     }
  1160.     public boolean checkLeft()    {
  1161.         boolean OK=true;
  1162.         Wall w;
  1163.         if (Pacman.level==1)    {
  1164.             for (int i=0;i<Pacman.level1.size();i++)    {
  1165.                 w=(Wall)Pacman.level1.elementAt(i);
  1166.                 if (w.vertical)    {
  1167.                     if (((!(this.x>w.x1+Wall.width)) && (this.y+25>w.y1) && (this.y<w.y1+w.length)) && !(this.x<w.x1))
  1168.                         OK=false;
  1169.                 } else    {
  1170.                     if (((!(this.x>w.x1+w.length)) && (this.y+25>w.y1) && (this.y<w.y1+Wall.width)) && !(this.x<w.x1))
  1171.                         OK=false;
  1172.                 }
  1173.             }
  1174.         }
  1175.         else if (Pacman.level==2)    {
  1176.             for (int i=0;i<Pacman.level2.size();i++)    {
  1177.                 w=(Wall)Pacman.level2.elementAt(i);
  1178.                 if (w.vertical)    {
  1179.                     if (((!(this.x>w.x1+Wall.width)) && (this.y+25>w.y1) && (this.y<w.y1+w.length)) && !(this.x<w.x1))
  1180.                         OK=false;
  1181.                 } else    {
  1182.                     if (((!(this.x>w.x1+w.length)) && (this.y+25>w.y1) && (this.y<w.y1+Wall.width)) && !(this.x<w.x1))
  1183.                         OK=false;
  1184.                 }
  1185.             }
  1186.         }
  1187.         else if (Pacman.level==3)    {
  1188.             for (int i=0;i<Pacman.level3.size();i++)    {
  1189.                 w=(Wall)Pacman.level3.elementAt(i);
  1190.                 if (w.vertical)    {
  1191.                     if (((!(this.x>w.x1+Wall.width)) && (this.y+25>w.y1) && (this.y<w.y1+w.length)) && !(this.x<w.x1))
  1192.                         OK=false;
  1193.                 } else    {
  1194.                     if (((!(this.x>w.x1+w.length)) && (this.y+25>w.y1) && (this.y<w.y1+Wall.width)) && !(this.x<w.x1))
  1195.                         OK=false;
  1196.                 }
  1197.             }
  1198.             if (this.x<=0)    {
  1199.                 for (int i=0;i<Pacman.level3.size();i++)    {
  1200.                     w=(Wall)Pacman.level3.elementAt(i);
  1201.                     if ((w.x1==400) || ((w.x1+w.length==425) && (!w.vertical)))    {
  1202.                         if (w.vertical)    {
  1203.                             if ((w.y1<this.y+25) && (w.y1+w.length>this.y))
  1204.                                 OK=false;
  1205.                         }
  1206.                         else    {
  1207.                             if ((w.y1<this.y+25) && (w.y1+Wall.width>this.y))
  1208.                                 OK=false;
  1209.                         }
  1210.                     }
  1211.                 }
  1212.             }
  1213.         }
  1214.         else if (Pacman.level==4)    {
  1215.             for (int i=0;i<Pacman.levelCustom.size();i++)    {
  1216.                 w=(Wall)Pacman.levelCustom.elementAt(i);
  1217.                 if (w.vertical)    {
  1218.                     if (((!(this.x>w.x1+Wall.width)) && (this.y+25>w.y1) && (this.y<w.y1+w.length)) && !(this.x<w.x1))
  1219.                         OK=false;
  1220.                 } else    {
  1221.                     if (((!(this.x>w.x1+w.length)) && (this.y+25>w.y1) && (this.y<w.y1+Wall.width)) && !(this.x<w.x1))
  1222.                         OK=false;
  1223.                 }
  1224.             }
  1225.             if (this.x<=0)    {
  1226.                 for (int i=0;i<Pacman.levelCustom.size();i++)    {
  1227.                     w=(Wall)Pacman.levelCustom.elementAt(i);
  1228.                     if ((w.x1==400) || (w.x1+w.length==425))    {
  1229.                         if (w.vertical)    {
  1230.                             if ((w.y1<this.y+25) && (w.y1+w.length>this.y))
  1231.                                 OK=false;
  1232.                         }
  1233.                         else    {
  1234.                             if ((w.y1<this.y+25) && (w.y1+Wall.width>this.y))
  1235.                                 OK=false;
  1236.                         }
  1237.                     }
  1238.                 }
  1239.             }
  1240.         }
  1241.         return OK;
  1242.     }
  1243.     public boolean checkDown()    {
  1244.         boolean OK=true;
  1245.         Wall w;
  1246.         if (Pacman.level==1)    {
  1247.             for (int i=0;i<Pacman.level1.size();i++)    {
  1248.                 w=(Wall)Pacman.level1.elementAt(i);
  1249.                 if (!w.vertical)    {
  1250.                     if (((!(this.y+25<w.y1)) && (this.x+25>w.x1) && (this.x<w.x1+w.length)) && !(this.y>w.y1))
  1251.                         OK=false;
  1252.                 } else    {
  1253.                     if (((!(this.y+25<w.y1)) && (this.x+25>w.x1) && (this.x<w.x1+Wall.width)) && !(this.y>w.y1))
  1254.                         OK=false;
  1255.                 }
  1256.             }
  1257.         }
  1258.         else if (Pacman.level==2)    {
  1259.             for (int i=0;i<Pacman.level2.size();i++)    {
  1260.                 w=(Wall)Pacman.level2.elementAt(i);
  1261.                 if (!w.vertical)    {
  1262.                     if (((!(this.y+25<w.y1)) && (this.x+25>w.x1) && (this.x<w.x1+w.length)) && !(this.y>w.y1))
  1263.                         OK=false;
  1264.                 } else    {
  1265.                     if (((!(this.y+25<w.y1)) && (this.x+25>w.x1) && (this.x<w.x1+Wall.width)) && !(this.y>w.y1))
  1266.                         OK=false;
  1267.                 }
  1268.             }
  1269.         }
  1270.         else if (Pacman.level==3)    {
  1271.             for (int i=0;i<Pacman.level3.size();i++)    {
  1272.                 w=(Wall)Pacman.level3.elementAt(i);
  1273.                 if (!w.vertical)    {
  1274.                     if (((!(this.y+25<w.y1)) && (this.x+25>w.x1) && (this.x<w.x1+w.length)) && !(this.y>w.y1))
  1275.                         OK=false;
  1276.                 } else    {
  1277.                     if (((!(this.y+25<w.y1)) && (this.x+25>w.x1) && (this.x<w.x1+Wall.width)) && !(this.y>w.y1))
  1278.                         OK=false;
  1279.                 }
  1280.             }
  1281.             if (this.y>=375)    {
  1282.                 for (int i=0;i<Pacman.level3.size();i++)    {
  1283.                     w=(Wall)Pacman.level3.elementAt(i);
  1284.                     if (w.y1==0)    {
  1285.                         if (w.vertical)    {
  1286.                             if ((this.x<w.x1+25) && (this.x+25>w.x1))
  1287.                                 OK=false;
  1288.                         }
  1289.                         else    {
  1290.                             if ((this.x<w.x1+w.length) && (this.x+25>w.x1))
  1291.                                 OK=false;
  1292.                         }
  1293.                     }
  1294.                 }
  1295.             }
  1296.         }
  1297.         else if (Pacman.level==4)    {
  1298.             for (int i=0;i<Pacman.levelCustom.size();i++)    {
  1299.                 w=(Wall)Pacman.levelCustom.elementAt(i);
  1300.                 if (!w.vertical)    {
  1301.                     if (((!(this.y+25<w.y1)) && (this.x+25>w.x1) && (this.x<w.x1+w.length)) && !(this.y>w.y1))
  1302.                         OK=false;
  1303.                 } else    {
  1304.                     if (((!(this.y+25<w.y1)) && (this.x+25>w.x1) && (this.x<w.x1+Wall.width)) && !(this.y>w.y1))
  1305.                         OK=false;
  1306.                 }
  1307.             }
  1308.             if (this.y>=375)    {
  1309.                 for (int i=0;i<Pacman.levelCustom.size();i++)    {
  1310.                     w=(Wall)Pacman.levelCustom.elementAt(i);
  1311.                     if (w.y1==0)    {
  1312.                         if (w.vertical)    {
  1313.                             if ((this.x<w.x1+25) && (this.x+25>w.x1))
  1314.                                 OK=false;
  1315.                         }
  1316.                         else    {
  1317.                             if ((this.x<w.x1+w.length) && (this.x+25>w.x1))
  1318.                                 OK=false;
  1319.                         }
  1320.                     }
  1321.                 }
  1322.             }
  1323.         }
  1324.         return OK;
  1325.     }
  1326. }
  1327. class Wall {
  1328.     static Color wallColor=Color.red;
  1329.     static boolean bricks=true;
  1330.     int x1, y1, length;
  1331.     boolean vertical;
  1332.     final static int width=25;
  1333.     Wall(int x1, int y1, int length, boolean vertical)    {
  1334.         this.x1=x1;
  1335.         this.y1=y1;
  1336.         this.length=length;
  1337.         this.vertical=vertical;
  1338.     }
  1339.     public void draw(Graphics g)    {
  1340.         g.setColor(wallColor);
  1341.         if (vertical)
  1342.             g.fillRect(this.x1, this.y1, width, length);
  1343.         else
  1344.             g.fillRect(this.x1, this.y1, length, width);
  1345.         g.setColor(Color.black);
  1346.         if (bricks)    {
  1347.     if (vertical)    {
  1348.     for (int i=0;i<this.length/25;i++)    {
  1349.         g.drawLine(this.x1,this.y1+25*i,this.x1,this.y1+6+25*i);
  1350.         g.drawLine(this.x1+12,this.y1+25*i,this.x1+12,this.y1+6+25*i);
  1351.         g.drawLine(this.x1+25,this.y1+25*i,this.x1+25,this.y1+6+25*i);
  1352.         g.drawLine(this.x1+6,this.y1+6+25*i,this.x1+6,this.y1+12+25*i);
  1353.         g.drawLine(this.x1+19,this.y1+6+25*i,this.x1+19,this.y1+12+25*i);
  1354.         g.drawLine(this.x1,this.y1+12+25*i,this.x1,this.y1+19+25*i);
  1355.         g.drawLine(this.x1+12,this.y1+12+25*i,this.x1+12,this.y1+19+25*i);
  1356.         g.drawLine(this.x1+25,this.y1+12+25*i,this.x1+25,this.y1+19+25*i);
  1357.         g.drawLine(this.x1+6,this.y1+19+25*i,this.x1+6,this.y1+25+25*i);
  1358.         g.drawLine(this.x1+19,this.y1+19+25*i,this.x1+19,this.y1+25+25*i);
  1359.         
  1360.         g.drawLine(this.x1,this.y1+25*i,this.x1+25,this.y1+25*i);
  1361.         g.drawLine(this.x1,this.y1+6+25*i,this.x1+25,this.y1+6+25*i);
  1362.         g.drawLine(this.x1,this.y1+12+25*i,this.x1+25,this.y1+12+25*i);
  1363.         g.drawLine(this.x1,this.y1+19+25*i,this.x1+25,this.y1+19+25*i);
  1364.         g.drawLine(this.x1,this.y1+25+25*i,this.x1+25,this.y1+25+25*i);
  1365.     }
  1366.     }
  1367.     else    {
  1368.     for (int i=0;i<this.length/25;i++)    {
  1369.         g.drawLine(this.x1+25*i,this.y1,this.x1+25*i,this.y1+6);
  1370.         g.drawLine(this.x1+12+25*i,this.y1,this.x1+12+25*i,this.y1+6);
  1371.         g.drawLine(this.x1+25+25*i,this.y1,this.x1+25+25*i,this.y1+6);
  1372.         g.drawLine(this.x1+6+25*i,this.y1+6,this.x1+6+25*i,this.y1+12);
  1373.         g.drawLine(this.x1+19+25*i,this.y1+6,this.x1+19+25*i,this.y1+12);
  1374.         g.drawLine(this.x1+25*i,this.y1+12,this.x1+25*i,this.y1+19);
  1375.         g.drawLine(this.x1+12+25*i,this.y1+12,this.x1+12+25*i,this.y1+19);
  1376.         g.drawLine(this.x1+25+25*i,this.y1+12,this.x1+25+25*i,this.y1+19);
  1377.         g.drawLine(this.x1+6+25*i,this.y1+19,this.x1+6+25*i,this.y1+25);
  1378.         g.drawLine(this.x1+19+25*i,this.y1+19,this.x1+19+25*i,this.y1+25);
  1379.         
  1380.         g.drawLine(this.x1+25*i,this.y1,this.x1+25+25*i,this.y1);
  1381.         g.drawLine(this.x1+25*i,this.y1+6,this.x1+25+25*i,this.y1+6);
  1382.         g.drawLine(this.x1+25*i,this.y1+12,this.x1+25+25*i,this.y1+12);
  1383.         g.drawLine(this.x1+25*i,this.y1+19,this.x1+25+25*i,this.y1+19);
  1384.         g.drawLine(this.x1+25*i,this.y1+25,this.x1+25+25*i,this.y1+25);
  1385.     }
  1386.     }
  1387.         }
  1388.     }
  1389. }
  1390. class setPanel extends Panel    {
  1391.     Dimension myDimension=new Dimension(425,58);
  1392.     setPanel(int width, int height)    {
  1393.         myDimension.width=width;
  1394.         myDimension.height=height;
  1395.     }
  1396.     public Dimension getPreferredSize()    {
  1397.         return myDimension;
  1398.     }
  1399.     public Dimension getMinimumSize()    {
  1400.         return myDimension;
  1401.     }
  1402. }