diff --git a/libs/bluepixle.js b/libs/bluepixle.js index 392b3c9..cff6272 100644 --- a/libs/bluepixle.js +++ b/libs/bluepixle.js @@ -236,78 +236,3 @@ class frameBuffer { } } - -class starfield { - constructor (buffer,boundWidth,boundHeight,centerX,centerY,starCount,starLife,starSpeed) { - //Validate things - this.centerX = centerX; - this.centerY = centerY; - this.starLife = starLife; - this.starSpeed = starSpeed; - //Math the things - this.topBound = centerY - (boundHeight/2); - this.bottomBound = centerY + (boundHeight/2); - this.leftBound = centerX - (boundWidth/2); - this.rightBound = centerX + (boundWidth/2); - this.stars = []; - this.container = buffer.addContainer( - new container(this.centerX,this.centerY,0,0,0)); - this.container.nestContainer(); - for (var count = 1; count <= starCount; count++) { - var star = this.container.addShape( - new shape( - "rect", - ((Math.random()*boundWidth)-(boundWidth/2)), - ((Math.random()*boundHeight)-(boundHeight/2)), - 1,1, - "#ffffff", - "#ffffff", - 1)); - this.stars.push({ - "container":star, - "life":this.starLife, - "speed":this.starSpeed}); - } - } - - forward() { - var me = this; - this.stars.forEach(function (star) { - if ( - (star.life > 0) & - (star.container.shape.x > me.leftBound - me.centerX) & - (star.container.shape.x < me.rightBound - me.centerX) & - (star.container.shape.y > me.topBound - me.centerY) & - (star.container.shape.y < me.bottomBound - me.centerY)) { - var xOffset = star.container.shape.x; - var yOffset = star.container.shape.y; - star.life--; - var c = 255*((me.starLife-star.life)/me.starLife)*4; - star.container.grow(5/me.starLife); - star.container.shape.fColor = "rgb("+c+","+c+","+c+")"; - star.container.shape.bColor = "rgb("+c+","+c+","+c+")"; - star.speed+=me.starSpeed; - star.container.shape.x += - star.speed*((xOffset/me.centerX)*0.5); - star.container.shape.y += - star.speed*((yOffset/me.centerY)*0.5); - } else { - star.container.x = 0; - star.container.y = 0; - star.life = me.starLife; - star.speed = me.starSpeed; - star.container.shape.sizeX = 1; - star.container.shape.sizeY = 1; - star.container.shape.fColor = "rgb(0,0,0)"; - star.container.shape.bColor = "rgb(0,0,0)"; - star.container.shape.x = - (Math.random()*(me.rightBound-me.leftBound)) - -(me.centerX); - star.container.shape.y = - (Math.random()*(me.bottomBound-me.topBound)) - -(me.centerY); - } - }); - } -} -