deadstephanie_edge-of-solaris/edge_of_solaris/level_layouts.pde
void placeEnemies() {
  if (levelIndex == 98) { //performance test level
    genEnemy(2, 1000, 300);
    
    genEnemy(0, 1200, 200);
    genEnemy(0, 1200, 400);
    genEnemy(0, 1200, 100);
    genEnemy(0, 1200, 500);
    genEnemy(0, 1200, 600);
    genEnemy(0, 1200, 0);
    
    genEnemy(3, 1300, 50);
    genEnemy(3, 1300, 225);
    genEnemy(3, 1300, 400);
    genEnemy(3, 1300, 575);
    
    genEnemy(0, 1400, 100);
    genEnemy(0, 1400, 300);
    genEnemy(0, 1400, 500);
    
    genEnemy(1, 1600, 50);
    genEnemy(1, 1600, 225);
    genEnemy(1, 1600, 400);
    genEnemy(1, 1600, 575);
    
    genEnemy(0, 1800, 100);
    genEnemy(0, 1800, 300);
    genEnemy(0, 1800, 500);
    
    genEnemy(3, 2000, 50);
    genEnemy(3, 2000, 225);
    genEnemy(3, 2000, 400);
    genEnemy(3, 2000, 575);
    
    genEnemy(1, 2200, 100);
    genEnemy(2, 2200, 300);
    genEnemy(1, 2200, 500);
    
    genEnemy(0, 2400, 50);
    genEnemy(0, 2400, 225);
    genEnemy(0, 2400, 400);
    genEnemy(0, 2400, 575);
    
    genEnemy(4, 3000, 50);
    genEnemy(4, 3000, 150);
    genEnemy(4, 3000, 250);
    genEnemy(4, 3000, 350);
    genEnemy(4, 3000, 450);
    genEnemy(4, 3000, 550);
    
    genEnemy(0, 3600, 0);
    genEnemy(0, 3600, 100);
    genEnemy(0, 3600, 200);
    genEnemy(0, 3600, 300);
    genEnemy(0, 3600, 400);
    genEnemy(0, 3600, 500);
    genEnemy(0, 3600, 600);
    
    genEnemy(0, 3700, 0);
    genEnemy(0, 3700, 100);
    genEnemy(0, 3700, 200);
    genEnemy(0, 3700, 300);
    genEnemy(0, 3700, 400);
    genEnemy(0, 3700, 500);
    genEnemy(0, 3700, 600);
    
    genEnemy(0, 3800, 0);
    genEnemy(0, 3800, 100);
    genEnemy(0, 3800, 200);
    genEnemy(0, 3800, 300);
    genEnemy(0, 3800, 400);
    genEnemy(0, 3800, 500);
    genEnemy(0, 3800, 600);
    
    genEnemy(0, 3900, 0);
    genEnemy(0, 3900, 100);
    genEnemy(0, 3900, 200);
    genEnemy(0, 3900, 300);
    genEnemy(0, 3900, 400);
    genEnemy(0, 3900, 500);
    genEnemy(0, 3900, 600);
    
    genEnemy(0, 4000, 0);
    genEnemy(0, 4000, 100);
    genEnemy(0, 4000, 200);
    genEnemy(0, 4000, 300);
    genEnemy(0, 4000, 400);
    genEnemy(0, 4000, 500);
    genEnemy(0, 4000, 600);
    
    genEnemy(0, 4100, 0);
    genEnemy(0, 4100, 100);
    genEnemy(0, 4100, 200);
    genEnemy(0, 4100, 300);
    genEnemy(0, 4100, 400);
    genEnemy(0, 4100, 500);
    genEnemy(0, 4100, 600);
    
    genEnemy(0, 4200, 0);
    genEnemy(0, 4200, 100);
    genEnemy(0, 4200, 200);
    genEnemy(0, 4200, 300);
    genEnemy(0, 4200, 400);
    genEnemy(0, 4200, 500);
    genEnemy(0, 4200, 600);
    
    genEnemy(0, 4300, 0);
    genEnemy(0, 4300, 100);
    genEnemy(0, 4300, 200);
    genEnemy(0, 4300, 300);
    genEnemy(0, 4300, 400);
    genEnemy(0, 4300, 500);
    genEnemy(0, 4300, 600);
    
    genEnemy(0, 4400, 0);
    genEnemy(0, 4400, 100);
    genEnemy(0, 4400, 200);
    genEnemy(0, 4400, 300);
    genEnemy(0, 4400, 400);
    genEnemy(0, 4400, 500);
    genEnemy(0, 4400, 600);
    
    genEnemy(0, 4500, 0);
    genEnemy(0, 4500, 100);
    genEnemy(0, 4500, 200);
    genEnemy(0, 4500, 300);
    genEnemy(0, 4500, 400);
    genEnemy(0, 4500, 500);
    genEnemy(0, 4500, 600);
    
    genEnemy(0, 4600, 0);
    genEnemy(0, 4600, 100);
    genEnemy(0, 4600, 200);
    genEnemy(0, 4600, 300);
    genEnemy(0, 4600, 400);
    genEnemy(0, 4600, 500);
    genEnemy(0, 4600, 600);
    
    genEnemy(0, 4700, 0);
    genEnemy(0, 4700, 100);
    genEnemy(0, 4700, 200);
    genEnemy(0, 4700, 300);
    genEnemy(0, 4700, 400);
    genEnemy(0, 4700, 500);
    genEnemy(0, 4700, 600);
    
    genEnemy(0, 4800, 0);
    genEnemy(0, 4800, 100);
    genEnemy(0, 4800, 200);
    genEnemy(0, 4800, 300);
    genEnemy(0, 4800, 400);
    genEnemy(0, 4800, 500);
    genEnemy(0, 4800, 600);
  } else if (levelIndex == 1) { //miniboss level
    genEnemy(6, 1000, 350);
    genEnemy(6, 800, 150);
    genEnemy(6, 800, 550);
    
    genEnemy(0, 1400, 350);
    genEnemy(0, 1400, 500);
    genEnemy(0, 1400, 200);
    
    genEnemy(3, 1700, 350);
    genEnemy(3, 1750, 400);
    genEnemy(3, 1750, 300);
    genEnemy(3, 1800, 450);
    genEnemy(3, 1800, 250);
    
    genEnemy(6, 2000, 450);
    genEnemy(6, 2050, 500);
    genEnemy(6, 2100, 550);
    
    genEnemy(6, 2200, 250);
    genEnemy(6, 2250, 200);
    genEnemy(6, 2300, 150);
    
    genEnemy(4, 2500, 300);
  } else if (levelIndex == 0) { //opening level
    genEnemy(6, 1000, 400);
    genEnemy(6, 1100, 500);
    genEnemy(6, 1200, 600);
    genEnemy(6, 1500, 300);
    genEnemy(6, 1600, 200);
    genEnemy(6, 1700, 100);
    
    genEnemy(0, 1800, 100);
    genEnemy(0, 1900, 200);
    genEnemy(0, 2000, 300);
    
    genEnemy(6, 2100, 350);
    genEnemy(6, 2200, 450);
    genEnemy(6, 2200, 250);
    genEnemy(6, 2300, 550);
    genEnemy(6, 2300, 150);
    
    genEnemy(6, 2800, 350);
    genEnemy(6, 2850, 400);
    genEnemy(6, 2850, 300);
    genEnemy(6, 2900, 450);
    genEnemy(6, 2900, 250);
    genEnemy(6, 2950, 500);
    genEnemy(6, 2950, 200);
    genEnemy(6, 3000, 550);
    genEnemy(6, 3000, 150);
    
    genEnemy(6, 3200, 350);
    genEnemy(6, 3300, 450);
    genEnemy(6, 3300, 250);
    genEnemy(6, 3400, 550);
    genEnemy(6, 3400, 150);
    
    genEnemy(6, 3600, 350);
    genEnemy(6, 3650, 400);
    genEnemy(6, 3650, 300);
    genEnemy(6, 3700, 450);
    genEnemy(6, 3700, 250);
    genEnemy(6, 3750, 500);
    genEnemy(6, 3750, 200);
    genEnemy(6, 3800, 550);
    genEnemy(6, 3800, 150);
  } else if (levelIndex == 99) {
    genEnemy(7, 900, 100);
    genEnemy(7, 900, 200);
    genEnemy(7, 900, 300);
    genEnemy(7, 900, 400);
    genEnemy(7, 900, 500);
    genEnemy(7, 900, 600);
  } else if (levelIndex == 2) { //3rd level
    genEnemy(2, 900, 100);
    genEnemy(2, 1100, 300);
    genEnemy(2, 1300, 500);
    
    genEnemy(2, 1600, 500);
    genEnemy(2, 1800, 300);
    genEnemy(2, 2000, 100);
    
    genEnemy(2, 2600, 100);
    genEnemy(2, 2650, 200);
    genEnemy(2, 2600, 300);
    genEnemy(2, 2650, 400);
    genEnemy(2, 2600, 500);
    
    genEnemy(2, 3200, 50);
    genEnemy(2, 3250, 150);
    genEnemy(2, 3200, 250);
    genEnemy(2, 3250, 350);
    genEnemy(2, 3200, 450);
    genEnemy(2, 3250, 550);
    genEnemy(0, 3200, 600);
    
    genEnemy(2, 3600, 100);
    genEnemy(2, 3650, 200);
    genEnemy(2, 3600, 300);
    genEnemy(2, 3650, 400);
    genEnemy(2, 3600, 500);
    
    genEnemy(2, 4200, 500);
    genEnemy(2, 4200, 300);
    genEnemy(2, 4200, 100);
    
    genEnemy(2, 4600, 500);
    genEnemy(2, 4600, 300);
    genEnemy(2, 4600, 100);
    
    genEnemy(2, 5000, 500);
    genEnemy(2, 5000, 300);
    genEnemy(2, 5000, 100);
    
    genEnemy(2, 5600, 100);
    genEnemy(2, 5650, 200);
    genEnemy(2, 5600, 300);
    genEnemy(2, 5650, 400);
    genEnemy(2, 5600, 500);
    genEnemy(0, 5600, 600);
    
    genEnemy(2, 6200, 50);
    genEnemy(2, 6250, 150);
    genEnemy(2, 6200, 250);
    genEnemy(2, 6250, 350);
    genEnemy(2, 6200, 450);
    genEnemy(2, 6250, 550);
    
    genEnemy(2, 6600, 100);
    genEnemy(2, 6650, 200);
    genEnemy(2, 6600, 300);
    genEnemy(2, 6650, 400);
    genEnemy(2, 6600, 500);
    genEnemy(0, 6600, 600);
    
    genEnemy(0, 7200, 500);
    genEnemy(0, 7200, 300);
    genEnemy(0, 7200, 100);
    
    genEnemy(0, 7600, 500);
    genEnemy(0, 7600, 300);
    genEnemy(0, 7600, 100);
    
    genEnemy(0, 8000, 500);
    genEnemy(0, 8000, 300);
    genEnemy(0, 8000, 100);
    
    genEnemy(1, 8600, 100);
    genEnemy(1, 8650, 200);
    genEnemy(1, 8600, 300);
    genEnemy(1, 8650, 400);
    genEnemy(1, 8600, 500);
  }
}

void genEnemy(int type, int x, int y) { //used for placing enemies easier, pass in enemy type and position x/y
  enemyIndex = findEnemy();
  basicE[enemyIndex].enemyState = 0;
  if (type == 0) {
    basicE[enemyIndex].enemyX = x;
    basicE[enemyIndex].enemyY = y;
    basicE[enemyIndex].enemySpeedX = autoScroll;
    basicE[enemyIndex].enemySpeedY = 0;
    basicE[enemyIndex].enemyType = 0;
    basicE[enemyIndex].enemyHitX = 100;
    basicE[enemyIndex].enemyHitY = 100;
    basicE[enemyIndex].enemyHP = 10 * enemyBalanceHP;
    basicE[enemyIndex].enemyHPMax = 10 * enemyBalanceHP;
  } else if (type == 1) {
    basicE[enemyIndex].enemyX = x;
    basicE[enemyIndex].enemyY = y;
    basicE[enemyIndex].enemySpeedX = autoScroll;
    basicE[enemyIndex].enemySpeedY = 0;
    basicE[enemyIndex].enemyType = type;
    basicE[enemyIndex].enemyHitX = 200;
    basicE[enemyIndex].enemyHitY = 76;
    basicE[enemyIndex].enemyHP = 50 * enemyBalanceHP;
    basicE[enemyIndex].enemyHPMax = 50 * enemyBalanceHP;
  } else if (type == 2) {
    basicE[enemyIndex].enemyX = x;
    basicE[enemyIndex].enemyY = y;
    basicE[enemyIndex].enemySpeedX = autoScroll;
    basicE[enemyIndex].enemySpeedY = 0;
    basicE[enemyIndex].enemyType = type;
    basicE[enemyIndex].enemyHitX = 160;
    basicE[enemyIndex].enemyHitY = 60;
    basicE[enemyIndex].enemyHP = 20 * enemyBalanceHP;
    basicE[enemyIndex].enemyHPMax = 20 * enemyBalanceHP;
  } else if (type == 3) {
    basicE[enemyIndex].enemyX = x;
    basicE[enemyIndex].enemyY = y;
    basicE[enemyIndex].enemySpeedX = autoScroll;
    basicE[enemyIndex].enemySpeedY = 0;
    basicE[enemyIndex].enemyType = type;
    basicE[enemyIndex].enemyHitX = 180;
    basicE[enemyIndex].enemyHitY = 48;
    basicE[enemyIndex].enemyHP = 10 * enemyBalanceHP;
    basicE[enemyIndex].enemyHPMax = 10 * enemyBalanceHP;
  } else if (type == 4) {
    basicE[enemyIndex].enemyX = x;
    basicE[enemyIndex].enemyY = y;
    basicE[enemyIndex].enemySpeedX = autoScroll;
    basicE[enemyIndex].enemySpeedY = 0;
    basicE[enemyIndex].enemyType = type;
    basicE[enemyIndex].enemyHitX = 244;
    basicE[enemyIndex].enemyHitY = 92;
    basicE[enemyIndex].enemyHP = 100 * enemyBalanceHP;
    basicE[enemyIndex].enemyHPMax = 100 * enemyBalanceHP;
  } else if (type == 6) {
    basicE[enemyIndex].enemyX = x;
    basicE[enemyIndex].enemyY = y;
    basicE[enemyIndex].enemySpeedX = autoScroll;
    basicE[enemyIndex].enemySpeedY = 0;
    basicE[enemyIndex].enemyType = type;
    basicE[enemyIndex].enemyHitX = 160;
    basicE[enemyIndex].enemyHitY = 60;
    basicE[enemyIndex].enemyHP = 10 * enemyBalanceHP;
    basicE[enemyIndex].enemyHPMax = 10 * enemyBalanceHP;
  } else if (type == 7) {
    basicE[enemyIndex].enemyX = x;
    basicE[enemyIndex].enemyY = y;
    basicE[enemyIndex].enemySpeedX = autoScroll;
    basicE[enemyIndex].enemySpeedY = 0;
    basicE[enemyIndex].enemyType = type;
    basicE[enemyIndex].enemyHitX = 120;
    basicE[enemyIndex].enemyHitY = 52;
    basicE[enemyIndex].enemyHP = 20 * enemyBalanceHP;
    basicE[enemyIndex].enemyHPMax = 20 * enemyBalanceHP;
  } else if (type == 8) {
    basicE[enemyIndex].enemyX = x;
    basicE[enemyIndex].enemyY = y;
    basicE[enemyIndex].enemySpeedX = autoScroll;
    basicE[enemyIndex].enemySpeedY = 0;
    basicE[enemyIndex].enemyType = type;
    basicE[enemyIndex].enemyHitX = 240;
    basicE[enemyIndex].enemyHitY = 52;
    basicE[enemyIndex].enemyHP = 30 * enemyBalanceHP;
    basicE[enemyIndex].enemyHPMax = 30 * enemyBalanceHP;
  } else if (type == 9) {
    basicE[enemyIndex].enemyX = x;
    basicE[enemyIndex].enemyY = y;
    basicE[enemyIndex].enemySpeedX = autoScroll;
    basicE[enemyIndex].enemySpeedY = 0;
    basicE[enemyIndex].enemyType = type;
    basicE[enemyIndex].enemyHitX = 240;
    basicE[enemyIndex].enemyHitY = 52;
    basicE[enemyIndex].enemyHP = 30 * enemyBalanceHP;
    basicE[enemyIndex].enemyHPMax = 30 * enemyBalanceHP;
  }
}

void levelEditor() { //the level editor routine is here
  //render background
  if (levelType == 1) background(180, 248, 255);
     else if (levelType == 2) background(0);
     
  //render stars/clouds
  if (levelType == 2 || levelType == 1) {
    for (starsBG stars : stars) {
      stars.update();
      stars.display();
    }
  }
    
  //render and process enemies (enemies will fire once placed)
  for (enemy basicE : basicE) {
    basicE.update();
    basicE.shoot();
    basicE.display();
  }
    
  //render and process bullets
  for (bullet blts : blts) {
    blts.update();
    blts.display();
  }
    
  //render player hp and shield bars
  stroke(0);
  strokeWeight(15);
  fill(0);
  rect(20 * screenScaling, 650 * screenScaling, 200 * screenScaling, 50 * screenScaling, 10);
  rect(235 * screenScaling, 650 * screenScaling, 200 * screenScaling, 50 * screenScaling, 10);
  setRect(4);
  if (playerHP >= 0) rect(23 * screenScaling, 653.5 * screenScaling, ((195 * (playerHP / playerHPMax))) * screenScaling, 44 * screenScaling);
  setRect(5);
  rect(238 * screenScaling, 653.5 * screenScaling, ((194 * (playerShield / playerShieldMax))) * screenScaling, 44 * screenScaling);
  setRect(3); //render surrounds
  noFill();
  rect(20 * screenScaling, 650 * screenScaling, 200 * screenScaling, 50 * screenScaling, 10);
  rect(235 * screenScaling, 650 * screenScaling, 200 * screenScaling, 50 * screenScaling, 10);
  fill(0);
    
    
  //render weapon selector
  stroke(255);
  strokeWeight(2);
  rect(450 * screenScaling, 653 * screenScaling, 30 * screenScaling, 20 * screenScaling, 5);
  rect(450 * screenScaling, 678 * screenScaling, 30 * screenScaling, 20 * screenScaling, 5);
  rect(485 * screenScaling, 653 * screenScaling, 30 * screenScaling, 20 * screenScaling, 5);
  rect(485 * screenScaling, 678 * screenScaling, 30 * screenScaling, 20 * screenScaling, 5);      
    
  image(player1, (playerX - 5 - scrollX) * screenScaling, (playerY - 5) * screenScaling, 80 * screenScaling, 30 * screenScaling); //player sprite
  
  //draw enemies
  if (useControllerForCursor == false) {
    cursorY = mouseY / screenScaling;
    cursorX = mouseX / screenScaling;
  }
  tint(255, 100);
  image(player1, (playerX - 5) * screenScaling, (playerY - 5) * screenScaling, 80 * screenScaling, 30 * screenScaling); //player sprite faded (doesnt scroll)
  switch(levelEnemyTypeSelected) {
    case 0: //drone that fires a homing shot
    image(faun1, (cursorX - (100 / 2)) * screenScaling, (cursorY - (100 / 2)) * screenScaling, 100 * screenScaling, 100 * screenScaling);
    break;
    case 1: //small gunship
    image(faun2, (cursorX - (200 / 2)) * screenScaling, (cursorY - (76 / 2)) * screenScaling, 200 * screenScaling, 76 * screenScaling);
    break;
    case 2: //small interceptor (spread shot)
    image(faun3, (cursorX - (160 / 2)) * screenScaling, (cursorY - (60 / 2)) * screenScaling, 160 * screenScaling, 60 * screenScaling);
    break;
    case 3: //medium interceptor
    image(faun4, (cursorX - (180 / 2)) * screenScaling, (cursorY - (48 / 2)) * screenScaling, 180 * screenScaling, 48 * screenScaling);
    break;
    case 4: //cargo ship
    image(faun5, (cursorX - (244 / 2)) * screenScaling, (cursorY - (92 / 2)) * screenScaling, 244 * screenScaling, 92 * screenScaling);
    break;
    case 6: //small interceptor that does not fire until it reaches a certain part of the screen, then fires a homing shot
    image(faun3, (cursorX - (160 / 2)) * screenScaling, (cursorY - (70 / 2)) * screenScaling, 160 * screenScaling, 60 * screenScaling);
    break;
    case 7: //energy weapon that charges
    image(faun6, (cursorX - (120 / 2)) * screenScaling, (cursorY - (52 / 2)) * screenScaling, 120 * screenScaling, 52 * screenScaling);
    break;
    case 8: //enemy that charges then zooms across the screen
    image(faun7, (cursorX - (240 / 2)) * screenScaling, (cursorY - (52 / 2)) * screenScaling, 240 * screenScaling, 52 * screenScaling);
    break;
    case 9: //enemy that charges then zooms across the screen
    image(faun8, (cursorX - (240 / 2)) * screenScaling, (cursorY - (52 / 2)) * screenScaling, 240 * screenScaling, 52 * screenScaling);
    break;
    default:
    noStroke();
    fill(255, 0, 0);
    ellipse(cursorX * screenScaling, cursorY * screenScaling, 40 * screenScaling, 40 * screenScaling);
    break;
  }
  tint(255, 255, 255, 255);
    
  textSize(24 * screenScaling);
  fill(255, 20, 20);
  text("scrollX: " + scrollX, 1000 * screenScaling, 25 * screenScaling);
  text("cursorX: " + cursorX * screenScaling, 1000 * screenScaling, 50 * screenScaling);
  text("cursorY: " + cursorY * screenScaling, 1000 * screenScaling, 75 * screenScaling);
  text("enemyType: " + levelEnemyTypeSelected, 1000 * screenScaling, 100 * screenScaling);
  text("::CONTROLS::", 1000 * screenScaling, 125 * screenScaling);
  if (useControllerForCursor == true) {
    text("DPAD/RS-X = scroll screen", 1000 * screenScaling, 150 * screenScaling);
    text("A/Cross = place enemy", 1000 * screenScaling, 175 * screenScaling);
    text("B/Circle = undo", 1000 * screenScaling, 200 * screenScaling);
    text("Y/Triange = cycle enemies", 1000 * screenScaling, 225 * screenScaling);
    text("LB = load from file", 1000 * screenScaling, 250 * screenScaling);
    text("RB = save to file", 1000 * screenScaling, 275 * screenScaling);
    text("Start = playtest", 1000 * screenScaling, 300 * screenScaling);
    text("R3 = exit", 1000 * screenScaling, 325 * screenScaling);
    text("Press Back/Share to", 1000 * screenScaling, 350 * screenScaling);
    text("switch to mouse", 1000 * screenScaling, 375 * screenScaling);
  } else {
    text("LMB = place enemy", 1000 * screenScaling, 150 * screenScaling);
    text("MMB = reset enemies", 1000 * screenScaling, 175 * screenScaling);
    text("RMB = undo", 1000 * screenScaling, 200 * screenScaling);
    text("A/D scroll", 1000 * screenScaling, 225 * screenScaling);
    text("W/S fast scroll", 1000 * screenScaling, 250 * screenScaling);
    text("SPACE cycles enemy type", 1000 * screenScaling, 275 * screenScaling);
    text("P saves to level-editor-save.json", 950 * screenScaling, 300 * screenScaling);
    text("M exits to level select", 1000 * screenScaling, 325 * screenScaling);
    text("L loads the save file", 1000 * screenScaling, 350 * screenScaling);
    text("T tests the level", 1000 * screenScaling, 375 * screenScaling);
    text("Press Back/Share on", 1000 * screenScaling, 400 * screenScaling);
    text("controller to switch to", 1000 * screenScaling, 425 * screenScaling);
    text("controller", 1000 * screenScaling, 450 * screenScaling);
  }
}

void saveLevel() { //saves the level editor level
  levelEditorSaveJSON = new JSONArray();
  for(int i = 0; i < levelEnemyIndex; i++) { //repeat for all 
    JSONObject data = new JSONObject();
    data.setInt("id", i);
    data.setInt("enemyType", levelEnemyType[i]);
    data.setInt("enemyX", levelEnemyX[i]);
    data.setInt("enemyY", levelEnemyY[i]);
    levelEditorSaveJSON.setJSONObject(i, data);
  }
  saveJSONArray(levelEditorSaveJSON, "level-editor-save.json");
  text("saved to level-editor-save.json", 1000 * screenScaling, 250 * screenScaling);
}

void loadLevel() { //load a saved level editor level
  levelEditorSaveJSON = loadJSONArray("level-editor-save.json"); //load the array
  //JSONArray values = levelEditorSaveJSON.getJSONArray(0);
  levelEnemyIndex = 0; //reset the index
  for (int i = 0; i < levelEditorSaveJSON.size(); i++) {
    JSONObject item = levelEditorSaveJSON.getJSONObject(i);
    levelEnemyType[i] = item.getInt("enemyType");
    levelEnemyX[i] = item.getInt("enemyX");
    levelEnemyY[i] = item.getInt("enemyY");
    levelEnemyIndex++;
  }
  
  //reset player variables
  playerHP = playerHPMax;
  playerX = 200;
  playerY = 250;
  playerShield = 0;
  playerLives = 3;
  
  calculateStats();
  
  //redraw enemies
  initObjects(); //reset all enemies
  for(int i = 0; i < levelEnemyIndex; i++) {
        genEnemy(levelEnemyType[i], levelEnemyX[i], levelEnemyY[i]);
  }
}
