Package com.palepail.TestGame.Levels

Source Code of com.palepail.TestGame.Levels.LevelOne

package com.palepail.TestGame.Levels;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Animation;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.Array;
import com.palepail.TestGame.Enemies.BossOne;
import com.palepail.TestGame.Enemies.Follower;
import com.palepail.TestGame.Enemies.LargeEnemy;
import com.palepail.TestGame.Enemies.Shooter;
import com.palepail.TestGame.Message.Message;
import com.palepail.TestGame.Message.MessageString;
import com.palepail.TestGame.Model.Entity;
import com.palepail.TestGame.Utilities.Configuration;

public class LevelOne extends Level {

  Texture shipSheet;
  Texture enemySheet;
  Texture projectileSheet;
  Texture bossSheet;

  Animation enemyBasicBulletAnimation;
  Animation shooterAnimation;
  Animation shooterMoveAnimation;
  Animation shipAnimation;
  Animation shipMoveAnimation;
  Animation followerAnimation;

  Animation bossMoveAnimation;
  Animation bossWaitAnimation;
  Animation bossAttackAnimation;
  TextureRegion[] bossMoveFrames;
  TextureRegion[] bossWaitFrames;
  TextureRegion[] bossAttackFrames;

  TextureRegion bossHealthBar;

  int shipSheetTileWidth = 16;
  int shipSheetTileHeight = 16;
  TextureRegion[] shipFrames;
  TextureRegion[] shipMoveFrames;
  TextureRegion shipSlow;
  TextureRegion shipBasicBullet;

  TextureRegion basicExplosion;
  TextureRegion Follower;
  TextureRegion bomb;

  int enemySheetTileWidth = 32;
  int enemySheetTileHeight = 32;
  TextureRegion[] enemyBasicBulletFrames;
  TextureRegion[] shooterMoveFrames;
  TextureRegion[] shooterFrames;

  TextureRegion pointsItem;
  TextureRegion powerItem;
  TextureRegion bombItem;

  TextureRegion frameTexture;

  public LevelOne() {
    name = "Level One";
    bgm = "game";
    bgmName = "Naki Oujo no Tame no Septette";

   
    setQueues();

    // =================Animations

    shipSheet = new Texture(Gdx.files.internal("data/spritesheets/CharacterSheet.png"));
    enemySheet = new Texture(Gdx.files.internal("data/spritesheets/EnemySheet.png"));
    projectileSheet = new Texture(Gdx.files.internal("data/spritesheets/ProjectileSheet.png"));
    bossSheet = new Texture(Gdx.files.internal("data/spritesheets/BossSheet.png"));

    frameTexture = new TextureRegion(new Texture("data/screens/frame.png"));

    // set sprite sheet to work with to shipSheet
    TextureRegion[][] tmp = TextureRegion.split(shipSheet, shipSheet.getWidth() / shipSheetTileWidth * 3,
        shipSheet.getHeight() / shipSheetTileHeight * 3);
    shipFrames = new TextureRegion[3]; // number of frames for the animation
                      // counting from 0
    shipMoveFrames = new TextureRegion[4];

    // place all ship frames into array
    //
    int index = 0;
    for (int i = 2; i < 3; i++) {
      for (int j = 0; j < 3; j++) {
        shipFrames[index++] = tmp[i][j];
      }
    }
    // place all ship turing frams into array
    index = 0;
    for (int i = 3; i < 4; i++) {
      for (int j = 0; j < 4; j++) {
        shipMoveFrames[index++] = tmp[i][j];
      }
    }

    index = 0;
    for (int i = 3; i < 4; i++) {
      for (int j = 0; j < 4; j++) {
        shipMoveFrames[index++] = tmp[i][j];
      }
    }

    shipBasicBullet = new TextureRegion(shipSheet, 64, 224, 48, 16);

    shipAnimation = new Animation(.2f, shipFrames);
    shipMoveAnimation = new Animation(.2f, shipMoveFrames);

    // switch sprite sheet to enemySheet
    tmp = TextureRegion.split(enemySheet, enemySheet.getWidth() / 16, enemySheet.getHeight() / 16);

    // place enemy bulletFrames into array sprite sheet

    index = 0;
    enemyBasicBulletFrames = new TextureRegion[7];
    for (int i = 6; i < 7; i++) {
      for (int j = 8; j < 15; j++) {
        enemyBasicBulletFrames[index++] = tmp[i][j];
      }
    }
    enemyBasicBulletAnimation = new Animation(.15f, enemyBasicBulletFrames);
    animations.put("enemyBasicBulletBlue", enemyBasicBulletAnimation);
    // red enemy bullets
    index = 0;
    enemyBasicBulletFrames = new TextureRegion[7];
    for (int i = 4; i < 5; i++) {
      for (int j = 8; j < 15; j++) {
        enemyBasicBulletFrames[index++] = tmp[i][j];
      }
    }
    enemyBasicBulletAnimation = new Animation(.15f, enemyBasicBulletFrames);
    animations.put("enemyBasicBulletRed", enemyBasicBulletAnimation);

    // green enemy bullets
    index = 0;
    enemyBasicBulletFrames = new TextureRegion[7];
    for (int i = 5; i < 6; i++) {
      for (int j = 8; j < 15; j++) {
        enemyBasicBulletFrames[index++] = tmp[i][j];
      }
    }
    enemyBasicBulletAnimation = new Animation(.15f, enemyBasicBulletFrames);
    animations.put("enemyBasicBulletGreen", enemyBasicBulletAnimation);

    // place enemy frames into array from sprite sheet
    // blue shooter animations
    shooterFrames = new TextureRegion[3];
    index = 0;
    for (int i = 0; i < 1; i++) {
      for (int j = 0; j < 3; j++) {
        shooterFrames[index++] = tmp[i][j];
      }
    }
    shooterAnimation = new Animation(.2f, shooterFrames);
    animations.put("ShooterBlue", shooterAnimation);

    shooterMoveFrames = new TextureRegion[3];
    index = 0;
    for (int i = 0; i < 1; i++) {
      for (int j = 4; j < 7; j++) {
        shooterMoveFrames[index++] = tmp[i][j];
      }
    }
    shooterMoveAnimation = new Animation(.2f, shooterMoveFrames);
    animations.put("ShooterBlueMove", shooterMoveAnimation);

    shooterFrames = new TextureRegion[3];
    index = 0;
    for (int i = 1; i < 2; i++) {
      for (int j = 0; j < 3; j++) {
        shooterFrames[index++] = tmp[i][j];
      }
    }
    // red shooter animation
    shooterAnimation = new Animation(.2f, shooterFrames);
    animations.put("ShooterRed", shooterAnimation);

    shooterMoveFrames = new TextureRegion[3];
    index = 0;
    for (int i = 1; i < 2; i++) {
      for (int j = 4; j < 7; j++) {
        shooterMoveFrames[index++] = tmp[i][j];
      }
    }
    shooterMoveAnimation = new Animation(.2f, shooterMoveFrames);
    animations.put("ShooterRedMove", shooterMoveAnimation);

    // green shooter animations
    shooterFrames = new TextureRegion[3];
    index = 0;
    for (int i = 2; i < 3; i++) {
      for (int j = 0; j < 3; j++) {
        shooterFrames[index++] = tmp[i][j];
      }
    }
    shooterAnimation = new Animation(.2f, shooterFrames);
    animations.put("ShooterGreen", shooterAnimation);

    shooterMoveFrames = new TextureRegion[3];
    index = 0;
    for (int i = 2; i < 3; i++) {
      for (int j = 4; j < 7; j++) {
        shooterMoveFrames[index++] = tmp[i][j];
      }
    }
    shooterMoveAnimation = new Animation(.2f, shooterMoveFrames);
    animations.put("ShooterGreenMove", shooterMoveAnimation);

    shipSlow = new TextureRegion(projectileSheet, 288, 128, 64, 64);

    Follower = new TextureRegion(enemySheet, 1, 192, 32, 32);
    followerAnimation = new Animation(1f, Follower);
    animations.put("FollowerRed", followerAnimation);

    Follower = new TextureRegion(enemySheet, 65, 192, 32, 32);
    followerAnimation = new Animation(1f, Follower);
    animations.put("FollowerBlue", followerAnimation);

    Follower = new TextureRegion(enemySheet, 33, 192, 32, 32);
    followerAnimation = new Animation(1f, Follower);
    animations.put("FollowerGreen", followerAnimation);
    ;

    basicExplosion = new TextureRegion(enemySheet, 1, 224, 32, 32);
    textures.put("basicExplosionRed", basicExplosion);

    basicExplosion = new TextureRegion(enemySheet, 65, 224, 32, 32);
    textures.put("basicExplosionBlue", basicExplosion);

    basicExplosion = new TextureRegion(enemySheet, 33, 224, 32, 32);
    textures.put("basicExplosionGreen", basicExplosion);

    // place enemy bulletFrames into array sprite sheet
    bossWaitFrames = new TextureRegion[4];
    index = 0;
    for (int j = 0; j < 4; j++) {
      bossWaitFrames[index++] = new TextureRegion(bossSheet, j * 48, 0, 48, 64);
    }
    bossWaitAnimation = new Animation(.15f, bossWaitFrames);
    animations.put("BossOneWait", bossWaitAnimation);

    bossMoveFrames = new TextureRegion[3];
    index = 0;
    for (int j = 0; j < 3; j++) {
      bossMoveFrames[index++] = new TextureRegion(bossSheet, j * 48, 1 * 64, 48, 64);
    }
    bossMoveAnimation = new Animation(.15f, bossMoveFrames);
    animations.put("BossOneMove", bossMoveAnimation);

    bossAttackFrames = new TextureRegion[4];
    index = 0;
    for (int j = 0; j < 4; j++) {
      bossAttackFrames[index++] = new TextureRegion(bossSheet, j * 48, 2 * 64, 48, 64);
    }
    bossAttackAnimation = new Animation(.15f, bossAttackFrames);
    animations.put("BossOneAttack", bossAttackAnimation);

    bossHealthBar = new TextureRegion(projectileSheet, 34, 18, 14, 14);
    textures.put("healthBar", bossHealthBar);

    bomb = new TextureRegion(projectileSheet, 695, 28, 256, 256);

    powerItem = new TextureRegion(projectileSheet, 320, 80, 16, 16);
    bombItem = new TextureRegion(projectileSheet, 336, 80, 16, 16);
    pointsItem = new TextureRegion(projectileSheet, 306, 82, 12, 12);

    animations.put("Ship", shipAnimation);
    animations.put("ShipMove", shipMoveAnimation);

    textures.put("shipBasicBullet", shipBasicBullet);
    textures.put("shipSlow", shipSlow);
    textures.put("bomb", bomb);

    textures.put("Follower", Follower);

    textures.put("powerItem", powerItem);
    textures.put("bombItem", bombItem);
    textures.put("pointsItem", pointsItem);
    textures.put("Frame", frameTexture);

  }

  public Animation getAnimation(String key) {

    return animations.get(key);
  }

  public TextureRegion getTexture(String key) {

    return textures.get(key);
  }

  public Level getNextLevel() {
    return new LevelTwo();
  }

  protected void setQueues() {
    super.setQueues();

    for (int x = 300; x < 600; x += 60) {

      Shooter shooter = getShooterSingle(getTopLeft(), 75, 0, Entity.VARIATION_BLUE);
      shooter.setTopLeftToBottomScript();
      enemyQueue.add(shooter);
      enemyTimes.add(x);

      shooter = getShooterSingle(getTopRight(), 75, 0, Entity.VARIATION_BLUE);
      shooter.setTopRightToBottomScript();
      enemyQueue.add(shooter);
      enemyTimes.add(x + 30);
    }

    // wait for enemies to be inactive before continuing
    enemyTimes.add(WAIT_FOR_ENEMIES);

    enemyQueue.add(getFollowerLerp(5, 23, 0, 0f, Entity.VARIATION_BLUE));
    enemyTimes.add(660);
    enemyQueue.add(getFollowerLerp(14, 23, 0, 0f, Entity.VARIATION_BLUE));
    enemyTimes.add(660);

    enemyQueue.add(getFollowerLerp(getMidRight(), 0, 0, Entity.VARIATION_BLUE));
    enemyTimes.add(690);

    enemyQueue.add(getFollowerLerp(getMidLeft(), 0, 0, Entity.VARIATION_BLUE));
    enemyTimes.add(690);

    LargeEnemy largeEnemy = getLargeEnemyBurst(5, 23, 100, 0, Entity.VARIATION_BLUE);
    largeEnemy.setLeftDownUpScript();
    enemyQueue.add(largeEnemy);
    enemyTimes.add(850);

    largeEnemy = getLargeEnemyBurst(16, 23, 100, 0, Entity.VARIATION_BLUE);
    largeEnemy.setRightDownUpScript();
    enemyQueue.add(largeEnemy);
    enemyTimes.add(850);

    for (int x = 1000; x < 1300; x += 20) {
      Shooter shoot = getShooterSingle(0, 12, 75, 0, Entity.VARIATION_BLUE);
      shoot.setSplineLoopLeftScript();
      enemyQueue.add(shoot);
      enemyTimes.add(x);

      shoot = getShooterSingle(0, 12, 75, 0, Entity.VARIATION_BLUE);
      shoot.setSplineLoopRightScript();
      enemyQueue.add(shoot);
      enemyTimes.add(x + 10);
    }

    for (int x = 1500; x < 1700; x += 20) {
      Shooter shoot = getShooterSquiggle(0, 12, 100, 10, Entity.VARIATION_RED);
      shoot.setSplineLoopLeftScript();
      enemyQueue.add(shoot);
      enemyTimes.add(x);

      shoot = getShooterSquiggle(0, 12, 100, 10, Entity.VARIATION_RED);
      shoot.setSplineLoopRightScript();
      enemyQueue.add(shoot);
      enemyTimes.add(x + 10);
    }

    largeEnemy = getLargeEnemySquiggle(5, 23, 100, 10, Entity.VARIATION_RED);
    largeEnemy.setLeftDownUpScript();
    enemyQueue.add(largeEnemy);
    enemyTimes.add(2000);

    largeEnemy = getLargeEnemySquiggle(16, 23, 100, 10, Entity.VARIATION_RED);
    largeEnemy.setRightDownUpScript();
    enemyQueue.add(largeEnemy);
    enemyTimes.add(2000);

    Follower follower = getFollowerDoubleShot(-1, 14, 0, 5, Entity.VARIATION_RED);
    follower.setVelocity(.5f, 0);

    enemyQueue.add(follower);
    enemyTimes.add(2400);

    follower = getFollowerDoubleShot(21, 14, 0, 5, Entity.VARIATION_RED);
    follower.setVelocity(-.5f, 0);
    enemyQueue.add(follower);
    enemyTimes.add(2400);

    follower = getFollowerDoubleShot(5, 23, 0, 5, Entity.VARIATION_RED);
    follower.setVelocity(0, -.5f);

    enemyQueue.add(follower);
    enemyTimes.add(2600);

    follower = getFollowerDoubleShot(14, 23, 0, 5, Entity.VARIATION_RED);
    follower.setVelocity(0, -.5f);
    enemyQueue.add(follower);
    enemyTimes.add(2600);

    enemyTimes.add(WAIT_FOR_ENEMIES);
    boolean alternate = false;
    for (int x = 2900; x < 3500; x += 20) {
      Shooter shoot = getShooterSingle(0, 12, 100, 0, Entity.VARIATION_BLUE);
      if (alternate) {
        shoot.setSplineLoopLeftScript();
      } else {
        shoot.setSplineLoopRightScript();
      }
      enemyQueue.add(shoot);
      enemyTimes.add(x);

      shoot = getShooterSquiggle(0, 12, 100, 10, Entity.VARIATION_RED);
      if (alternate) {
        shoot.setSplineLoopRightScript();
      } else {
        shoot.setSplineLoopLeftScript();
      }
      enemyQueue.add(shoot);
      enemyTimes.add(x);
      alternate = !alternate;
    }

    largeEnemy = getLargeEnemySquiggle(5, 23, 100, 10, Entity.VARIATION_RED);
    largeEnemy.setLeftDownUpScript();
    enemyQueue.add(largeEnemy);
    enemyTimes.add(3700);

    largeEnemy = getLargeEnemyBurst(16, 23, 100, 10, Entity.VARIATION_BLUE);
    largeEnemy.setRightDownUpScript();
    enemyQueue.add(largeEnemy);
    enemyTimes.add(3700);
    enemyTimes.add(WAIT_FOR_ENEMIES);

    for (int x = 3900; x < 4400; x += 20) {
      Shooter shoot = getShooterSplit(0, 12, 100, 0, Entity.VARIATION_GREEN);

      shoot.setSplineLoopLeftScript();
      enemyQueue.add(shoot);
      enemyTimes.add(x);

      shoot = getShooterSplit(0, 12, 100, 10, Entity.VARIATION_GREEN);

      shoot.setSplineLoopRightScript();
      enemyQueue.add(shoot);
      enemyTimes.add(x);

    }
    enemyTimes.add(WAIT_FOR_ENEMIES);

    follower = getFollowerSplit(10, 24, 0, 5, Entity.VARIATION_GREEN, 3);

    enemyQueue.add(follower);
    enemyTimes.add(4750);
    enemyTimes.add(WAIT_FOR_ENEMIES);

    for (int x = 5000; x < 5500; x += 20) {
      Shooter shoot = getShooterSplit(0, 12, 100, 0, Entity.VARIATION_GREEN);
      if (alternate) {
        shoot.setSplineLoopLeftScript();
      } else {
        shoot.setSplineLoopRightScript();
      }
      enemyQueue.add(shoot);
      enemyTimes.add(x);

      shoot = getShooterSquiggle(0, 12, 100, 10, Entity.VARIATION_RED);
      if (alternate) {
        shoot.setSplineLoopRightScript();
      } else {
        shoot.setSplineLoopLeftScript();
      }
      enemyQueue.add(shoot);
      enemyTimes.add(x);
      alternate = !alternate;
    }

    largeEnemy = getLargeEnemySplit(5, 23, 100, 10, Entity.VARIATION_GREEN);
    largeEnemy.setLeftDownUpScript();
    enemyQueue.add(largeEnemy);
    enemyTimes.add(6000);

    largeEnemy = getLargeEnemySplit(16, 23, 100, 10, Entity.VARIATION_GREEN);
    largeEnemy.setRightDownUpScript();
    enemyQueue.add(largeEnemy);
    enemyTimes.add(6000);
    enemyTimes.add(WAIT_FOR_ENEMIES);

    BossOne boss = new BossOne(5f, 0, 2 * Configuration.gameScale, 2 * Configuration.gameScale, new Vector2(
        10 * Configuration.gameScale, 23 * Configuration.gameScale));
    enemyQueue.add(boss);
    enemyTimes.add(6300);

    enemyTimes.add(WAIT_FOR_ENEMIES);
    enemyTimes.add(VICTORY);

  }

}
 
TOP

Related Classes of com.palepail.TestGame.Levels.LevelOne

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.