User prompt
Fix Bug: 'Can't find variable: Fish2' in this line: 'var fish = new Fish2();' Line Number: 142
User prompt
Fix Bug: 'ReferenceError: Can't find variable: Fish2' in this line: 'var fish = new Fish2();' Line Number: 142
User prompt
Fix Bug: 'TypeError: fishes[i].pushAway is not a function. (In 'fishes[i].pushAway(urchin)', 'fishes[i].pushAway' is undefined)' in this line: 'fishes[i].pushAway(urchin);' Line Number: 180
User prompt
Fix Bug: 'TypeError: fishes[i].pushAway is not a function. (In 'fishes[i].pushAway(urchin)', 'fishes[i].pushAway' is undefined)' in this line: 'fishes[i].pushAway(urchin);' Line Number: 180
User prompt
Make both fish and fish2 be pushed away by urchin expand
User prompt
Make fish and fish2 two separate variables
User prompt
Fix Bug: 'ReferenceError: Can't find variable: Fish' in this line: 'var fish = new Fish();' Line Number: 120
User prompt
Spawn both fish and fish 2 at game start
User prompt
Fish2 only swims right to left on the screen
User prompt
Fix Bug: 'ReferenceError: Can't find variable: Fish' in this line: 'var newFish = new Fish();' Line Number: 167
User prompt
Duplicate fish icon as fish2
User prompt
When fish are swimming left, flip fish icon horizontally
User prompt
Change bubbles to have no effect on urchin
User prompt
Fish swim towards urchin
User prompt
Increase speed fish are pushed off screen
User prompt
Instead of destroy fish. Touching urchin while expanded pushes fish off screen. Once fish off screen, destroy fish.
User prompt
Urchin starts game with 1 bubble power.
User prompt
Fix Bug: 'TypeError: undefined is not an object (evaluating 'bubbleMeter.currentPower')' in this line: 'var expansion = Math.min(this.scale.x + bubbleMeter.currentPower, 5);' Line Number: 55
User prompt
Bubbles refill urchin bubble power. 1 bubble lets urchin do regular expand. 2 bubbles lets urchin expand x2 and so on.
User prompt
Fix Bug: 'TypeError: undefined is not an object (evaluating 'self.bubbles.length')' in this line: 'for (var i = self.bubbles.length - 1; i >= 0; i--) {' Line Number: 76
User prompt
Fix issues cited above
User prompt
Bubbles float in zig zag pattern from bottom screen to top of screen
User prompt
Fix Bug: 'TypeError: undefined is not an object (evaluating 'bubbleMeter.currentPower')' in this line: 'if (bubbleMeter.currentPower > 0) {' Line Number: 51
User prompt
Fix Bug: 'TypeError: undefined is not an object (evaluating 'bubbleMeter.x = 0')' in this line: 'bubbleMeter.x = 0;' Line Number: 96
User prompt
Fix Bug: 'TypeError: undefined is not an object (evaluating 'bubbleMeter.currentPower')' in this line: 'if (bubbleMeter.currentPower > 0) {' Line Number: 51
var Bubble = Container.expand(function () { var self = Container.call(this); var bubbleGraphics = self.createAsset('bubble', 'Bubble collectible', .5, .5); self.direction = Math.random() < 0.5 ? -1 : 1; self.amplitude = Math.random() * 5 + 5; self.frequency = Math.random() * 0.05 + 0.05; self.on('tick', function () { self.x += Math.sin(LK.ticks * self.frequency) * self.amplitude * self.direction; self.y -= 2; if (self.y < -self.height / 2) { self.destroy(); } }); return self; }); var BubbleMeter = Container.expand(function () { var self = Container.call(this); var meterGraphics = self.createAsset('bubbleMeter', 'Bubble Meter', 0, 0.5); self.maxPower = 100; self.currentPower = 1; self.decreaseRate = 1; self.recoveryRate = 0.5; self.update = function (urchin) { if (urchin.scale.x > 1 && self.currentPower > 0) { self.currentPower -= self.decreaseRate; } else if (self.currentPower < self.maxPower) { self.currentPower += self.recoveryRate; } meterGraphics.scale.x = self.currentPower / self.maxPower; if (meterGraphics.texture && meterGraphics.texture.width) { meterGraphics.width = self.currentPower / self.maxPower * meterGraphics.texture.width; } }; self.reset = function () { self.currentPower = 1; }; return self; }); var Urchin = Container.expand(function () { var self = Container.call(this); var urchinGraphics = self.createAsset('urchinWithSpikes', 'Urchin character with spikes', .5, .5); self.health = 5; self.speed = 5; self.move = function (deltaX, deltaY) { var inertia = 0.95; var maxSpeed = 5; this.vx = (this.vx || 0) * inertia + deltaX * 0.05; this.vy = (this.vy || 0) * inertia + deltaY * 0.05; this.vx = Math.sign(this.vx) * Math.min(Math.abs(this.vx), maxSpeed); this.vy = Math.sign(this.vy) * Math.min(Math.abs(this.vy), maxSpeed); this.x += this.vx; this.y += this.vy; }; self.push = function (bubbleMeter) { if (bubbleMeter) { var expansion = Math.min(this.scale.x + bubbleMeter.currentPower, 5); this.scale.set(expansion); bubbleMeter.currentPower = 0; } }; }); var Fish = Container.expand(function () { var self = Container.call(this); Fish.prototype.pushAway = function (urchin) { this.pushed = true; this.pushDirection = { x: this.x - urchin.x, y: this.y - urchin.y }; var pushMagnitude = Math.sqrt(this.pushDirection.x * this.pushDirection.x + this.pushDirection.y * this.pushDirection.y); this.pushDirection.x /= pushMagnitude; this.pushDirection.y /= pushMagnitude; }; var fishGraphics = self.createAsset('fish', 'Fish character', .5, .5); self.speed = 3; self.move = function (urchinX, urchinY) { var dx = urchinX - this.x; var dy = urchinY - this.y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance < 500) { this.x += this.speed * (dx > 0 ? 1 : -1); this.y += this.speed * (dy > 0 ? 1 : -1); } }; }); var BubbleSpawner = Container.expand(function () { var self = Container.call(this); self.bubbles = []; self.bubbles = []; self.spawnBubble = function () { if (Math.random() < 0.05 && self.bubbles.length < 3) { var newBubble = new Bubble(); newBubble.x = Math.random() * 2048; newBubble.y = 2732; self.bubbles.push(newBubble); LK.stage.addChild(newBubble); } }; LK.on('tick', self.spawnBubble); return self; }); var Game = Container.expand(function () { var self = Container.call(this); var bubbleSpawner = self.addChild(new BubbleSpawner()); var background = self.createAsset('background', 'Game background', 0.5, 0.5); background.alpha = 0.5; background.x = 2048 / 2; background.y = 2732 / 2; self.addChildAt(background, 0); LK.stageContainer.setBackgroundColor(0x000000); var urchin = self.addChild(new Urchin()); var bubbleMeter = self.addChild(new BubbleMeter()); bubbleMeter.x = 0; bubbleMeter.y = 2732 - bubbleMeter.height / 2; LK.gui.bottomLeft.addChild(bubbleMeter); var fishes = []; var scoreTxt = new Text2('0', { size: 150, fill: "#ffffff" }); LK.gui.topCenter.addChild(scoreTxt); urchin.x = 2048 / 2; urchin.y = 2732 / 2; var dragNode = null; stage.on('down', function (obj) { var event = obj.event; var pos = event.getLocalPosition(self); var distance = Math.sqrt(Math.pow(pos.x - urchin.x, 2) + Math.pow(pos.y - urchin.y, 2)); if (distance > urchin.width / 2 && bubbleMeter && bubbleMeter.currentPower > 0) { urchin.push(bubbleMeter); } else { dragNode = urchin; } }); function handleMove(obj) { var event = obj.event; var pos = event.getLocalPosition(self); if (dragNode) { dragNode.x = pos.x; dragNode.y = pos.y; } } stage.on('move', handleMove); stage.on('up', function (obj) { dragNode = null; urchin.scale.set(1); bubbleMeter.currentPower = 0; }); LK.on('tick', function () { urchin.move(); bubbleMeter.update(urchin); for (var i = 0; i < fishes.length; i++) { fishes[i].move(urchin.x, urchin.y); if (urchin.intersects(fishes[i])) { if (urchin.scale.x === 1) { urchin.health -= 1; if (urchin.health <= 0) {} } else { fishes[i].pushAway(urchin); } scoreTxt.text = (Number(scoreTxt.text) + 1).toString(); } } if (Math.random() < 0.01 && fishes.length < 20) { var newFish = new Fish(); var side = Math.floor(Math.random() * 4); var targetX, targetY; switch (side) { case 0: newFish.x = -100; newFish.y = Math.random() * 2732; targetX = 2048 + 100; targetY = newFish.y; break; case 1: newFish.x = Math.random() * 2048; newFish.y = -100; targetX = newFish.x; targetY = 2732 + 100; break; case 2: newFish.x = 2048 + 100; newFish.y = Math.random() * 2732; targetX = -100; targetY = newFish.y; break; case 3: newFish.x = Math.random() * 2048; newFish.y = 2732 + 100; targetX = newFish.x; targetY = -100; break; } newFish.move = function () { if (this.pushed) { this.x += this.pushDirection.x * 20; this.y += this.pushDirection.y * 20; if (this.x < -100 || this.x > 2148 || this.y < -100 || this.y > 2832) { this.destroy(); } } else { var dx = targetX - this.x; var dy = targetY - this.y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance > 0) { var angle = Math.atan2(dy, dx); this.x += Math.cos(angle) * this.speed; this.y += Math.sin(angle) * this.speed; } } }; fishes.push(newFish); self.addChild(newFish); } }); });
===================================================================
--- original.js
+++ change.js
@@ -85,15 +85,8 @@
});
var BubbleSpawner = Container.expand(function () {
var self = Container.call(this);
self.bubbles = [];
- for (var i = self.bubbles.length - 1; i >= 0; i--) {
- if (urchin.intersects(self.bubbles[i])) {
- bubbleMeter.currentPower = Math.min(bubbleMeter.currentPower + 1, bubbleMeter.maxPower);
- self.bubbles[i].destroy();
- self.bubbles.splice(i, 1);
- }
- }
self.bubbles = [];
self.spawnBubble = function () {
if (Math.random() < 0.05 && self.bubbles.length < 3) {
var newBubble = new Bubble();
Sea urchin, cartoon, spiny, long spines, grumpy face, no shadow Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Fish, cartoon Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
underwater, ocean, anime landscape Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Bubble, opaque, cartoon Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A tender morsel of delicious plankton. cartoon, shiny, no background. bright orange and yellow shrimp. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Game start sign. cartoon, shiny, underwater theme. "START GAME". Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
game success graphic, surprised cartoon shiny words, "WOW!". Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.