home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 64 / CDPRO64.iso / JUEGOS / java / airforcex / airforcex.jar / AFAnimationCanvas.class (.txt) < prev    next >
Encoding:
Java Class File  |  2003-07-29  |  13.8 KB  |  803 lines

  1. import java.util.Random;
  2. import java.util.Timer;
  3. import javax.microedition.lcdui.Canvas;
  4. import javax.microedition.lcdui.Command;
  5. import javax.microedition.lcdui.CommandListener;
  6. import javax.microedition.lcdui.Displayable;
  7. import javax.microedition.lcdui.Font;
  8. import javax.microedition.lcdui.Graphics;
  9. import javax.microedition.lcdui.Image;
  10.  
  11. public class AFAnimationCanvas extends Canvas implements CommandListener {
  12.    private Random random;
  13.    private AirForceX midlet;
  14.    private Command cmClose;
  15.    Image bck = null;
  16.    Image points = null;
  17.    Image gameover = null;
  18.    Image life = null;
  19.    Image upperBar = null;
  20.    Image lowerBar = null;
  21.    Image blackout = null;
  22.    Image levelComplete = null;
  23.    Image ex1 = null;
  24.    Image ex2 = null;
  25.    Image ex3 = null;
  26.    Image ex4 = null;
  27.    Image ex5 = null;
  28.    Image user = null;
  29.    Image userLeft = null;
  30.    Image userRight = null;
  31.    Image userUp = null;
  32.    Image userDown = null;
  33.    Image userNorm = null;
  34.    Image town = null;
  35.    Image aim = null;
  36.    Image fire1 = null;
  37.    Image fire2 = null;
  38.    Image fire = null;
  39.    Image enemy1 = null;
  40.    Image enemyLarge = null;
  41.    Image enemyMediumLarge = null;
  42.    Image enemyMediumSmall = null;
  43.    Image enemySmallest = null;
  44.    Image enemy1Left = null;
  45.    Image enemy1Right = null;
  46.    Image clockImage = null;
  47.    Image enemyImage = null;
  48.    // $FF: renamed from: tm java.util.Timer
  49.    private Timer field_0;
  50.    private Timer m_scheduler;
  51.    // $FF: renamed from: tt AFAnimateTimerTask
  52.    private AFAnimateTimerTask field_1;
  53.    private int width;
  54.    private int height;
  55.    int keyTest;
  56.    private int heightDiff;
  57.    private int widthDiff;
  58.    int upperY;
  59.    int lowerY;
  60.    int rightX;
  61.    int leftX;
  62.    int bckgrndX;
  63.    int bckgrndY;
  64.    int actualSizeX;
  65.    int actualSizeY;
  66.    int startClipX = 0;
  67.    int xSize = 0;
  68.    int startClipY = 0;
  69.    int ySize = 0;
  70.    Font theFont;
  71.    int theLife;
  72.    String stringTheLife;
  73.    int scorePosX;
  74.    int scorePosY;
  75.    int heartX;
  76.    int heartY;
  77.    int pointsX;
  78.    int pointsY;
  79.    int theScore;
  80.    String stringTheScore;
  81.    boolean changeDisplay = false;
  82.    int userX;
  83.    int userY;
  84.    int gameOverX;
  85.    int gameOverY;
  86.    boolean gameOver = false;
  87.    int val1;
  88.    int val2;
  89.    int val3;
  90.    int val4;
  91.    int val5;
  92.    int val6;
  93.    int val7;
  94.    int val8;
  95.    int val9;
  96.    int val10;
  97.    int val11;
  98.    int val12;
  99.    int val13;
  100.    int val14;
  101.    int val15;
  102.    int val16;
  103.    int val17;
  104.    int val18;
  105.    int val19;
  106.    int val20;
  107.    int lifeBarImageX;
  108.    int lifeBarImageY;
  109.    int movingLifeBarImageX;
  110.    int townX;
  111.    int townY;
  112.    int town2X;
  113.    int aimX;
  114.    int aimY;
  115.    int counterY;
  116.    int counterX;
  117.    boolean moveAim = false;
  118.    int fireX;
  119.    int fireY;
  120.    int fireCycleImage;
  121.    boolean userFired = false;
  122.    boolean displayEnemy1 = false;
  123.    boolean resetEnemy1 = true;
  124.    int enemy1X;
  125.    int enemy1Y;
  126.    int enemy1Size;
  127.    int enemy1Dir;
  128.    boolean en1MoveAircraft = false;
  129.    int en1MoveCounter;
  130.    int en1MoveCounterLimit;
  131.    boolean en1OutBoundary = false;
  132.    int en1DelayCounter;
  133.    int en1DelayCounterLimit;
  134.    boolean en1NearLeft = false;
  135.    boolean en1NearRight = false;
  136.    boolean en1NearUpper = false;
  137.    boolean en1NearLower = false;
  138.    boolean displayEn1Explosion = false;
  139.    int en1ExCycle;
  140.    int en1ExX;
  141.    int en1ExY;
  142.    int proxX;
  143.    int proxY;
  144.    int en1SizeCounter;
  145.    int en1SizeCounterLimit;
  146.    int enemyDestroyed;
  147.    String enemyDestroyedString;
  148.    int enemyDestroyedStringX;
  149.    int levelLimit;
  150.    boolean displayLevelComplete = false;
  151.    int displayLevelCompleteCounter;
  152.    boolean resetLevel = false;
  153.    int clockImageX;
  154.    int clockImageY;
  155.    int enemyImageX;
  156.    int enemyImageY;
  157.    int timerCounter;
  158.    int timeCounterSecs;
  159.    String levelTimeString;
  160.    int levelTimeStringX;
  161.    int levelTime;
  162.  
  163.    public AFAnimationCanvas(AirForceX var1) {
  164.       this.midlet = var1;
  165.       this.width = ((Canvas)this).getWidth();
  166.       this.height = ((Canvas)this).getHeight();
  167.       this.random = new Random();
  168.       this.cmClose = new Command("Close", 1, 1);
  169.       ((Displayable)this).addCommand(this.cmClose);
  170.       ((Displayable)this).setCommandListener(this);
  171.       this.initialiseItems();
  172.       this.field_0 = new Timer();
  173.       this.field_1 = new AFAnimateTimerTask(this);
  174.       this.field_0.schedule(this.field_1, 0L, 100L);
  175.    }
  176.  
  177.    protected void showNotify() {
  178.       this.theFont = Font.getFont(0, 0, 8);
  179.       if (this.height < 110) {
  180.          this.heightDiff = 110 - this.height;
  181.          this.heightDiff /= 2;
  182.       } else {
  183.          this.heightDiff = 0;
  184.       }
  185.  
  186.       if (this.width < 110) {
  187.          this.widthDiff = 110 - this.width;
  188.          this.widthDiff /= 2;
  189.       } else {
  190.          this.widthDiff = 0;
  191.       }
  192.  
  193.       this.actualSizeX = (this.width - 110) / 2;
  194.       this.startClipX = 0 + this.actualSizeX;
  195.       this.xSize = this.width - this.actualSizeX * 2;
  196.       this.actualSizeY = (this.height - 110) / 2;
  197.       this.startClipY = 0 + this.actualSizeY;
  198.       this.ySize = this.height - this.actualSizeY * 2;
  199.       this.upperY = this.startClipY;
  200.       this.lowerY = this.startClipY + this.ySize;
  201.       this.leftX = this.startClipX;
  202.       this.rightX = this.startClipX + this.xSize;
  203.       this.bckgrndX = this.width / 2 + this.widthDiff;
  204.       this.bckgrndY = this.height / 2 - this.heightDiff;
  205.       this.scorePosY = this.upperY + 0 + this.heightDiff;
  206.       this.scorePosX = this.leftX + (80 - this.widthDiff);
  207.       this.pointsX = this.leftX + (95 - this.widthDiff);
  208.       this.pointsY = this.upperY + 5 + this.heightDiff;
  209.       this.gameOverX = this.width / 2;
  210.       this.gameOverY = this.height / 2;
  211.       this.stringTheScore = "0";
  212.       this.theScore = 0;
  213.       this.theLife = 4;
  214.       this.stringTheLife = "4";
  215.       this.userX = this.width / 2;
  216.       this.userY = this.lowerY - (20 + this.heightDiff);
  217.       this.lifeBarImageX = this.leftX + 13 + this.widthDiff;
  218.       this.lifeBarImageY = this.upperY + 5 + this.heightDiff;
  219.       this.movingLifeBarImageX = this.leftX + 13 + this.widthDiff;
  220.       this.townX = this.leftX + 0 + this.widthDiff;
  221.       this.town2X = this.leftX + 110 + this.widthDiff;
  222.       this.townY = this.lowerY - (20 + this.heightDiff);
  223.       this.aimX = this.width / 2;
  224.       this.aimY = this.userY - 35;
  225.       this.counterX = 0;
  226.       this.counterY = 0;
  227.       this.fireX = this.width / 2;
  228.       this.fireY = this.userY - 15;
  229.       this.enemy1Size = 0;
  230.       this.enemy1Dir = 0;
  231.       this.val1 = this.leftX + 10 + this.widthDiff;
  232.       this.val2 = this.upperY - (40 + this.heightDiff);
  233.       this.en1MoveCounter = 0;
  234.       this.en1MoveCounterLimit = 20;
  235.       this.val3 = this.leftX + 10 + this.widthDiff;
  236.       this.val4 = this.rightX - (10 + this.widthDiff);
  237.       this.val5 = this.upperY - (40 + this.heightDiff);
  238.       this.val6 = this.lowerY - (60 + this.heightDiff);
  239.       this.en1DelayCounter = 0;
  240.       this.en1DelayCounterLimit = 10;
  241.       this.en1SizeCounter = 0;
  242.       this.en1SizeCounterLimit = 30;
  243.       this.en1ExCycle = 0;
  244.       this.val7 = 0;
  245.       this.val8 = 0;
  246.       this.enemyDestroyed = 10;
  247.       this.enemyDestroyedString = "10";
  248.       this.enemyDestroyedStringX = this.leftX + 50 + this.widthDiff;
  249.       this.levelLimit = 10;
  250.       this.clockImageX = this.leftX + 10 + this.widthDiff;
  251.       this.clockImageY = this.upperY + 5 + this.heightDiff;
  252.       this.enemyImageX = this.leftX + 40 + this.widthDiff;
  253.       this.enemyImageY = this.upperY + 7 + this.heightDiff;
  254.       this.timerCounter = 0;
  255.       this.levelTimeString = "60";
  256.       this.levelTime = 60;
  257.       this.timeCounterSecs = this.levelTime;
  258.       this.levelTimeStringX = this.leftX + 20 + this.widthDiff;
  259.    }
  260.  
  261.    public void initialiseItems() {
  262.       try {
  263.          this.bck = Image.createImage("/sky.png");
  264.          this.gameover = Image.createImage("/gameover.png");
  265.          this.levelComplete = Image.createImage("/nextWave.png");
  266.          this.ex1 = Image.createImage("/ex1.png");
  267.          this.ex2 = Image.createImage("/ex2.png");
  268.          this.ex3 = Image.createImage("/ex3.png");
  269.          this.ex4 = Image.createImage("/ex4.png");
  270.          this.ex5 = Image.createImage("/ex5.png");
  271.          this.userLeft = Image.createImage("/userPlaneLeftB.png");
  272.          this.userRight = Image.createImage("/userPlaneRightB.png");
  273.          this.userUp = Image.createImage("/userPlaneUpB.png");
  274.          this.userDown = Image.createImage("/userPlaneDownB.png");
  275.          this.userNorm = Image.createImage("/userPlane1B.png");
  276.          this.town = Image.createImage("/town.png");
  277.          this.aim = Image.createImage("/aim2.png");
  278.          this.fire1 = Image.createImage("/bullet1.png");
  279.          this.fire2 = Image.createImage("/bullet2.png");
  280.          this.enemyLarge = Image.createImage("/bomber1.png");
  281.          this.enemyMediumLarge = Image.createImage("/bomber2.png");
  282.          this.enemyMediumSmall = Image.createImage("/bomber3.png");
  283.          this.enemySmallest = Image.createImage("/bomber4.png");
  284.          this.enemy1Left = Image.createImage("/bomberLeft.png");
  285.          this.enemy1Right = Image.createImage("/bomberRight.png");
  286.          this.clockImage = Image.createImage("/clock.png");
  287.          this.enemyImage = Image.createImage("/planeIcon.png");
  288.       } catch (Exception var2) {
  289.          System.out.println("error with image load: " + var2);
  290.       }
  291.  
  292.       this.user = this.userNorm;
  293.       this.enemy1 = this.enemySmallest;
  294.    }
  295.  
  296.    public void paint(Graphics var1) {
  297.       var1.setColor(0, 0, 0);
  298.       var1.fillRect(0, 0, this.width, this.height);
  299.       var1.setClip(this.startClipX, this.startClipY, this.xSize, this.ySize);
  300.       var1.drawImage(this.bck, this.bckgrndX, this.bckgrndY, 3);
  301.       var1.drawImage(this.town, this.townX, this.townY, 3);
  302.       var1.drawImage(this.town, this.town2X, this.townY, 3);
  303.       if (this.theLife <= 0) {
  304.          this.gameOver = true;
  305.          this.gameOver();
  306.       }
  307.  
  308.       if (this.enemyDestroyed <= 0) {
  309.          this.displayEnemy1 = false;
  310.          this.resetEnemy1 = false;
  311.          this.displayLevelComplete = true;
  312.          this.displayLevelCompleteCounter = 0;
  313.          this.levelLimit += 5;
  314.          this.enemyDestroyed = this.levelLimit;
  315.          this.theScore += 100;
  316.          this.levelTime += 30;
  317.          this.timeCounterSecs = this.levelTime;
  318.          this.changeDisplay = true;
  319.          this.timerCounter = 0;
  320.          if (this.en1DelayCounterLimit > 1) {
  321.             this.en1DelayCounterLimit -= 2;
  322.          }
  323.       }
  324.  
  325.       if (this.resetLevel) {
  326.          this.resetLevel = false;
  327.          this.resetEnemy1 = true;
  328.          this.changeDisplay = true;
  329.       }
  330.  
  331.       if (this.timerCounter >= 10) {
  332.          this.timerCounter = 0;
  333.          --this.timeCounterSecs;
  334.          this.changeDisplay = true;
  335.       } else {
  336.          ++this.timerCounter;
  337.       }
  338.  
  339.       if (this.timeCounterSecs <= 0) {
  340.          this.gameOver = true;
  341.          this.gameOver();
  342.       }
  343.  
  344.       if (this.resetEnemy1) {
  345.          this.resetEnemy1 = false;
  346.          this.displayEnemy1 = true;
  347.          this.enemy1X = (this.random.nextInt() >>> 1) % 10 * 10 + this.val1;
  348.          this.enemy1Y = (this.random.nextInt() >>> 1) % 10 * 10 + this.val2;
  349.          this.enemy1Size = 1;
  350.          this.en1NearLeft = false;
  351.          this.en1NearRight = false;
  352.          this.en1NearUpper = false;
  353.          this.en1NearLower = false;
  354.          this.en1OutBoundary = false;
  355.          this.en1MoveAircraft = false;
  356.          this.enemy1Size = 1;
  357.          this.enemy1 = this.enemySmallest;
  358.       }
  359.  
  360.       if (this.displayEnemy1) {
  361.          if (!this.en1MoveAircraft) {
  362.             if (this.en1DelayCounter >= this.en1DelayCounterLimit) {
  363.                if (this.en1OutBoundary) {
  364.                   if (this.en1NearLeft) {
  365.                      this.enemy1Dir = 3;
  366.                      this.enemy1X += 3;
  367.                      this.enemy1Y += 3;
  368.                   } else if (this.en1NearRight) {
  369.                      this.enemy1Dir = 5;
  370.                      this.enemy1X -= 3;
  371.                      this.enemy1Y += 3;
  372.                   } else if (this.en1NearUpper) {
  373.                      this.enemy1Dir = 4;
  374.                      this.enemy1Y += 3;
  375.                   } else if (this.en1NearLower) {
  376.                      this.enemy1Dir = 0;
  377.                      this.enemy1Y -= 3;
  378.                   }
  379.  
  380.                   this.en1NearLeft = false;
  381.                   this.en1NearRight = false;
  382.                   this.en1NearUpper = false;
  383.                   this.en1NearLower = false;
  384.                   this.en1OutBoundary = false;
  385.                } else {
  386.                   this.enemy1Dir = (this.random.nextInt() >>> 1) % 8;
  387.                }
  388.  
  389.                this.en1MoveAircraft = true;
  390.                this.en1DelayCounter = 0;
  391.                this.en1MoveCounter = 0;
  392.             } else {
  393.                ++this.en1DelayCounter;
  394.             }
  395.          } else if (this.en1MoveAircraft) {
  396.             if (this.en1MoveCounter >= this.en1MoveCounterLimit) {
  397.                this.en1MoveAircraft = false;
  398.                this.en1MoveCounter = 0;
  399.             } else {
  400.                ++this.en1MoveCounter;
  401.                if (this.enemy1X <= this.val3) {
  402.                   this.en1OutBoundary = true;
  403.                   this.en1MoveAircraft = false;
  404.                   this.en1MoveCounter = 0;
  405.                   this.en1NearLeft = true;
  406.                } else if (this.enemy1X >= this.val4) {
  407.                   this.en1OutBoundary = true;
  408.                   this.en1MoveAircraft = false;
  409.                   this.en1MoveCounter = 0;
  410.                   this.en1NearRight = true;
  411.                } else if (this.enemy1Y <= this.val5) {
  412.                   this.en1OutBoundary = true;
  413.                   this.en1MoveAircraft = false;
  414.                   this.en1MoveCounter = 0;
  415.                   this.en1NearUpper = true;
  416.                } else if (this.enemy1Y >= this.val6) {
  417.                   this.en1OutBoundary = true;
  418.                   this.en1MoveAircraft = false;
  419.                   this.en1MoveCounter = 0;
  420.                   this.en1NearLower = true;
  421.                }
  422.  
  423.                if (this.enemy1Size != 4) {
  424.                   if (this.en1SizeCounter >= this.en1SizeCounterLimit) {
  425.                      if (this.enemy1Size == 1) {
  426.                         this.enemy1Size = 2;
  427.                         this.enemy1 = this.enemyMediumSmall;
  428.                      } else if (this.enemy1Size == 2) {
  429.                         this.enemy1Size = 3;
  430.                         this.enemy1 = this.enemyMediumLarge;
  431.                      } else if (this.enemy1Size == 3) {
  432.                         this.enemy1Size = 4;
  433.                         this.enemy1 = this.enemyLarge;
  434.                      }
  435.  
  436.                      this.en1SizeCounter = 0;
  437.                   } else {
  438.                      ++this.en1SizeCounter;
  439.                   }
  440.                }
  441.  
  442.                if (this.enemy1Dir == 0) {
  443.                   if (this.enemy1Size == 4 & this.enemy1 != this.enemyLarge) {
  444.                      this.enemy1 = this.enemyLarge;
  445.                   }
  446.  
  447.                   if (this.enemy1Size != 1 && this.enemy1Size != 2) {
  448.                      if (this.enemy1Size == 3 || this.enemy1Size == 4) {
  449.                         this.enemy1Y -= 2;
  450.                      }
  451.                   } else {
  452.                      --this.enemy1Y;
  453.                   }
  454.                } else if (this.enemy1Dir == 1) {
  455.                   if (this.enemy1Size == 4 & this.enemy1 != this.enemyLarge) {
  456.                      this.enemy1 = this.enemyLarge;
  457.                   }
  458.  
  459.                   if (this.enemy1Size != 1 && this.enemy1Size != 2) {
  460.                      if (this.enemy1Size == 3 || this.enemy1Size == 4) {
  461.                         this.enemy1X += 2;
  462.                         this.enemy1Y -= 2;
  463.                      }
  464.                   } else {
  465.                      ++this.enemy1X;
  466.                      --this.enemy1Y;
  467.                   }
  468.                } else if (this.enemy1Dir == 2) {
  469.                   if (this.enemy1Size == 4 & this.enemy1 != this.enemy1Right) {
  470.                      this.enemy1 = this.enemy1Right;
  471.                   }
  472.  
  473.                   if (this.enemy1Size != 1 && this.enemy1Size != 2) {
  474.                      if (this.enemy1Size == 3 || this.enemy1Size == 4) {
  475.                         this.enemy1X += 2;
  476.                      }
  477.                   } else {
  478.                      ++this.enemy1X;
  479.                   }
  480.                } else if (this.enemy1Dir == 3) {
  481.                   if (this.enemy1Size == 4 & this.enemy1 != this.enemyLarge) {
  482.                      this.enemy1 = this.enemyLarge;
  483.                   }
  484.  
  485.                   if (this.enemy1Size != 1 && this.enemy1Size != 2) {
  486.                      if (this.enemy1Size == 3 || this.enemy1Size == 4) {
  487.                         this.enemy1X += 2;
  488.                         this.enemy1Y += 2;
  489.                      }
  490.                   } else {
  491.                      ++this.enemy1X;
  492.                      ++this.enemy1Y;
  493.                   }
  494.                } else if (this.enemy1Dir == 4) {
  495.                   if (this.enemy1Size == 4 & this.enemy1 != this.enemyLarge) {
  496.                      this.enemy1 = this.enemyLarge;
  497.                   }
  498.  
  499.                   if (this.enemy1Size != 1 && this.enemy1Size != 2) {
  500.                      if (this.enemy1Size == 3 || this.enemy1Size == 4) {
  501.                         this.enemy1Y += 2;
  502.                      }
  503.                   } else {
  504.                      ++this.enemy1Y;
  505.                   }
  506.                } else if (this.enemy1Dir == 5) {
  507.                   if (this.enemy1Size == 4 & this.enemy1 != this.enemyLarge) {
  508.                      this.enemy1 = this.enemyLarge;
  509.                   }
  510.  
  511.                   if (this.enemy1Size != 1 && this.enemy1Size != 2) {
  512.                      if (this.enemy1Size == 3 || this.enemy1Size == 4) {
  513.                         this.enemy1X -= 2;
  514.                         this.enemy1Y += 2;
  515.                      }
  516.                   } else {
  517.                      --this.enemy1X;
  518.                      ++this.enemy1Y;
  519.                   }
  520.                } else if (this.enemy1Dir == 6) {
  521.                   if (this.enemy1Size == 4 & this.enemy1 != this.enemy1Left) {
  522.                      this.enemy1 = this.enemy1Left;
  523.                   }
  524.  
  525.                   if (this.enemy1Size != 1 && this.enemy1Size != 2) {
  526.                      if (this.enemy1Size == 3 || this.enemy1Size == 4) {
  527.                         this.enemy1X -= 2;
  528.                      }
  529.                   } else {
  530.                      --this.enemy1X;
  531.                   }
  532.                } else if (this.enemy1Dir == 7) {
  533.                   if (this.enemy1Size == 4 & this.enemy1 != this.enemyLarge) {
  534.                      this.enemy1 = this.enemyLarge;
  535.                   }
  536.  
  537.                   if (this.enemy1Size != 1 && this.enemy1Size != 2) {
  538.                      if (this.enemy1Size == 3 || this.enemy1Size == 4) {
  539.                         this.enemy1X -= 2;
  540.                         this.enemy1Y -= 2;
  541.                      }
  542.                   } else {
  543.                      --this.enemy1X;
  544.                      --this.enemy1Y;
  545.                   }
  546.                }
  547.             }
  548.          }
  549.       }
  550.  
  551.       if (this.userFired) {
  552.          if (this.fireCycleImage == 0) {
  553.             this.fireCycleImage = 1;
  554.             this.fire = this.fire1;
  555.             if (!this.displayEn1Explosion) {
  556.                this.proxX = Math.abs(this.aimX - this.enemy1X);
  557.                this.proxY = Math.abs(this.aimY - this.enemy1Y);
  558.                if (this.enemy1Size != 1 && this.enemy1Size != 2) {
  559.                   if (this.enemy1Size == 3 || this.enemy1Size == 4) {
  560.                      this.val7 = 12;
  561.                      this.val8 = 6;
  562.                   }
  563.                } else {
  564.                   this.val7 = 8;
  565.                   this.val8 = 3;
  566.                }
  567.  
  568.                if (this.proxX <= this.val7 & this.proxY <= this.val8) {
  569.                   this.resetEnemy1 = true;
  570.                   this.displayEnemy1 = false;
  571.                   this.en1ExX = this.enemy1X;
  572.                   this.en1ExY = this.enemy1Y;
  573.                   this.en1ExCycle = 0;
  574.                   this.displayEn1Explosion = true;
  575.                   this.theScore += 20;
  576.                   this.changeDisplay = true;
  577.                   --this.enemyDestroyed;
  578.                }
  579.             }
  580.          } else if (this.fireCycleImage == 1) {
  581.             this.fireCycleImage = 0;
  582.             this.fire = this.fire2;
  583.          }
  584.       }
  585.  
  586.       if (this.displayEnemy1) {
  587.          var1.drawImage(this.enemy1, this.enemy1X, this.enemy1Y, 3);
  588.       }
  589.  
  590.       if (this.displayEn1Explosion) {
  591.          if (this.en1ExCycle == 0) {
  592.             var1.drawImage(this.ex1, this.en1ExX, this.en1ExY, 3);
  593.             ++this.en1ExCycle;
  594.          } else if (this.en1ExCycle == 1) {
  595.             var1.drawImage(this.ex2, this.en1ExX, this.en1ExY, 3);
  596.             ++this.en1ExCycle;
  597.          } else if (this.en1ExCycle == 2) {
  598.             var1.drawImage(this.ex3, this.en1ExX, this.en1ExY, 3);
  599.             ++this.en1ExCycle;
  600.          } else if (this.en1ExCycle == 3) {
  601.             var1.drawImage(this.ex4, this.en1ExX, this.en1ExY, 3);
  602.             ++this.en1ExCycle;
  603.          } else if (this.en1ExCycle == 4) {
  604.             var1.drawImage(this.ex5, this.en1ExX, this.en1ExY, 3);
  605.             this.en1ExCycle = 0;
  606.             this.displayEn1Explosion = false;
  607.          }
  608.       }
  609.  
  610.       if (this.userFired) {
  611.          var1.drawImage(this.fire, this.fireX, this.fireY, 3);
  612.       }
  613.  
  614.       var1.drawImage(this.user, this.userX, this.userY, 3);
  615.       var1.drawImage(this.aim, this.aimX, this.aimY, 3);
  616.       if (this.displayLevelComplete) {
  617.          if (this.displayLevelCompleteCounter >= 10) {
  618.             this.displayLevelCompleteCounter = 0;
  619.             this.displayLevelComplete = false;
  620.             this.resetLevel = true;
  621.          } else {
  622.             ++this.displayLevelCompleteCounter;
  623.          }
  624.  
  625.          var1.drawImage(this.levelComplete, this.gameOverX, this.gameOverY, 3);
  626.       }
  627.  
  628.       if (this.changeDisplay) {
  629.          this.stringTheScore = Integer.toString(this.theScore);
  630.          this.stringTheLife = Integer.toString(this.theLife);
  631.          this.enemyDestroyedString = Integer.toString(this.enemyDestroyed);
  632.          this.levelTimeString = Integer.toString(this.timeCounterSecs);
  633.          this.changeDisplay = false;
  634.       }
  635.  
  636.       var1.setColor(0, 0, 0);
  637.       var1.setFont(this.theFont);
  638.       var1.drawString(this.stringTheScore, this.scorePosX, this.scorePosY, 20);
  639.       var1.drawString(this.enemyDestroyedString, this.enemyDestroyedStringX, this.scorePosY, 20);
  640.       var1.drawString(this.levelTimeString, this.levelTimeStringX, this.scorePosY, 20);
  641.       var1.drawImage(this.enemyImage, this.enemyImageX, this.enemyImageY, 3);
  642.       var1.drawImage(this.clockImage, this.clockImageX, this.clockImageY, 3);
  643.       if (this.gameOver) {
  644.          var1.drawImage(this.gameover, this.gameOverX, this.gameOverY, 3);
  645.       }
  646.  
  647.    }
  648.  
  649.    public void gameOver() {
  650.       this.field_1.cancel();
  651.       this.field_0.cancel();
  652.       this.field_0 = new Timer();
  653.       this.field_1 = new AFAnimateTimerTask(this);
  654.       this.field_0.schedule(this.field_1, 100000L);
  655.    }
  656.  
  657.    public void reStartSA() {
  658.       this.field_0 = new Timer();
  659.       this.field_1 = new AFAnimateTimerTask(this);
  660.       this.field_0.schedule(this.field_1, 0L, 100L);
  661.       this.changeDisplay = false;
  662.       this.gameOver = false;
  663.       this.moveAim = false;
  664.       this.userFired = false;
  665.       this.displayEnemy1 = false;
  666.       this.resetEnemy1 = true;
  667.       this.en1MoveAircraft = false;
  668.       this.en1OutBoundary = false;
  669.       this.en1NearLeft = false;
  670.       this.en1NearRight = false;
  671.       this.en1NearUpper = false;
  672.       this.en1NearLower = false;
  673.       this.displayEn1Explosion = false;
  674.       this.displayLevelComplete = false;
  675.       this.resetLevel = false;
  676.       this.user = this.userNorm;
  677.       this.enemy1 = this.enemySmallest;
  678.    }
  679.  
  680.    protected void hideNotify() {
  681.    }
  682.  
  683.    public void commandAction(Command var1, Displayable var2) {
  684.       if (var1 == this.cmClose) {
  685.          this.field_1.cancel();
  686.          this.field_0.cancel();
  687.          this.hideNotify();
  688.          this.midlet.RRScore(this.theScore);
  689.          this.midlet.RMSScore();
  690.       }
  691.  
  692.    }
  693.  
  694.    protected void keyRepeated(int var1) {
  695.       if (((Canvas)this).hasRepeatEvents()) {
  696.          this.field_1.repeatKey = true;
  697.          this.field_1.m_gameAction = var1;
  698.       }
  699.  
  700.    }
  701.  
  702.    protected void keyPressed(int var1) {
  703.       this.keyTest = ((Canvas)this).getGameAction(var1);
  704.       switch (this.keyTest) {
  705.          case 1:
  706.             if (this.counterY <= 20) {
  707.                if (this.user != this.userUp) {
  708.                   this.user = this.userUp;
  709.                }
  710.  
  711.                if (this.displayEnemy1) {
  712.                   this.enemy1Y += 5;
  713.                }
  714.  
  715.                this.townY += 5;
  716.                this.val2 += 5;
  717.                this.val5 += 5;
  718.                this.val6 += 5;
  719.                ++this.counterY;
  720.             }
  721.             break;
  722.          case 2:
  723.             if (this.counterX >= -10) {
  724.                if (this.user != this.userLeft) {
  725.                   this.user = this.userLeft;
  726.                }
  727.  
  728.                if (this.displayEnemy1) {
  729.                   this.enemy1X += 5;
  730.                }
  731.  
  732.                this.townX += 5;
  733.                this.town2X += 5;
  734.                this.val1 += 5;
  735.                this.val3 += 5;
  736.                this.val4 += 5;
  737.                --this.counterX;
  738.             }
  739.          case 3:
  740.          case 4:
  741.          case 7:
  742.          case 9:
  743.          default:
  744.             break;
  745.          case 5:
  746.             if (this.counterX <= 10) {
  747.                if (this.user != this.userRight) {
  748.                   this.user = this.userRight;
  749.                }
  750.  
  751.                if (this.displayEnemy1) {
  752.                   this.enemy1X -= 5;
  753.                }
  754.  
  755.                this.townX -= 5;
  756.                this.town2X -= 5;
  757.                this.val1 -= 5;
  758.                this.val3 -= 5;
  759.                this.val4 -= 5;
  760.                ++this.counterX;
  761.             }
  762.             break;
  763.          case 6:
  764.             if (this.counterY > 0) {
  765.                if (this.user != this.userDown) {
  766.                   this.user = this.userDown;
  767.                }
  768.  
  769.                if (this.displayEnemy1) {
  770.                   this.enemy1Y -= 5;
  771.                }
  772.  
  773.                this.townY -= 5;
  774.                this.val2 -= 5;
  775.                this.val5 -= 5;
  776.                this.val6 -= 5;
  777.                --this.counterY;
  778.             }
  779.             break;
  780.          case 8:
  781.             if (!this.userFired) {
  782.                this.userFired = true;
  783.                this.fireCycleImage = 0;
  784.             }
  785.       }
  786.  
  787.       this.field_1.repeatKey = true;
  788.       this.field_1.m_gameAction = var1;
  789.    }
  790.  
  791.    protected void keyReleased(int var1) {
  792.       this.field_1.repeatKey = false;
  793.       if (this.user != this.userNorm) {
  794.          this.user = this.userNorm;
  795.       }
  796.  
  797.       if (this.userFired) {
  798.          this.userFired = false;
  799.       }
  800.  
  801.    }
  802. }
  803.