コード例 #1
0
ファイル: Level3State.java プロジェクト: IvanAli/ColesteRage
 public void eventPoints() {
   if (player.getEatenDishes() > 0) {
     player.addEatenDishes(-1);
     player.increaseScore(5);
     AudioPlayer.play("increasescore");
   } else nextLevel = true;
 }
コード例 #2
0
ファイル: World1State.java プロジェクト: NINJAMUSICIAN/Amodo
 public void startMusic() {
   if (gsm.getCurrentLevel() == 1) {
     bgMusic = new AudioPlayer("/Audio/Music/CuriousCritters2.mp3");
     bgMusic.play();
     setMusicStarted(getMusicStarted() + 1);
   }
 }
コード例 #3
0
ファイル: Level3State.java プロジェクト: IvanAli/ColesteRage
 public void clearAll() {
   ImagesLoader.clearImages();
   AudioPlayer.clearAudio();
 }
コード例 #4
0
ファイル: Level3State.java プロジェクト: IvanAli/ColesteRage
 public void stopAudioPlayer() {
   AudioPlayer.stop(musicFnm);
   // AudioPlayer.stopAll();
 }
コード例 #5
0
ファイル: Level3State.java プロジェクト: IvanAli/ColesteRage
  public void input() {
    if (player.isPlaying())
      if (Keys.isPressed(Keys.ESCAPE) || Keys.isPressed(Keys.ENTER)) gsm.setPaused(true);
    if (!eventCaught && !eventDead && !eventClear) {
      if (Keys.isPressed(Keys.UP)) {
        player.setUp();
        npc.setUp();
      }
      if (Keys.isPressed(Keys.DOWN)) {
        player.setDown();
        npc.setDown();
      }
      if (Keys.isPressed(Keys.SPACE)) player.setJumping();
      if (Keys.isPressed(Keys.RIGHT)) player.setAccelerating();
    }

    if (eventCaught) {
      if (Keys.isPressed(Keys.ENTER)) {
        AudioPlayer.stop("levelfailcaught");
        gsm.setState(GameStateManager.MENU);
        ImagesLoader.removeImages("nivel3_imagenes.txt");
        ImagesLoader.removeImages("player_imagenes.txt");
        ImagesLoader.removeImages("npc_imagenes.txt");
        ImagesLoader.removeImages("hud_imagenes.txt");
        ImagesLoader.removeImages("nivel_efectosvisuales_imagenes.txt");
        AudioLoader.removeAudio("nivel3_sonido.txt");
      }
    }
    if (eventDead) {
      if (Keys.isPressed(Keys.ENTER)) {
        AudioPlayer.stop("levelfaildead");
        gsm.setState(GameStateManager.MENU);
        ImagesLoader.removeImages("nivel3_imagenes.txt");
        ImagesLoader.removeImages("player_imagenes.txt");
        ImagesLoader.removeImages("npc_imagenes.txt");
        ImagesLoader.removeImages("hud_imagenes.txt");
        ImagesLoader.removeImages("nivel_efectosvisuales_imagenes.txt");
        AudioLoader.removeAudio("nivel3_sonido.txt");
      }
    }
    if (eventClear) {
      if (Keys.isPressed(Keys.ENTER)) {
        if (!showResults) {
          showResults = true;
          resultsStartTime = System.nanoTime();
          return;
        }
        if (ticksResults > 65) {
          eventPoints = true;
          if (nextLevel) {
            AudioPlayer.play("menu_skip");
            AudioPlayer.stop("levelclear");
            ImagesLoader.removeImages("nivel3_imagenes.txt");
            AudioLoader.removeAudio("nivel3_sonido.txt");
            gsm.setState(nextState);
          }
        }
      }

      /*
      if(Keys.isPressed(Keys.ENTER)) {
             AudioPlayer.stop("levelclear");
             gsm.setState(GameStateManager.Level3);
         }
         */
    }
  }
コード例 #6
0
ファイル: Level3State.java プロジェクト: IvanAli/ColesteRage
  public void update() {

    // keyboard input
    input();

    // check the events flags
    eventClear = player.clearedLevel();
    eventDead = player.isDead();
    eventCaught = player.isCaught();

    if (eventIntro) {
      // title update
      player.setPlaying(false);
      if (titleIntroA != null) {
        titleIntroA.update();
        if (titleIntroA.shouldRemove()) {
          titleIntroA = null;
          titleIntroB.start();
        }
      }
      if (titleIntroB != null) {
        titleIntroB.update();
        if (titleIntroB.shouldRemove()) {
          titleIntroB = null;
          eventIntro = false;
          player.setPlaying(true);
        }
      }
    }

    if (eventClear || eventDead || eventCaught) player.stop();

    if (eventClear) {
      if (!playFlag) {
        AudioPlayer.stop(musicFnm);
        AudioPlayer.playAndLoop("levelclear");
        playFlag = true;
      }
      PlayerData.setScore(player.getScore());
      PlayerData.addEatenDishes(player.getEatenDishes());
      if (showResults) showResults();
      if (!titleClear.hasStarted()) titleClear.start();
    }

    if (eventCaught) {
      if (!playFlag) {
        AudioPlayer.stop(musicFnm);
        AudioPlayer.play("levelfailcaught");
        playFlag = true;
      }
      if (!titleCaught.hasStarted()) titleCaught.start();
      if (titleCaught.shouldRemove()) titleCaught = null;
    }

    if (eventDead) {
      if (!playFlag) {
        AudioPlayer.stop(musicFnm);
        AudioPlayer.play("levelfaildead");
        playFlag = true;
      }
      if (!titleDead.hasStarted()) titleDead.start();
      if (titleDead.shouldRemove()) titleDead = null;
    }

    camera.setPosition(playerxscreen - player.getx(), 0);

    player.update();

    /*
    bgSky.setPosition(camera.getx() * 0.6, camera.gety() + bgSky.gety());
    bgSoil.setPosition(camera.getx(), camera.gety() + bgSoil.gety());

    bgSky.update();
    bgSoil.update();
    */

    bgKitchen.setPosition(camera.getx(), camera.gety());
    bgKitchen.update();

    for (int i = 0; i < numbers.size(); i++) {
      numbers.get(i).update();
      if (numbers.get(i).isOver()) {
        numbers.remove(i);
        i--;
      }
    }

    for (int i = 0; i < explosions.size(); i++) {
      SpriteAnimation explosion = explosions.get(i);
      explosion.update();
      if (explosion.hasPlayedOnce()) {
        explosions.remove(i);
        i--;
      }
    }
    for (int i = 0; i < powerup.size(); i++) {
      SpriteAnimation pup = powerup.get(i);
      pup.update();
      if (pup.hasPlayedOnce()) {
        powerup.remove(i);
        i--;
      }
    }

    // collisionDetection();
    for (int i = 0; i < dishes.size(); i++) {
      // dishes.get(i).setPosition(400 - player.getx(), dishes.get(i).gety());
      dishes.get(i).update();
      if (dishes.get(i).shouldRemove()) {
        dishes.remove(i);
        i--;
      }
    }
    hud.update();
    npc.update();

    if (player.getCholesterol() >= 85) {
      heartAttack.update();
      if (heartAttack.shouldPlaySound()) if (player.isPlaying()) AudioPlayer.play("heartbeat");
    }
    if (player.getCholesterol() <= 25) {
      warning.update();
      if (warning.shouldPlaySound()) if (player.isPlaying()) AudioPlayer.play("redalert");
    }

    levelIntroTimerDiff = (System.nanoTime() - levelIntroTimer) / 1000000;
    if (levelIntroTimerDiff > levelIntroDelay) levelStart = true;

    if (eventIntro || eventClear || eventDead || eventCaught) return;
    addDish();
  }
コード例 #7
0
ファイル: Level3State.java プロジェクト: IvanAli/ColesteRage
  public void init() {

    // LEVEL SPEED
    levelSpeed = 8;

    // AudioPlayer init
    AudioLoader.loadFromFile("nivel3_sonido.txt");

    // images loading
    ImagesLoader.loadFromFile("nivel3_imagenes.txt");
    ImagesLoader.loadFromFile("nivel_efectosvisuales_imagenes.txt");
    ImagesLoader.loadFromFile("food_imagenes.txt");

    // food appearance probability
    if (difficulty == OptionsState.EASY) foodprobability = 0.8;
    if (difficulty == OptionsState.NORMAL) foodprobability = 0.88;
    if (difficulty == OptionsState.HARD) foodprobability = 0.94;

    fooddelays = new int[6];
    fooddelays[0] = 100;
    fooddelays[1] = 600;
    fooddelays[2] = 100;
    fooddelays[3] = 500;
    fooddelays[4] = 100;
    fooddelays[5] = 400;

    // Events init
    eventIntro = true;
    eventClear = eventDead = eventCaught = false;

    txtAnimation = new TextAnimation();

    camera = new Camera();
    cameraPoint = new Camera();

    levelStart = false;
    levelIntroTimer = System.nanoTime();
    levelIntroDelay = 10000;

    foodTimer = System.nanoTime();
    foodDelay = 3000;

    // load fonts
    Text.loadFont("yummyFont.png");
    Text.loadFont("leishoFont.png");

    player = new Player();
    npc = new NPC(player);
    dishes = new ArrayList<>();
    hud = new HUD(player);

    // difficulty
    difficulty = OptionsData.getDifficulty();

    // rails init
    rails = new Rail[3];

    // title init
    titleIntroA = new Title(levelName, Title.INTROANIMATIONA);
    titleIntroB = new Title("EMPIEZA", Title.INTROANIMATIONB);
    titleClear = new Title("GANASTE", Title.CLEARANIMATION);
    titleDead = new Title("MORISTE", Title.CAUGHTANIMATION);
    titleCaught = new Title("ATRAPADO", Title.CAUGHTANIMATION);

    titleIntroA.start();

    // background creation
    // individual creation

    bgKitchen = new Background(0, 0, ImagesLoader.getImage("3_background"), Background.MOVELEFT);
    heartAttack =
        new BackgroundAnimation(
            ImagesLoader.getImage("heartsolo"), BackgroundAnimation.HEARTATTACK);
    warning =
        new BackgroundAnimation(ImagesLoader.getImage("warning"), BackgroundAnimation.WARNING);
    /*
    bgSky = new Background(0, 0, ImagesLoader.getImage("nivel1_clouds"));
    bgSoil = new Background(0, GamePanel.HEIGHT - (ImagesLoader.getHeight("nivel1_soil")),
            ImagesLoader.getImage("nivel1_soil"));
    */
    numbers = new ArrayList<>();
    explosions = new ArrayList<>();
    powerup = new ArrayList<>();
    player.init(dishes, numbers, explosions, powerup);

    // setting the score for the player
    player.setScore(PlayerData.getScore());

    foodValues = new HashMap<>();
    foodList = new ArrayList<>();
    powerList = new ArrayList<>();

    loadFoodFile("archivoComida.txt");

    powerList.add("FREEZEPOWER");
    powerList.add("DOUBLESCOREPOWER");
    powerList.add("DOUBLESPEEDPOWER");
    powerList.add("HALFSPEEDPOWER");

    // set position
    // debugging
    player.setPositionInRail(playerxscreen, player.getCurrentRail());
    cameraPoint.setPosition(playerxscreen, 0);

    // player.setVector(levelSpeed, 0);
    // parameters to be given: dx, dy, moveSpeed, jumpStart, fallSpeed
    player.setSpeed(levelSpeed, 0, 3.6, -28.8, 1.8);
    cameraPoint.setVector(levelSpeed, 0);

    npc.setPositionInRail(-npc.getWidth() / 2, npc.getCurrentRail());
    // npc.setVector(levelSpeed, 0);
    // parameters to be given: dx, dy, moveSpeed
    npc.setSpeed(levelSpeed, 0, 3.6);

    player.setCamera(camera);
    npc.setCamera(camera);

    // results stuff init
    squarewidth = 5;
    squareheight = 1;
    resultsDelay = 600;
    ticksResults = 0;

    // AudioPlayer volume setting
    // AudioPlayer.setVolume("musicFnm", -5.0f);
    AudioPlayer.setVolume("increasescore", -25.0f);

    // AudioPlayer bg play
    AudioPlayer.playAndLoop(musicFnm);
  }