Code edit (10 edits merged)
Please save this source code
User prompt
on first tap, start backgroundmusic
Code edit (12 edits merged)
Please save this source code
User prompt
in ObstacleExploding._move_migrated please update rotation, so that it's always facing centerx,centery
Code edit (1 edits merged)
Please save this source code
Code edit (12 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: game.add is not a function' in or related to this line: 'game.add(self.parent);' Line Number: 301
Code edit (8 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: trailgraphics is not defined' in or related to this line: 'trailgraphics.tint = 0xff0000;' Line Number: 138
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: particles.destroy is not a function' in or related to this line: 'particles.destroy();' Line Number: 1101
Code edit (3 edits merged)
Please save this source code
User prompt
explosiontrails should explode in a circular pattern
Code edit (2 edits merged)
Please save this source code
User prompt
Instead of just flashing the screen on player death, make the fireball it is explode in a bunch of fading trails like fireworks
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: Point is not a constructor' in or related to this line: 'var globalPlayerPosition = player.toGlobal(new Point(0, 0));' Line Number: 307
User prompt
please factor into the lookatplayer and shootatplayer functions, that they should work in the global scope, because player and the turretobstacle can be children of different containers.
Code edit (2 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: speed is not defined' in or related to this line: 'turret.initialPosition(speed, angle, radius);' Line Number: 444
Code edit (1 edits merged)
Please save this source code
Code edit (20 edits merged)
Please save this source code
/**** * Classes ****/ /**** TODO: * Prøv at lave en exploding enemy. * Make turretshots lethal. (Or rework them - not good for gameplay now). * Try to think up a few more enemy types. Might need to slow difficulty progression down a bit to introduce them. * What if holding mouse down didn't just stall movement, but move player the other way? * Maybe give player 3 lives. * Sound & Music. * Would also be cool to be able to jump in AND out of orbits, but hard to implement. Or maybe just tap on the orbit to go to? ****/ var Collectible = Container.expand(function (i) { var self = Container.call(this); var particleGraphics = self.attachAsset('energyPill', { anchorX: 0.5, anchorY: 0.5 }); self.orbitSpeed; // = 0; // set by the orbit that spawns it. self.growing = Math.random() <= 0.5 ? true : false; self.radius; // = 0; self.initialPosition = function (radius, angle) { self.angle = angle; self.radius = radius; self.x = self.radius * Math.cos(self.angle); self.y = self.radius * Math.sin(self.angle); }; self._move_migrated = function () { /*if (self.parent) { self.radius = self.parent.width / 2 * (1900 / self.parent.width) - self.width / 2 * (100 / self.width); }*/ self.angle = (self.angle || 0) + self.orbitSpeed; self.angle %= Math.PI * 2; self.x = self.radius * Math.cos(self.angle); self.y = self.radius * Math.sin(self.angle); // Pulse effect if (self.growing) { if (self.scale.x < 1.1) { self.scale.x += 0.025; self.scale.y += 0.025; } else { self.growing = false; } } else { if (self.scale.x > 0.9) { self.scale.x -= 0.025; self.scale.y -= 0.025; } else { self.growing = true; } } }; }); var Dragon = Container.expand(function (head, index) { var self = Container.call(this); self.head = head; self.index = index; if (head == true) { var powerup1Graphics = self.attachAsset('powerup3', { anchorX: 0.5, anchorY: 0.5 }); } else { var powerup1Graphics = self.attachAsset('dragonTail', { anchorX: 0.5, anchorY: 0.5 }); } self.radius = 880; //self.angleSpeed = 0.01; //self.orbitSpeed = 0.075; self.orbitSpeed = 0.01; //0.055; self.initialPosition = function (angle) { self.angle = angle; self.x = self.radius * Math.cos(self.angle); self.y = self.radius * Math.sin(self.angle); }; self._move_migrated = function () { //self.radius = self.parent.width / 2 * (1900 / self.parent.width) - self.width / 2 * (100 / self.width) + 10; //self.radius = self.parent.width / 2 * (1900 / self.parent.width) - self.width / 2 * (100 / self.width) + 2; self.angle = (self.angle || 0) + self.orbitSpeed; self.x = self.radius * Math.cos(self.angle); self.y = self.radius * Math.sin(self.angle); //var sway = Math.cos((LK.ticks + self.index) % 100) * 2; //self.radius += sway; self.radius += Math.sin((LK.ticks + (self.index + 1) * 10) * 0.1) * 2; // Adjust radius for wavelike movement //self.rotation += 0.1; // If in the player's orbit. if (self.parent == orbits[currentOrbitIndex]) { if (LK.ticks % 15 == 0) { // Increase speed every 15 ticks. self.orbitSpeed += 0.0025; } } if (self.head) { self.parent.addChild(self); if (self.x < centerX) { //self.rotation = self.angle; } else { //self.rotation = self.angle / 2; } } }; }); var ExplosionTrail = Container.expand(function (x, y) { var self = Container.call(this); //var tint = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "#ffffff"; /*var trailGraphics = self.attachAsset('trail', { anchorX: 0.5, anchorY: 0.5 });*/ var trailGraphics = self.attachAsset('redExplosion', { anchorX: 0.5, anchorY: 0.5 }); trailGraphics.blendMode = 3; self.x = x; self.y = y; var angle = Math.random() * Math.PI * 2; var speed = Math.random() * 10; self.speedX = Math.cos(angle) * speed; self.speedY = Math.sin(angle) * speed; self.alpha = 1; self.update = function () { self.x += self.speedX; self.y += self.speedY; self.scale.x -= 0.015; self.scale.y -= 0.015; //self.alpha -= 0.01; //if (self.alpha <= 0) { if (self.scale.x <= 0) { self.destroy(); } }; }); var FloatingText = Container.expand(function (text, x, y) { var self = Container.call(this); var textLabel = new Text2(text, { size: 100, fill: "#8888ff", align: 'center', stroke: "#000000", strokeThickness: 5 }); textLabel.anchor.set(0.5, 0.5); textLabel.x = x; textLabel.y = y; self.addChild(textLabel); self.update = function () { textLabel.y -= 2; // Move the text up textLabel.alpha -= 0.02; // Fade out the text if (textLabel.alpha <= 0) { self.destroy(); } }; }); var GameOverScreen = Container.expand(function (orbitsJumped, energyCollected, finalScore) { var self = Container.call(this); var bgGraphics = self.attachAsset('gameoverBg', { anchorX: 0.5, anchorY: 0.5, alpha: 0.5 }); bgGraphics.width = 2048 - 700; bgGraphics.height = 600; bgGraphics.x = centerX; bgGraphics.y = centerY; var text = new Text2("Orbits jumped: ".concat(orbitsJumped, "\nEnergy collected: ").concat(energyCollected, "\nFinal score: (").concat(orbitsJumped, "+").concat(energyCollected, ") = ").concat(finalScore), { size: 100, fill: "#ffffff", align: 'center', stroke: "#000000", strokeThickness: 5 }); text.anchor.set(0.5, 0.5); text.x = 2048 / 2; text.y = 2732 / 2; self.addChild(text); self.update = function () { // No update logic needed for static game over screen }; }); // Obstacle class var Obstacle = Container.expand(function () { var self = Container.call(this); self.obstacleGraphics = self.attachAsset('obstacle', { anchorX: 0.5, anchorY: 0.5 }); self.orbitSpeed = 0; // This is set by the Orbit that instantiates this obstacle, so obstacles in same orbit have same speed. self.rotatingRight = Math.random() < 0.5 ? true : false; /*if (self.parent) { self.radius = self.parent.width / 2 * (1900 / self.parent.width) - self.width / 2; }*/ self.radius = 0; self.initialPosition = function (speed, angle, radius) { self.angle = angle; self.orbitSpeed = speed; self.radius = radius; self.x = self.radius * Math.cos(self.angle); self.y = self.radius * Math.sin(self.angle); if (speed == 0) { self.obstacleGraphics.destroy(); self.obstacleGraphics = self.attachAsset('staticObstacle', { anchorX: 0.5, anchorY: 0.5 }); } }; self._move_migrated = function () { //self.radius = self.parent.width / 2 * (1900 / self.parent.width) - self.width / 2 * (100 / self.width); //self.radius = self.parent.width / 2 * (1900 / self.parent.width) - self.width / 2; // * (100 / self.width); self.angle = (self.angle || 0) + self.orbitSpeed; self.angle %= Math.PI * 2; self.x = self.radius * Math.cos(self.angle); self.y = self.radius * Math.sin(self.angle); if (ENEMY_WOBBLE) { if (self.rotatingRight) { if (self.rotation < 0.15) { self.rotation += 0.05; } else { self.rotatingRight = false; } } else { if (self.rotation > -0.15) { self.rotation -= 0.05; } else { self.rotatingRight = true; } } } }; }); var ObstacleExploding = Container.expand(function () { var self = Container.call(this); self.obstacleGraphics = self.attachAsset('obstacleExploding', { anchorX: 0.5, anchorY: 0.5 }); self.exploding = false; self.orbitSpeed = 0; // This is set by the Orbit that instantiates this obstacle, so obstacles in same orbit have same speed. self.rotatingRight = Math.random() < 0.5 ? true : false; self.radius = 0; self.initialPosition = function (speed, angle, radius) { self.angle = angle; self.orbitSpeed = speed; self.radius = radius; self.x = self.radius * Math.cos(self.angle); self.y = self.radius * Math.sin(self.angle); }; self._move_migrated = function () { self.angle = (self.angle || 0) + self.orbitSpeed; self.angle %= Math.PI * 2; self.x = self.radius * Math.cos(self.angle); self.y = self.radius * Math.sin(self.angle); self.rotation = Math.atan2(centerX - self.x, centerY - self.y); if (self.parent == orbits[currentOrbitIndex]) { //self.exploding = true; self.parent.addFragment(self.angle, self.orbitSpeed); self.parent.addFragment(self.angle, self.orbitSpeed * -1); for (var i = 0; i < 10; i++) { var angle = i / 10 * Math.PI * 2; var trail = new ExplosionTrail(self.x + Math.cos(angle) * 5, self.y + Math.sin(angle) * 5); self.parent.addChild(trail); } self.destroy(); self._destroyed = true; } }; }); var ObstacleFragment = Container.expand(function () { var self = Container.call(this); self.obstacleGraphics = self.attachAsset('obstacleFragment', { anchorX: 0.5, anchorY: 0.5 }); self.orbitSpeed; self.rotatingRight; self.radius; // = 0; self.initialPosition = function (speed, angle, radius) { self.angle = angle; self.orbitSpeed = speed; self.radius = radius; self.x = self.radius * Math.cos(self.angle); self.y = self.radius * Math.sin(self.angle); if (speed < 0) { self.obstacleGraphics.rotation *= -1; } }; self._move_migrated = function () { self.angle = (self.angle || 0) + self.orbitSpeed; self.angle %= Math.PI * 2; self.x = self.radius * Math.cos(self.angle); self.y = self.radius * Math.sin(self.angle); }; }); var ObstacleSeeker = Container.expand(function () { var self = Container.call(this); self.obstacleGraphics = self.attachAsset('obstacleSeeker', { anchorX: 0.5, anchorY: 0.5 }); self.obstacleGraphics2 = self.attachAsset('obstacleSeeker2', { anchorX: 0.5, anchorY: 0.5 }); self.obstacleGraphics2.alpha = 0; self.orbitSpeed = 0; // This is set by the Orbit that instantiates this obstacle, so obstacles in same orbit have same speed. self.rotatingRight = Math.random() < 0.5 ? true : false; self.radius = 0; self.initialPosition = function (speed, angle, radius) { self.angle = angle; self.orbitSpeed = Math.max(0.01, speed); self.radius = radius; self.x = self.radius * Math.cos(self.angle); self.y = self.radius * Math.sin(self.angle); }; self.determineDirection = function () { // Is clockwise or counterclokwise shortest path to player? var playerAngle = Math.atan2(player.y - centerY, player.x - centerX); var angleDifference = playerAngle - self.angle; angleDifference = (angleDifference + Math.PI) % (2 * Math.PI) - Math.PI; // Normalize angle difference to [-π, π] if (angleDifference > 0) { self.orbitSpeed = Math.abs(self.orbitSpeed); } else { self.orbitSpeed = -Math.abs(self.orbitSpeed); } }; self._move_migrated = function () { self.determineDirection(); //only move if player is one the same orbit. if (self.parent == orbits[currentOrbitIndex]) { self.obstacleGraphics2.alpha = 1; self.obstacleGraphics.alpha = 0; self.angle = (self.angle || 0) + self.orbitSpeed; self.angle %= Math.PI * 2; self.x = self.radius * Math.cos(self.angle); self.y = self.radius * Math.sin(self.angle); if (ENEMY_WOBBLE) { if (self.rotatingRight) { if (self.rotation < 0.15) { self.rotation += 0.05; } else { self.rotatingRight = false; } } else { if (self.rotation > -0.15) { self.rotation -= 0.05; } else { self.rotatingRight = true; } } } } else { self.obstacleGraphics2.alpha = 0; self.obstacleGraphics.alpha = 1; } }; }); var ObstacleTurret = Container.expand(function () { var self = Container.call(this); self.obstacleGraphics = self.attachAsset('obstacleTurrets', { anchorX: 0.5, anchorY: 0.5 }); self.orbitSpeed = 0; // This is set by the Orbit that instantiates this obstacle, so obstacles in same orbit have same speed. self.rotatingRight = Math.random() < 0.5 ? true : false; self.radius = 0; self.initialPosition = function (speed, angle, radius) { self.angle = angle; self.orbitSpeed = speed; self.radius = radius; self.x = self.radius * Math.cos(self.angle); self.y = self.radius * Math.sin(self.angle); }; self.lookAtPlayer = function () { var playerAngle = Math.atan2(player.y - (self.y + self.parent.y), player.x - (self.x + self.parent.x)); self.rotation = playerAngle; }; self.shootAtPlayer = function () { var playerAngle = Math.atan2(player.y - (self.y + self.parent.y), player.x - (self.x + self.parent.x)); var turretShot = new Container(); var shotGraphics = turretShot.attachAsset('turretShot', { anchorX: 0.5, anchorY: 0.5 }); turretShot.dead = false; turretShot.x = (self.x + self.parent.x) / self.parent.scale.x; turretShot.y = (self.y + self.parent.y) / self.parent.scale.y; turretShot.rotation = playerAngle + Math.PI / 2; turretShot.speedX = Math.cos(playerAngle) * 10; turretShot.speedY = Math.sin(playerAngle) * 10; turretShot.update = function () { turretShot.x += turretShot.speedX; turretShot.y += turretShot.speedY; if (turretShot.x < 0 || turretShot.x > 2048 || turretShot.y < 0 || turretShot.y > 2732) { turretShot.dead = true; turretShot.destroy(); } }; game.addChild(turretShot); turretShots.push(turretShot); //obstacles.push(turretShot); }; self._move_migrated = function () { self.lookAtPlayer(); // Should only be true when player and turret in same layer. if (self.parent.scale.x == 1) { if (LK.ticks % 30 === 0) { // Shoot every 2 seconds (assuming 60 FPS) self.shootAtPlayer(); } } self.angle = (self.angle || 0) + self.orbitSpeed; self.angle %= Math.PI * 2; self.x = self.radius * Math.cos(self.angle); self.y = self.radius * Math.sin(self.angle); }; }); // Orbit class var Orbit = Container.expand(function () { var self = Container.call(this); var orbitGraphics = self.attachAsset('orbit1', { anchorX: 0.5, anchorY: 0.5, tint: rainbowColors[colorOffset % rainbowColors.length] }); orbitsCreated++; colorOffset++; orbitGraphics.alpha = 0.5; self.direction = Math.random() < 0.5 ? 1 : -1; self.positionOrbit = function (i) { // Set position and scale. self.x = centerX; self.y = centerY; self.width = self.height = 1900 - i * 500; self.barrierSpeed = maxEnemySpeed * Math.random() * self.direction; // First orbit is always empty. if (i == 0) { return; } // Determine contents of this orbit. // Every 17th orbit is reserved for a powerup. if (orbitsCreated % 17 == 0) { self.addCollectible(1); self.addPowerup(); return; } if (orbitsCreated > 50) { // Turret enemy possible. if (Math.random() < 0.1) { var amount = Math.ceil(Math.random() * 3); self.addCollectible(amount); for (var i = 0; i < amount; i++) { self.addObstacleTurret(); } return; } } if (orbitsCreated > 40) { // Dragon enemy possible. if (Math.random() < 0.1) { self.addCollectible(10); self.addDragon(); return; } } if (orbitsCreated > 30) { // Seeker enemy possible. if (Math.random() < 0.1) { self.addCollectible(1); for (var i = 0; i < 2; i++) { self.addSeekerObstacle(self.barrierSpeed, i); } return; } } if (orbitsCreated > 20) { // Static enemy possible if (Math.random() < 0.33) { self.addCollectible(1); self.numBarriers = Math.ceil(Math.random() * maxEnemiesPerOrbit); self.barrierSpeed = 0; // Setting speed to 0 makes the barrier the static type. for (var i = 0; i < this.numBarriers; i++) { self.addBarrier(self.barrierSpeed, i); } return; } } // Default case, spawn X normal enemies self.addCollectible(1); self.numBarriers = Math.ceil(Math.random() * maxEnemiesPerOrbit); for (var i = 0; i < this.numBarriers; i++) { //self.addBarrier(self.barrierSpeed, i); self.addObstacleExploding(self.barrierSpeed, i); } }; /* var orbitGraphicsMask = self.attachAsset('blackSphere', { anchorX: 0.5, anchorY: 0.5, tint: 0x000000 //tint: rainbowColors[(colorOffset + 1) % rainbowColors.length] }); orbitGraphicsMask.alpha = 0; orbitGraphicsMask.width = self.width - 200; orbitGraphicsMask.height = self.height - 200; */ self.addBarrier = function (speed, index) { var barrier = new Obstacle(); var angle = Math.random() * (Math.PI * 2); var radius = 880; barrier.initialPosition(speed, angle, radius); self.addChild(barrier); obstacles.push(barrier); }; self.addObstacleExploding = function (speed, index) { var barrier = new ObstacleExploding(); var angle = Math.random() * (Math.PI * 2); var radius = 880; barrier.initialPosition(speed, angle, radius); self.addChild(barrier); obstacles.push(barrier); }; self.addFragment = function (angle, speed) { var fragment = new ObstacleFragment(); var radius = 880; fragment.initialPosition(speed, angle, radius); self.addChild(fragment); obstacles.push(fragment); }; self.addSeekerObstacle = function (speed, index) { var seeker = new ObstacleSeeker(); var angle = Math.random() * (Math.PI * 2); var radius = 880; seeker.initialPosition(speed, angle, radius); self.addChild(seeker); obstacles.push(seeker); }; self.addDragon = function () { for (var i = 0; i < 10; i++) { var dragon = new Dragon(i == 0, i); var angle = Math.PI * 1.5 - i * 0.03; dragon.scale.x = 1 - (i + 1) * 0.075; //0.15 dragon.scale.y = 1 - (i + 1) * 0.075; dragon.initialPosition(angle); self.addChild(dragon); obstacles.push(dragon); } }; self.addObstacleTurret = function () { var turret = new ObstacleTurret(); var angle = Math.random() * (Math.PI * 2); var radius = 880; var speed = 0.01; // Define a default speed value turret.initialPosition(speed, angle, radius); self.addChild(turret); obstacles.push(turret); }; self.addPowerup = function () { for (var i = 0; i < 5; i++) { var powerup = new Powerup1(); var angle = Math.PI * 1.5 - i * 0.08; var radius = 880; powerup.scale.x = 1 - (i + 1) * 0.15; powerup.scale.y = 1 - (i + 1) * 0.15; powerup.initialPosition(angle, radius); self.addChild(powerup); obstacles.push(powerup); } }; self.addCollectible = function (num) { var angleOffset = Math.random() * (Math.PI * 2); for (var i = 0; i < num; i++) { var collectible = new Collectible(); collectible.orbitSpeed = 0.0005 * self.direction; var angle = 0.00001 + i * (Math.PI * 2 / num) + angleOffset; collectible.initialPosition(880, angle); self.addChild(collectible); obstacles.push(collectible); } }; }); var Particle = Container.expand(function (i) { var self = Container.call(this); var particleGraphics = self.attachAsset('particle', { anchorX: 0.5, anchorY: 0.5 }); self.id = i; //self.speed = 8; self.dead = false; particleGraphics.blendMode = 3; self.alpha = 0.75; self.rotation = Math.random() * Math.PI * 2; self.update = function () { if (scaling) { self.x = player.x; self.y = player.y; self.x += self.id * 3 * Math.cos(player.angle); self.y += self.id * 3 * Math.sin(player.angle); } self.alpha -= 0.001; self.scale.x -= 0.02; self.scale.y -= 0.02; if (LK.ticks % (self.id + 1) == 0 || self.scale.x < 0) { self.alpha = 0.75; self.scale.x = 1; self.scale.y = 1; self.y = player.y; // + Math.random() * player.height / 4; // + player.height / 2 + (Math.random() * 50 - 25); self.x = player.x; // + Math.random() * player.width / 4; // + (Math.random() * 50 - 25); } }; }); // Initialize player // Player class var Player = Container.expand(function () { var self = Container.call(this); var playerGraphics = self.attachAsset('player', { anchorX: 0.5, anchorY: 0.5 }); self.radius = 890; self.angle = 0; self.jump = function () { currentOrbitIndex++; var targetOrbit = orbits[currentOrbitIndex]; self.angle = Math.atan2(self.y - centerY, self.x - centerX); if (targetOrbit && currentOrbitIndex < orbits.length) { //self.radius = (targetOrbit.width - 100) / 2; self.radius = targetOrbit.width / 2; //console.log('self.radius after setting it to targetOrbits: ' + self.radius); } else { self.radius = 0; // Fallback radius if targetOrbit is not defined } self.x = centerX + self.radius * Math.cos(self.angle); self.y = centerY + self.radius * Math.sin(self.angle); game.setBackgroundColor(rainbowColors[(colorOffset + 4) % rainbowColors.length]); //self.scale.x = 0.70; //self.scale.y = 0.70; self.width = 70; self.height = self.width; scaling = true; LK.setScore(LK.getScore() + 1); scoreText.setText(LK.getScore()); /* var orbit = game.addChild(new Orbit()); orbit.positionOrbit(4); orbits.push(orbit); // Move player to the topmost z-index game.setChildIndex(player, game.children.length - 1); */ }; self._update_migrated = function () { //self.angleSpeed = 0.01; //self.angle = (self.angle || 0) + self.angleSpeed; self.angle = (self.angle || 0) + playerSpeed; self.x = centerX + self.radius * Math.cos(self.angle); self.y = centerY + self.radius * Math.sin(self.angle); }; }); // Powerup class var Powerup1 = Container.expand(function () { var self = Container.call(this); var powerup1Graphics = self.attachAsset('powerup2', { anchorX: 0.5, anchorY: 0.5 }); self.radius = 880; //self.angleSpeed = 0.01; //self.orbitSpeed = 0.075; self.orbitSpeed = 0.055; self.initialPosition = function (angle, radius) { self.angle = angle; //self.orbitSpeed = Math.max(0.01, speed); self.radius = radius; self.x = self.radius * Math.cos(self.angle); self.y = self.radius * Math.sin(self.angle); }; self._move_migrated = function () { //self.radius = self.parent.width / 2 * (1900 / self.parent.width) - self.width / 2 * (100 / self.width) + 10; //self.radius = self.parent.width / 2 * (1900 / self.parent.width) - self.width / 2 * (100 / self.width) + 2; self.angle = (self.angle || 0) + self.orbitSpeed; self.x = self.radius * Math.cos(self.angle); self.y = self.radius * Math.sin(self.angle); self.rotation += 0.1; }; }); var Sparkle = Container.expand(function () { var self = Container.call(this); var obstacleGraphics = self.attachAsset('sparkle', { anchorX: 0.5, anchorY: 0.5 //tint: Math.floor(Math.random() * 16777215) // Add random tint }); //self.angleSpeed = 0.01; self.angle = 0; self.orbitSpeed = (0.5 - Math.random() * 1) * 0.2; //-0.01; self.radius = 0; self.spread = Math.random() * 6 + 1; self.centerX = 2048 / 2; self.centerY = 2720 / 2; self.moveAround = function () { // Obstacle move logic //var angleSpeed = -0.01 * self.parent.direction; //self.orbitSpeed; //self.radius = self.parent.width / 2 - self.width / 2; //self.radius = self.parent.width / 2 * (1900 / self.parent.width) - self.width / 2 * (100 / self.width); self.angle = (self.angle || 0) + self.orbitSpeed; self.angle %= Math.PI * 2; var oldX = self.x; var oldY = self.y; self.x = self.centerX + self.radius * Math.cos(self.angle); self.y = self.centerY + self.radius * Math.sin(self.angle); /* // Create a trail effect if (LK.ticks % 3 == 0) { var trail = LK.getAsset('trail', { x: oldX, y: oldY, width: 4, height: 4, anchorX: 0.5, anchorY: 0.5 //tint: Math.floor(Math.random() * 16777215) // Add random tint }); game.addChild(trail); //trails.push(trail); // Fade out and remove the trail after a short duration LK.setTimeout(function () { game.removeChild(trail); }, 50); } */ if (true || Math.random() < 0.9) { self.radius += self.spread; } //self.radius += 2 + Math.sin(LK.ticks % 20); if (self.x > 2060 || self.x < -2060 || self.y < -60 || self.y > 2800) { self.x = self.centerX; self.y = self.centerY; self.angle = 0; self.orbitSpeed = (0.5 - Math.random() * 1) * 0.2; //-0.01; self.radius = 0; self.spread = Math.random() * 10 + 1; game.addChild(self); } }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x444488 // Init game with black background }); /**** * Game Code ****/ var centerX = 2048 / 2; var centerY = 2732 / 2; var ENEMY_WOBBLE = false; var PARTICLES_ON = true; var SPARKLES_ON = true; var INCREASE_DIFFICULTY_EVERY_X_LEVELS = 15; var GAME_ENDED = false; var maxEnemiesPerOrbit = 2; var player; var playerSpeed = 0.005; //0.01; var maxEnemySpeed = 0.01; var collectiblesCollected = 0; var orbits = []; var obstacles = []; var turretShots = []; var currentOrbitIndex = 0; var scaling = false; var scalingCounter = 0; var scalingSpeed = 50; var scalingTarget = 500; var powerupText; var stalling = false; var powerup1Activated = false; var numColors = 18; var orbitsCreated = 0; //Math.floor(Math.random() * numColors); var colorOffset = Math.floor(Math.random() * numColors); var rainbowColors = function () { var colors = []; for (var i = 0; i < numColors; i++) { var hue = i * (360 / numColors) % 360; colors.push(hsvToHex(hue / 360, 1, 1)); } return colors; }(); var fullscreenBackground = LK.getAsset('fullscreenBackground', { anchorX: 0.507, anchorY: 0.46, x: 2048 / 2, y: 2732 / 2, alpha: 0.5 }); game.addChild(fullscreenBackground); function hsvToHex(h, s, v) { var r, g, b, i, f, p, q, t; i = Math.floor(h * 6); f = h * 6 - i; p = v * (1 - s); q = v * (1 - f * s); t = v * (1 - (1 - f) * s); switch (i % 6) { case 0: r = v, g = t, b = p; break; case 1: r = q, g = v, b = p; break; case 2: r = p, g = v, b = t; break; case 3: r = p, g = q, b = v; break; case 4: r = t, g = p, b = v; break; case 5: r = v, g = p, b = q; break; } var toHex = function toHex(x) { var hex = Math.round(x * 255).toString(16); return hex.length === 1 ? '0' + hex : hex; }; return '0x' + toHex(r) + toHex(g) + toHex(b); } //console.log(rainbowColors); // A for our purposes optimized hitdetection, based on orbit layer and angle. var radIntersects = function radIntersects(p, t) { if (t.parent == orbits[currentOrbitIndex]) { var pa = (p.angle * (180 / Math.PI) + 180) % 360; var ta = (t.angle * (180 / Math.PI) + 180) % 360; if (Math.abs(pa - ta) < 6) { return true; } else { return false; } } else { return false; } }; var showPowerupText = function showPowerupText() { powerupText = new Text2('Powerup Activated!\nAll visible obstacles cleared!\nTap to continue', { size: 100, fill: "#bbbbbb", align: 'center', stroke: "#000000", strokeThickness: 10 }); powerupText.y = 2700 / 2; powerupText.x = 2048 / 2; powerupText.anchor.set(0.5, 0.5); //instructionText.x = 2048 / 2; // Center horizontally //instructionText.y = 2732 - instructionText.height / 2; // Position at the bottom game.addChild(powerupText); LK.setTimeout(function () { var fadeDuration = 4000; var fadeStep = 30; var fadeInterval = fadeDuration / fadeStep; var currentStep = 0; var fadeOutInterval = LK.setInterval(function () { if (powerupText) { powerupText.alpha -= 1 / fadeStep; } currentStep++; if (currentStep >= fadeStep) { LK.clearInterval(fadeOutInterval); game.removeChild(powerupText); powerupText = null; } }, fadeInterval); }, 0); }; // Initialize assets used in this game. // Game variables var scoreText = new Text2('0', { size: 150, align: 'center', fill: "#ffffff", stroke: "#000000", strokeThickness: 20, anchorX: 0.5 }); LK.gui.top.addChild(scoreText); scoreText.x -= 40; // Initialize orbits function createOrbits() { for (var i = 0; i < 5; i++) { var orbit = game.addChild(new Orbit()); orbit.positionOrbit(i); orbits.push(orbit); } } createOrbits(); // Add instruction text at the bottom of the screen var instructionText = new Text2('Tap and release to jump to the next orbit.\nCollect blue energy and Don\'t hit the red obstacles.', { size: 50, fill: "#bbbbbb", align: 'center', strokeThickness: 10 }); instructionText.y = 163; instructionText.x = 50; instructionText.anchor.set(0.5, 0); //instructionText.x = 2048 / 2; // Center horizontally //instructionText.y = 2732 - instructionText.height / 2; // Position at the bottom LK.gui.top.addChild(instructionText); //game.setBackgroundColor(rainbowColors[7] + 0xdddddd); var playerLayer = new Container(); //player = game.addChild(new Player()); player = playerLayer.addChild(new Player()); game.addChild(playerLayer); var particles = []; if (PARTICLES_ON) { var particleContainer = new Container(); //game.addChild(particleContainer); playerLayer.addChild(particleContainer); // Initialize particles array //var particles = []; // Create particles for (var i = 0; i < 40; i++) { var particle = new Particle(i); particle.x = player.x; particle.y = player.y; // + player.height * 3; particleContainer.addChild(particle); particles.push(particle); } } var sparkles = []; if (SPARKLES_ON) { for (var i = 0; i < 50; i++) { var sparkle = game.addChild(new Sparkle()); //sparkles.positionOrbit(i); sparkles.push(sparkle); } } //player.x = 2048 / 2; //player.y = 2732 / 2 - 200; // Start the player 200px above the center /* console.log('Player radius is now: ' + player.radius); console.log('Orbits.length is now: ' + orbits.length); console.log('CurrentOrbitIndex is now: ' + currentOrbitIndex); console.log('width of currentorbit is now: ' + orbits[currentOrbitIndex].width); */ function increaseDifficulty() { if (maxEnemiesPerOrbit < 8) { maxEnemiesPerOrbit++; } maxEnemySpeed += 0.001; playerSpeed += 0.001; } // Game logic game.on('down', function (x, y, obj) { if (!GAME_ENDED) { if (!stalling) { stalling = true; } } }); game.on('up', function (x, y, obj) { if (!GAME_ENDED) { if (powerupText) { game.removeChild(powerupText); powerupText = null; } if (!scaling) { player.jump(currentOrbitIndex); LK.gui.top.removeChild(instructionText); if (orbitsCreated % INCREASE_DIFFICULTY_EVERY_X_LEVELS == 0) { //maxEnemiesPerOrbit++; //maxEnemySpeed += 0.002; increaseDifficulty(); } } if (stalling) { stalling = false; } } }); LK.on('tick', function () { if (!GAME_ENDED) { if (!stalling) { player._update_migrated(); } var t; if (powerup1Activated) { powerup1Activated = false; for (var i = obstacles.length - 1; i > 0; i--) { t = obstacles[i]; if (t instanceof Collectible == false) { t.destroy(); t._destroyed = true; } } } if (scaling) { scalingCounter++; for (var i = 0; i < orbits.length; i++) { t = orbits[i]; t.width += scalingSpeed; t.height += scalingSpeed; //player.radius += scalingSpeed * 0.1; } //player.radius = orbits[currentOrbitIndex].width / 2 - 50; if (currentOrbitIndex < orbits.length && orbits[currentOrbitIndex]) { player.radius = orbits[currentOrbitIndex].width / 2 - 65; } if (player.width < 100) { player.width += 0.3; player.height = player.width; } //player.scale.x = player.scale.y = if (scalingCounter == scalingTarget / scalingSpeed) { scaling = false; scalingCounter = 0; var orbit = game.addChild(new Orbit()); orbit.positionOrbit(4); orbits.push(orbit); //game.setChildIndex(player, game.children.length - 1); game.setChildIndex(playerLayer, game.children.length - 1); player.width = 100; player.height = 100; //game.setBackgroundColor(rainbowColors[(10 + currentOrbitIndex) % 15] + 0xdddddd); /* console.log('Player radius is now: ' + player.radius); console.log('Orbits.length is now: ' + orbits.length); console.log('CurrentOrbitIndex is now: ' + currentOrbitIndex); console.log('width of currentorbit is now: ' + orbits[currentOrbitIndex].width); */ } } // Update orbits for (var i = orbits.length - 1; i >= 0; i--) { //orbits[i].positionOrbit(i); var orb = orbits[i]; //if (orb && orb.width > 2700) { if (orb && orb.width > 3500) { for (var j = 0; j < orb.children.length; j++) { t = orb.children[j]; if (t instanceof Obstacle || t instanceof Powerup1) { // child is an instance of these, do something with it t._destroyed = true; } } //orbits[i].destroy(); orb.destroy(); // Splice alters jump logic, so alter currentTargetOrbit too. orbits.splice(i, 1); currentOrbitIndex--; } } // Update obstacles for (var i = obstacles.length - 1; i >= 0; i--) { t = obstacles[i]; //if (obstacles[i] && !obstacles[i]._destroyed) { if (t && !t._destroyed) { //obstacles[i]._move_migrated(); t._move_migrated(); //if (player.intersects(obstacles[i])) { //if (radIntersects(player, obstacles[i])) { if (radIntersects(player, t)) { //var t = obstacles[i]; //console.log('collision occurred: (obstacle:', t.radius, t.angle % (Math.PI * 2), ') , (player: ', player.radius, player.angle % (Math.PI * 2)); //var ta = (t.angle * (180 / Math.PI) + 180) % 360; //var pa = (player.angle * (180 / Math.PI) + 180) % 360; //console.log(ta, pa); //if (radIntersects(player, obstacles[i], 100)) { //if (obstacles[i] instanceof Powerup1) { if (t instanceof Powerup1) { //obstacles[i].destroy(); t.destroy(); //obstacles[i]._destroyed = true; t._destroyed = true; if (!powerup1Activated) { LK.effects.flashScreen(0xffffff, 1000); //LK.effects.flashScreen(rainbowColors[Math.floor(Math.random() * numColors)], 1000); powerup1Activated = true; showPowerupText(); } } else if (t instanceof Collectible) { t.destroy(); t._destroyed = true; collectiblesCollected++; var floatingText = new FloatingText("+1", player.x, player.y); game.addChild(floatingText); } else { player.visible = false; for (var i = particles.length - 1; i >= 0; i--) { particles[i].destroy(); } particles = []; for (var i = 0; i < 30; i++) { var angle = i / 30 * Math.PI * 2; var trail = new ExplosionTrail(player.x + Math.cos(angle) * 10, player.y + Math.sin(angle) * 10); game.addChild(trail); } var orbitsJumped = LK.getScore(); var energyCollected = collectiblesCollected; var finalScore = orbitsJumped + energyCollected; LK.setScore(finalScore); var gameOverScreen = new GameOverScreen(orbitsJumped, energyCollected, finalScore); game.addChild(gameOverScreen); GAME_ENDED = true; LK.setTimeout(function () { LK.showGameOver(); }, 6000); break; } } } else { obstacles.splice(i, 1); //console.log('obstacles.length is now: ' + obstacles.length); } } // Update turretshots for (var i = turretShots.length - 1; i >= 0; i--) { t = turretShots[i]; //if (obstacles[i] && !obstacles[i]._destroyed) { if (t.dead == true) { t.destroy(); turretShots.splice(i, 1); } } if (PARTICLES_ON && particles && particles.length > 0) { for (var i = particles.length - 1; i >= 0; i--) { particles[i].update(); } } if (SPARKLES_ON && sparkles && sparkles.length > 0) { for (var i = sparkles.length - 1; i > 0; i--) { if (sparkles[i] && !sparkles[i]._destroyed) { sparkles[i].moveAround(); } else { //sparkles.splice(i, 1); } } } for (var i = game.children.length - 1; i >= 0; i--) { if (game.children[i] instanceof ExplosionTrail) { game.children[i].update(); } } } });
===================================================================
--- original.js
+++ change.js
@@ -253,9 +253,9 @@
self.angle = (self.angle || 0) + self.orbitSpeed;
self.angle %= Math.PI * 2;
self.x = self.radius * Math.cos(self.angle);
self.y = self.radius * Math.sin(self.angle);
- self.rotation = Math.atan2(centerY - self.y, centerX - self.x);
+ self.rotation = Math.atan2(centerX - self.x, centerY - self.y);
if (self.parent == orbits[currentOrbitIndex]) {
//self.exploding = true;
self.parent.addFragment(self.angle, self.orbitSpeed);
self.parent.addFragment(self.angle, self.orbitSpeed * -1);
Make the circle completely black on all pixels.
A white star. Flat vector art.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
The line-color should be white, and the circle a bit thinner.
a wonderful but not very dense starfield. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A glowing blue comic energy orb. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
I'd like a top down image of a super fine and thin white empty cicular band on a transparent background. It should be flatly white and with no other details, and of course perfectly round with blank space in the center. The band's width should be less than one percent of the width of the circle itself, as if a 1 cm band were laid out in a circle with a diameter of 100 cm. Single Game Texture. In-Game asset. 2d. Blank background.