Why are you creating new values for the three variables if they are not being passed to the constructor?myX = Math.random() * 200 - 99;//star starts in a small square myY = Math.random() * 200 - 99;//in the center myLayer = Math.random() * 3;//random layer stars[index] = new Star();//fill array with stars