diff --git a/javascript/newsim.js b/javascript/newsim.js index 52af4a6..f00604f 100644 --- a/javascript/newsim.js +++ b/javascript/newsim.js @@ -92,7 +92,7 @@ function createEntity(x, y, vx, vy, ax, ay, rot, rotv, type, id=0, iframes=Math. function getRandomType(){ let rand = Math.random(); if (rand > 0.955){ - console.log("Comet made"); + if(Settings.devMode) console.log("Comet made"); return entityTypes.COMET; }if(rand > 0.4){ return entityTypes.METERORITE_SMALL; @@ -192,7 +192,7 @@ function setup(){ worldScale = createSlider(); //Load Entities - for(var i = 0; i <= entityCount; i+=1){ + for(var i = 0; i <= Settings.entityCount; i+=1){ createEntity( Math.floor(Math.random() * windowWidth), //X Location Math.floor(Math.random() * windowHeight), //Y Location @@ -201,7 +201,7 @@ function setup(){ 0.0, //X Acceleration 0.0, //Y Acceleration 0.0, //Current Rotation - (Math.random() * 2 *(Math.PI / rotationSpeed))-(Math.PI / rotationSpeed), //Rotation Velocity + (Math.random() * 2 *(Math.PI / Settings.rotationSpeed))-(Math.PI / Settings.rotationSpeed), //Rotation Velocity getRandomType(), id=i ); @@ -247,6 +247,23 @@ function draw(){ //Draw Entity drawEntity(entity); } + if (Settings.respawn){ + if(Settings.emptyEntries.length > 5){ + if(frameCount % 20 == 0){ + createEntity( + Math.floor(Math.random() * windowWidth)+windowHeight, //X Location + Math.floor(Math.random() * windowHeight)+windowHeight, //Y Location + (Math.random() * maxSpeed * 2)-maxSpeed, //X Velocity + (Math.random() * maxSpeed * 2)-maxSpeed, //Y Velocity + 0.0, //X Acceleration + 0.0, //Y Acceleration + 0.0, //Current Rotation + (Math.random() * 2 *(Math.PI / rotationSpeed))-(Math.PI / rotationSpeed), //Rotation Velocity + getRandomType() + ); + } + } + } } function windowResized() {