Example #1
0
  @Override
  public void update() {
    // STEPS
    xt = x;
    yt = y;
    z = yt + 16;
    if (MinusTimer <= 0 && Minus == 1) {
      if (GameOtherVars.Health == 1) {
        Atack = 1;
      } else {
        GameOtherVars.Health--;
        MinusTimer = 30;
        Minus = 0;
      }

    } else {
      MinusTimer--;
    }
    if (xt >= 500 || x >= 500) {
      MST = 4;
    }
    if (xt <= 90 || x <= 90) {
      MST = 2;
    }
    if (yt >= 500 || y >= 500) {
      MST = 1;
    }
    if (yt <= 90 || y <= 90) {
      MST = 3;
    }

    for (int i = 0; i < 120; i++) {
      if (plx == xt && ply == yt - i) {
        MST = 1;
      } else {
        if (plx == xt && ply == yt + i) {
          MST = 3;
        } else {
          if (ply == yt && plx == xt - i) {
            MST = 4;
          } else {
            if (ply == yt && plx == xt + i) {
              MST = 2;
            }
          }
        }
      }
    }

    if (Atack == 1) {

      Timer_sec = 1;
      GameOtherVars.VisibleDieLogo = 1;

      if (Timer_sec == 1) {

        if (Timer_3 <= 0) {
          Atack = 0;
          Timer_sec = 0;
          Timer_3 = 5;
          GameOtherVars.VisibleDieLogo = 0;
          Game.Get_Die();

        } else {
          Timer_3--;
        }
      }
    }

    // STEPS END

    if (Timer <= 0) {
      MST = 0 + (int) (Math.random() * ((4 - 0) + 1));
      Timer_set_del = 0;
    } else {
      Timer--;
    }
    if (MST == 0) {
      if (Timer_set_del == 0) {
        Timer = 20 + (int) (Math.random() * ((80 - 20) + 1));
        Timer_set_del = 1;
      }
      // y-=3;
      // yt-=3;
      // sprite.currentStep = 0;
    }
    if (MST == 1) {
      if (Timer_set_del == 0) {
        Timer = 20 + (int) (Math.random() * ((80 - 20) + 1));
        Timer_set_del = 1;
      }

      // yt-=3;
      y -= 1;
      z += 1;
      sprite.currentStep = 1;
    }
    if (MST == 2) {
      if (Timer_set_del == 0) {
        Timer = 20 + (int) (Math.random() * ((80 - 20) + 1));
        Timer_set_del = 1;
      }

      // xt+=3;
      x += 1;
      sprite.currentStep = 2;
    }
    if (MST == 3) {
      if (Timer_set_del == 0) {
        Timer = 20 + (int) (Math.random() * ((80 - 20) + 1));
        Timer_set_del = 1;
      }

      // yt+=3;
      y += 1;
      z -= 1;
      sprite.currentStep = 3;
    }
    if (MST == 4) {
      if (Timer_set_del == 0) {
        Timer = 20 + (int) (Math.random() * ((80 - 20) + 1));
        Timer_set_del = 1;
      }

      // xt-=3;
      x -= 1;
      sprite.currentStep = 0;
    }

    // Collision :

    if (Timer_2 <= 0) {

      Timer_2 = 0;
    } else {
      Timer_2--;
    }
    if (otchet == myx.length) {
      otchet = 0;
    }
    if (otchet3 == myx.length) {
      otchet3 = 0;
    }
    if (otchet5 == myx.length) {
      otchet5 = 0;
    }
    if (otchet2 == myy.length) {
      otchet2 = 0;
    }
    if (otchet4 == myy.length) {
      otchet4 = 0;
    }
    if (otchet6 == myy.length) {
      otchet6 = 0;
    }
    if (otchet7 == myx.length) {
      otchet7 = 0;
    }
    if (otchet8 == myy.length) {
      otchet8 = 0;
    }

    if (xt - myx[otchet] == plx1
        || xt + myx[otchet] == plx1
        || xt - myx[otchet5] == plx1
        || xt + myx[otchet5] == plx1
        || xt - myx[otchet3] == plx1
        || xt + myx[otchet7] == plx1
        || xt - myx[otchet7] == plx1
        || xt + myx[otchet3] == plx1
        || xt - myx[otchet] == plx2
        || xt + myx[otchet] == plx2
        || xt - myx[otchet7] == plx2
        || xt + myx[otchet7] == plx2
        || xt - myx[otchet5] == plx2
        || xt + myx[otchet5] == plx2
        || xt - myx[otchet3] == plx2
        || xt + myx[otchet3] == plx2
        || xt - myx[otchet] == plx3
        || xt + myx[otchet] == plx3
        || xt - myx[otchet7] == plx3
        || xt + myx[otchet7] == plx3
        || xt - myx[otchet5] == plx3
        || xt + myx[otchet5] == plx3
        || xt - myx[otchet3] == plx3
        || xt + myx[otchet3] == plx3
        || xt - myx[otchet] == plx4
        || xt + myx[otchet] == plx4
        || xt - myx[otchet7] == plx4
        || xt + myx[otchet7] == plx4
        || xt - myx[otchet5] == plx4
        || xt + myx[otchet5] == plx4
        || xt - myx[otchet3] == plx4
        || xt + myx[otchet3] == plx4) {
      if (yt - myy[otchet2] == ply1
          || yt + myy[otchet2] == ply1
          || yt - myy[otchet7] == ply1
          || yt + myy[otchet7] == ply1
          || yt - myy[otchet6] == ply1
          || yt + myy[otchet6] == ply1
          || yt - myy[otchet4] == ply1
          || yt + myy[otchet4] == ply1
          || yt - myy[otchet6] == ply1
          || yt + myy[otchet6] == ply1
          || yt - myy[otchet7] == ply2
          || yt + myy[otchet7] == ply1
          || yt - myy[otchet2] == ply2
          || yt + myy[otchet2] == ply2
          || yt - myy[otchet6] == ply2
          || yt + myy[otchet6] == ply2
          || yt - myy[otchet4] == ply2
          || yt + myy[otchet4] == ply2
          || yt - myy[otchet2] == ply2
          || yt + myy[otchet2] == ply2
          || yt - myy[otchet4] == ply2
          || yt + myy[otchet4] == ply2
          || yt - myy[otchet2] == ply3
          || yt + myy[otchet2] == ply3
          || yt - myy[otchet7] == ply3
          || yt + myy[otchet7] == ply3
          || yt - myy[otchet6] == ply3
          || yt + myy[otchet6] == ply3
          || yt - myy[otchet4] == ply3
          || yt + myy[otchet4] == ply3
          || yt - myy[otchet2] == ply4
          || yt + myy[otchet2] == ply4
          || yt - myy[otchet4] == ply4
          || yt + myy[otchet4] == ply4
          || yt - myy[otchet6] == ply4
          || yt + myy[otchet6] == ply4
          || yt - myy[otchet7] == ply4
          || yt + myy[otchet7] == ply4) {

        // System.out.println("KOL");
        if (GameOtherVars.Fullimmortality == 0) {
          Minus = 1;
        }

        if (PlusOnce == 0) {
          PlayerZ++;
          PlusOnce = 1;
        }

        // System.out.println("nowfaleKOL");

      } else {
        // System.out.println("Yea.....");

        if (otchet == myx.length) {
          otchet = 0;
        } else {
          otchet++;
        }
        if (otchet3 == myx.length) {
          otchet3 = 0;
        } else {
          otchet3++;
        }
        if (otchet2 == myy.length) {
          otchet2 = 0;
        } else {
          otchet2++;
        }
        if (otchet4 == myy.length) {
          otchet4 = 0;
        } else {
          otchet4++;
        }
        if (otchet6 == myy.length) {
          otchet6 = 0;
        } else {
          otchet6++;
        }
        if (otchet5 == myx.length) {
          otchet5 = 0;
        } else {
          otchet5++;
        }
        if (otchet7 == myx.length) {
          otchet7 = 0;
        }
        if (otchet8 == myy.length) {
          otchet8 = 0;
        }
      }

    } else {

      if (otchet == myx.length) {
        otchet = 0;
      } else {
        otchet++;
      }
      if (otchet3 == myx.length) {
        otchet3 = 0;
      } else {
        otchet3++;
      }
      if (otchet5 == myx.length) {
        otchet5 = 0;
      } else {
        otchet5++;
      }
      if (otchet7 == myx.length) {
        otchet7 = 0;
      }
    }
  }
Example #2
0
  @Override
  public void update() {
    super.update();
    // z = xt+10;
    if (dead == 0) {
      if (otchet == myx.length) {
        otchet = 0;
      }
      if (otchet3 == myx.length) {
        otchet3 = 0;
      }
      if (otchet5 == myx.length) {
        otchet5 = 0;
      }
      if (otchet2 == myy.length) {
        otchet2 = 0;
      }
      if (otchet4 == myy.length) {
        otchet4 = 0;
      }
      if (otchet6 == myy.length) {
        otchet6 = 0;
      }
      if (otchet7 == myx.length) {
        otchet7 = 0;
      }
      if (otchet8 == myy.length) {
        otchet8 = 0;
      }

      if (xt - myx[otchet] == plx1
          || xt + myx[otchet] == plx1
          || xt - myx[otchet5] == plx1
          || xt + myx[otchet5] == plx1
          || xt - myx[otchet3] == plx1
          || xt + myx[otchet7] == plx1
          || xt - myx[otchet7] == plx1
          || xt + myx[otchet3] == plx1
          || xt - myx[otchet] == plx2
          || xt + myx[otchet] == plx2
          || xt - myx[otchet7] == plx2
          || xt + myx[otchet7] == plx2
          || xt - myx[otchet5] == plx2
          || xt + myx[otchet5] == plx2
          || xt - myx[otchet3] == plx2
          || xt + myx[otchet3] == plx2
          || xt - myx[otchet] == plx3
          || xt + myx[otchet] == plx3
          || xt - myx[otchet7] == plx3
          || xt + myx[otchet7] == plx3
          || xt - myx[otchet5] == plx3
          || xt + myx[otchet5] == plx3
          || xt - myx[otchet3] == plx3
          || xt + myx[otchet3] == plx3
          || xt - myx[otchet] == plx4
          || xt + myx[otchet] == plx4
          || xt - myx[otchet7] == plx4
          || xt + myx[otchet7] == plx4
          || xt - myx[otchet5] == plx4
          || xt + myx[otchet5] == plx4
          || xt - myx[otchet3] == plx4
          || xt + myx[otchet3] == plx4) {
        if (yt - myy[otchet2] == ply1
            || yt + myy[otchet2] == ply1
            || yt - myy[otchet7] == ply1
            || yt + myy[otchet7] == ply1
            || yt - myy[otchet6] == ply1
            || yt + myy[otchet6] == ply1
            || yt - myy[otchet4] == ply1
            || yt + myy[otchet4] == ply1
            || yt - myy[otchet6] == ply1
            || yt + myy[otchet6] == ply1
            || yt - myy[otchet7] == ply2
            || yt + myy[otchet7] == ply1
            || yt - myy[otchet2] == ply2
            || yt + myy[otchet2] == ply2
            || yt - myy[otchet6] == ply2
            || yt + myy[otchet6] == ply2
            || yt - myy[otchet4] == ply2
            || yt + myy[otchet4] == ply2
            || yt - myy[otchet2] == ply2
            || yt + myy[otchet2] == ply2
            || yt - myy[otchet4] == ply2
            || yt + myy[otchet4] == ply2
            || yt - myy[otchet2] == ply3
            || yt + myy[otchet2] == ply3
            || yt - myy[otchet7] == ply3
            || yt + myy[otchet7] == ply3
            || yt - myy[otchet6] == ply3
            || yt + myy[otchet6] == ply3
            || yt - myy[otchet4] == ply3
            || yt + myy[otchet4] == ply3
            || yt - myy[otchet2] == ply4
            || yt + myy[otchet2] == ply4
            || yt - myy[otchet4] == ply4
            || yt + myy[otchet4] == ply4
            || yt - myy[otchet6] == ply4
            || yt + myy[otchet6] == ply4
            || yt - myy[otchet7] == ply4
            || yt + myy[otchet7] == ply4) {
          sprite.currentStep = 1;
          dead = 1;

        } else {
          if (otchet == myx.length) {
            otchet = 0;
          } else {
            otchet++;
          }
          if (otchet3 == myx.length) {
            otchet3 = 0;
          } else {
            otchet3++;
          }
          if (otchet2 == myy.length) {
            otchet2 = 0;
          } else {
            otchet2++;
          }
          if (otchet4 == myy.length) {
            otchet4 = 0;
          } else {
            otchet4++;
          }
          if (otchet6 == myy.length) {
            otchet6 = 0;
          } else {
            otchet6++;
          }
          if (otchet5 == myx.length) {
            otchet5 = 0;
          } else {
            otchet5++;
          }
          if (otchet7 == myx.length) {
            otchet7 = 0;
          }
          if (otchet8 == myy.length) {
            otchet8 = 0;
          }
        }

      } else {

        if (otchet == myx.length) {
          otchet = 0;
        } else {
          otchet++;
        }
        if (otchet3 == myx.length) {
          otchet3 = 0;
        } else {
          otchet3++;
        }
        if (otchet5 == myx.length) {
          otchet5 = 0;
        } else {
          otchet5++;
        }
        if (otchet7 == myx.length) {
          otchet7 = 0;
        }
      }

      if (otchet == myx.length || otchet == myy.length) {
        otchet = 0;
      }
      if (otchet2 == myx.length || otchet2 == myy.length) {
        otchet2 = 0;
      }

      if (xt - myx[otchet] == plx1 || xt + myx[otchet] == plx1) {
        if (yt - myy[otchet] == ply1
            || yt + myy[otchet] == ply1
            || yt - myy[otchet2] == ply1
            || yt + myy[otchet2] == ply1) {
          sprite.currentStep = 1;
          dead = 1;

        } else {
          if (otchet == myx.length || otchet == myy.length) {
            otchet = 0;
          } else {
            otchet++;
          }
          if (otchet2 == myx.length || otchet2 == myy.length) {
            otchet2 = 0;
          } else {
            otchet2++;
          }
        }

      } else {

        if (otchet == myx.length || otchet == myy.length) {
          otchet = 0;
        } else {
          otchet++;
        }
        if (otchet2 == myx.length || otchet2 == myy.length) {
          otchet2 = 0;
        }
      }
    }

    if (otchet == myx.length || otchet == myy.length) {
      otchet = 0;
    }
    if (otchet2 == myx.length || otchet2 == myy.length) {
      otchet2 = 0;
    }
    if (dead == 1 && Timer_sec == 0) {
      Player.PlayerCanMovie = 1;
      sprite.currentStep = 1;
      if (Timer <= 0) {
        OnAI();
        Timer_sec = 1;
        Timer = 50;
      } else {
        Timer--;
      }
    }
    if (Timer_sec == 1) {
      if (Timer <= 0) {
        // System.out.println("Suns ready");
        GameOtherVars.VisibleDieLogo = 1;
        Timer_sec = 2;
        Timer = 100;
      } else {
        Timer--;
      }
    }
    if (Timer_sec == 2) {
      if (Timer <= 0) {
        // System.out.println("Suns ready2");
        dead = 0;
        Timer_sec = 0;
        Timer = 5;
        GameOtherVars.VisibleDieLogo = 0;
        Game.Get_Die();

      } else {
        Timer--;
      }
    }
  }