js/render.js
// Add the player and enemies to the scene
Add the player and enemies to the scene
Add the player and enemies to the scene
function initEntities() {
  player = new Player();
  scene.add(player.mesh);
  controls.target = player.position;
  let shooter;
  let makeShooters = function(coords, inactive) {
    for (let c of coords) {
      shooter = new Shooter(c[0], c[1], PLAYER_Z);
      if (inactive) {
        shooter.deactivate();
        inactiveShooters.push(shooter);
      }
      scene.add(shooter.mesh);
      entities.push(shooter);
    }
  }
  let stages = {
    "intro" : [
      [1100, 1200],
      [1500, 1200],
      [1300, 800],
      [1700, 800],
    ],
    "stage2": [
      [1350, 150],
      [1350, 200],
      [1350, 250],
      [2700, 450],
      [2700, 500],
      [2700, 550],
    ],
    "stage3": [
      [1650, -1650],
      [1650, -1750]
    ],
    "ambush": [
      [2600, -1000],
      [3100, -1000],
      [2600, -1200],
      [3100, -1200],
      [2850, -1000]
    ]
  }
  for (let stage in stages) {
    let inactive = (stage === "ambush");
    let coords = stages[stage];
    makeShooters(coords, inactive);
  }
}
function initEntities ( ) { player = new Player ( ) ; scene . add ( player . mesh ) ; controls . target = player . position ; let shooter ; let makeShooters = function ( coords , inactive ) { for ( let c of coords ) { shooter = new Shooter ( c [ 0 ] , c [ 1 ] , PLAYER_Z ) ; if ( inactive ) { shooter . deactivate ( ) ; inactiveShooters . push ( shooter ) ; } scene . add ( shooter . mesh ) ; entities . push ( shooter ) ; } } let stages = { "intro" : [ [ 1100 , 1200 ] , [ 1500 , 1200 ] , [ 1300 , 800 ] , [ 1700 , 800 ] , ] , "stage2" : [ [ 1350 , 150 ] , [ 1350 , 200 ] , [ 1350 , 250 ] , [ 2700 , 450 ] , [ 2700 , 500 ] , [ 2700 , 550 ] , ] , "stage3" : [ [ 1650 , - 1650 ] , [ 1650 , - 1750 ] ] , "ambush" : [ [ 2600 , - 1000 ] , [ 3100 , - 1000 ] , [ 2600 , - 1200 ] , [ 3100 , - 1200 ] , [ 2850 , - 1000 ] ] } for ( let stage in stages ) { let inactive = ( stage === "ambush" ) ; let coords = stages [ stage ] ; makeShooters ( coords , inactive ) ; } }
Add the player and enemies to the scene
Add the player and enemies to the scene
// Add a playable cube to the scene // entities.push(player); // NOTE: The player should not be included in the entities array // Add 4 intro shooters // If the shooters are inactive, disable them // Initialize shooters