Code edit (1 edits merged)
Please save this source code
User prompt
Alpha does not seem to change inShotIndicator when I fire a bullet
User prompt
On test for currentShots and decrease shots when I tap the screen, not when any bullets are fired
User prompt
The shots indicator does not seem to show in the top right corner
User prompt
Fix Bug: 'TypeError: undefined is not an object (evaluating 'self.shotIndicator.resetShots')' in this line: 'self.shotIndicator.resetShots();' Line Number: 92
User prompt
Add shots indicators in the top right corner
User prompt
Elements should wrap around the screen if they fly off in any direction
User prompt
Make fade and scale be more explosion like
User prompt
Make elements fade out twice as fast
User prompt
Make elements also increase scale as they fade out
User prompt
Fix Bug: 'Timeout.tick error: Can't find variable: elements' in this line: 'elements.splice(elements.indexOf(self), 1);' Line Number: 27
User prompt
As soon as an element is hit, remove it from the elements areeay
User prompt
Make elements that where hit fade our
User prompt
When hit make elements fade out
User prompt
Rather than just being removed elements that where hit should fade out
User prompt
Bullets no longer seem to intersect elements please fix this
User prompt
Elements seem to move faster if there are more bullets on the screen. They should always move at the same speed
User prompt
In tick method, in game at the bottom also call tick for each element
User prompt
In tick, at the bottom also tick each element
User prompt
Elements do not seem to move please fix this
User prompt
Using tick, make hexagons move in a random hexagonal direction
User prompt
Add a tick function to elements
User prompt
Make bullets twice as fast
User prompt
In tick When a bullet and an element is hit, destroy the element and trigger the fire hexagon methid
User prompt
Remove the element hit method
var Bullet = Container.expand(function () { var self = Container.call(this); var bulletGraphics = self.createAsset('bullet', 'Bullet Graphics', .5, .5); self.speed = 10; self.tick = function () { if (!self.initialized) { self.rotationSpeed = -Math.PI / 60; self.rotationTicks = 30; self.initialized = true; } if (self.rotationTicks > 0) { bulletGraphics.rotation += self.rotationSpeed; self.rotationTicks--; } self.x += Math.cos(self.rotation) * self.speed; self.y += Math.sin(self.rotation) * self.speed; }; }); var HexagonElement = Container.expand(function () { var self = Container.call(this); self.fadeOut = function () { var fadeOutInterval = LK.setInterval(function () { elementGraphics.alpha -= 0.05; elementGraphics.scale.x += 0.05; elementGraphics.scale.y += 0.05; if (elementGraphics.alpha <= 0) { LK.clearInterval(fadeOutInterval); self.destroy(); } }, 10); }; var elementGraphics = self.createAsset('element', 'Element Graphics', .5, .5); var directions = [{ x: 1, y: 0 }, { x: -1, y: 0 }, { x: 0.5, y: Math.sqrt(3) / 2 }, { x: -0.5, y: Math.sqrt(3) / 2 }, { x: 0.5, y: -Math.sqrt(3) / 2 }, { x: -0.5, y: -Math.sqrt(3) / 2 }]; var chosenDirection = directions[Math.floor(Math.random() * directions.length)]; self.speed = 2; self.tick = function () { self.x = (self.x + chosenDirection.x * self.speed + 2048) % 2048; self.y = (self.y + chosenDirection.y * self.speed + 2732) % 2732; }; }); var Game = Container.expand(function () { var self = Container.call(this); var bullets = []; var elements = []; function startNextLevel() { bullets.forEach(function (bullet) { bullet.destroy(); }); bullets = []; elements.forEach(function (element) { element.destroy(); }); elements = []; for (var i = 0; i < 10; i++) { var hexagonElement = new HexagonElement(); hexagonElement.x = Math.random() * 2048; hexagonElement.y = Math.random() * 2732; elements.push(hexagonElement); self.addChild(hexagonElement); } } self.startNextLevel = startNextLevel; startNextLevel(); self.fireBulletsHexagon = function (position) { var directions = [{ x: 1, y: 0 }, { x: -1, y: 0 }, { x: 0.5, y: Math.sqrt(3) / 2 }, { x: -0.5, y: Math.sqrt(3) / 2 }, { x: 0.5, y: -Math.sqrt(3) / 2 }, { x: -0.5, y: -Math.sqrt(3) / 2 }]; directions.forEach(function (direction, index) { var bullet = new Bullet(); bullet.x = position.x; bullet.y = position.y; bullet.rotation = Math.atan2(direction.y, direction.x); bullets.push(bullet); self.addChild(bullet); }); }; stage.on('down', function (obj) { var event = obj.event; var pos = event.getLocalPosition(self); self.fireBulletsHexagon(pos); }); LK.on('tick', function () { for (var i = bullets.length - 1; i >= 0; i--) { bullets[i].tick(); for (var j = elements.length - 1; j >= 0; j--) { if (bullets[i].intersects(elements[j])) { var pos = { x: elements[j].x, y: elements[j].y }; elements[j].fadeOut(); elements.splice(j, 1); self.fireBulletsHexagon(pos); break; } } if (bullets[i].x < 0 || bullets[i].x > 2048 || bullets[i].y < 0 || bullets[i].y > 2732) { bullets[i].destroy(); bullets.splice(i, 1); } } for (var j = 0; j < elements.length; j++) { elements[j].tick(); } }); });
===================================================================
--- original.js
+++ change.js
@@ -51,10 +51,10 @@
}];
var chosenDirection = directions[Math.floor(Math.random() * directions.length)];
self.speed = 2;
self.tick = function () {
- self.x += chosenDirection.x * self.speed;
- self.y += chosenDirection.y * self.speed;
+ self.x = (self.x + chosenDirection.x * self.speed + 2048) % 2048;
+ self.y = (self.y + chosenDirection.y * self.speed + 2732) % 2732;
};
});
var Game = Container.expand(function () {
var self = Container.call(this);
Hexagon target Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Single White Hexagon, soft edges, simple, vector. Round corners. All white. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Amazing bright hexagon space background.
Triangle plasma bullet. Glowing. Pointing down. Dark outline. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
White triangle Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Single Bright light particle, white. Simple, vector. Triangle. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.