User prompt
Bubble spawn at the bottom of the screen and float the top of the screen. When bubbles reached top of screen destroy bubbles. Limit bubbles no more than three on screen.
User prompt
Using urchins expand move uses one bubble power point. Vin must collect bubbles replenish bubble order to use expand move
User prompt
Give urchin underwater physics for kovement
User prompt
Fix Bug: 'TypeError: undefined is not an object (evaluating 'bubbleMeter.x = 0')' in this line: 'bubbleMeter.x = 0;' Line Number: 54
User prompt
Ensure bubble meter is displayed in front of the background
User prompt
Display bubble meter at bottom left
User prompt
Fix Bug: 'TypeError: undefined is not an object (evaluating 'meterGraphics.texture.width')' in this line: 'meterGraphics.width = self.currentPower / self.maxPower * meterGraphics.texture.width;' Line Number: 15
User prompt
Fix Bug: 'TypeError: undefined is not an object (evaluating 'meterGraphics.texture.width')' in this line: 'meterGraphics.width = self.currentPower / self.maxPower * meterGraphics.texture.width;' Line Number: 15
User prompt
Bubble meter shrinks and grows in size depending on bubble power. urchin starts with 1 bubble power
User prompt
Fix Bug: 'ReferenceError: Can't find variable: urchin' in this line: 'if (urchin.scale.x > 1 && self.currentPower > 0) {' Line Number: 9
User prompt
Fix Bug: 'ReferenceError: Can't find variable: urchin' in this line: 'if (urchin.scale.x > 1 && self.currentPower > 0) {' Line Number: 9
User prompt
Expanding uses bubble power. Create bubble meter to show remaining bubble power
User prompt
Fish do not move left
User prompt
Change fish movement. Fish can move up, down, and right only.
User prompt
Reduced background opacity by 50%
User prompt
Center background
User prompt
Fix Bug: 'TypeError: scoreTxt.getText is not a function. (In 'scoreTxt.getText()', 'scoreTxt.getText' is undefined)' in this line: 'scoreTxt.setText((Number(scoreTxt.getText()) + 1).toString());' Line Number: 77
User prompt
Rewrite code as suggested in above
User prompt
Fix Bug: 'TypeError: parseInt is not a function. (In 'parseInt(scoreTxt.text, 10)', 'parseInt' is undefined)' in this line: 'scoreTxt.text = (parseInt(scoreTxt.text, 10) + 1).toString();' Line Number: 77
User prompt
Fix Bug: 'TypeError: parseInt is not a function. (In 'parseInt(scoreTxt.text)', 'parseInt' is undefined)' in this line: 'scoreTxt.text = (parseInt(scoreTxt.text) + 1).toString();' Line Number: 77
User prompt
Change the code so this error stops happening repeatedly: typeerror:%20scoreTxt.getText%20is%20not%20a%20function.%20(In%20'scoreTxt.getText()',%20'scoreTxt.getText'%20is%20undefined)'%20in%20this%20line%3A%20'scoreTxt.setText((parseInt(scoreTxt.getText())%20+%201).toString());'%20Line%20Number%3A%2077%0A
User prompt
Fix Bug: 'TypeError: parseInt is not a function. (In 'parseInt(scoreTxt.text, 10)', 'parseInt' is undefined)' in this line: 'scoreTxt.setText((parseInt(scoreTxt.text, 10) + 1).toString());' Line Number: 101
User prompt
Fix Bug: 'TypeError: scoreTxt.getText is not a function' in this line: 'scoreTxt.setText((parseInt(scoreTxt.getText(), 10) + 1).toString());' Line Number: 101
User prompt
Fix Bug: 'TypeError: parseInt is not a function' in this line: 'scoreTxt.setText((parseInt(scoreTxt.text, 10) + 1).toString());' Line Number: 101
User prompt
Fix Bug: 'TypeError: scoreTxt.getText is not a function' in this line: 'scoreTxt.setText((parseInt(scoreTxt.getText(), 10) + 1).toString());' Line Number: 101
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 () {}; self.push = function () {}; }); var Fish = Container.expand(function () { var self = Container.call(this); 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) { var angle = Math.atan2(dy, dx); var moveX = Math.cos(angle) * this.speed; this.x += moveX; this.y += Math.sin(angle) * this.speed; fishGraphics.scale.x = moveX > 0 ? -1 : 1; } }; }); var Game = Container.expand(function () { var self = Container.call(this); var background = self.createAsset('background', 'Game background', 0, 0); self.addChildAt(background, 0); LK.stageContainer.setBackgroundColor(0x000000); var urchin = self.addChild(new Urchin()); 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) { urchin.scale.set(1.5); } 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; if (urchin.scale.x > 1) urchin.scale.set(1); }); LK.on('tick', function () { urchin.move(); 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 { urchin.push(); } fishes[i].destroy(); fishes.splice(i, 1); scoreTxt.text = (parseInt(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 () { 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
@@ -1,9 +1,4 @@
-var Bubble = Container.expand(function () {
- var self = Container.call(this);
- var bubbleGraphics = self.createAsset('bubble', 'Bubble asset', .5, .5);
- self.duration = 3000;
-});
var Urchin = Container.expand(function () {
var self = Container.call(this);
var urchinGraphics = self.createAsset('urchinWithSpikes', 'Urchin character with spikes', .5, .5);
self.health = 5;
@@ -18,9 +13,9 @@
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 && distance > this.width / 2 + urchin.width / 2) {
+ if (distance < 500) {
var angle = Math.atan2(dy, dx);
var moveX = Math.cos(angle) * this.speed;
this.x += moveX;
this.y += Math.sin(angle) * this.speed;
@@ -30,10 +25,8 @@
});
var Game = Container.expand(function () {
var self = Container.call(this);
var background = self.createAsset('background', 'Game background', 0, 0);
- background.width = LK.stageContainer.width;
- background.height = LK.stageContainer.height;
self.addChildAt(background, 0);
LK.stageContainer.setBackgroundColor(0x000000);
var urchin = self.addChild(new Urchin());
var fishes = [];
@@ -48,23 +41,11 @@
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));
- var bubbles = self.children.filter(function (child) {
- return child instanceof Bubble;
- });
- for (var i = 0; i < bubbles.length; i++) {
- if (bubbles[i].intersects(urchin)) {
- urchin.scale.set(2);
- (function (urchinRef, bubbleDuration) {
- LK.setTimeout(function () {
- urchinRef.scale.set(1);
- }, bubbleDuration);
- })(urchin, bubbles[i].duration);
- bubbles[i].destroy();
- }
- }
if (distance > urchin.width / 2) {
+ urchin.scale.set(1.5);
+ } else {
dragNode = urchin;
}
});
function handleMove(obj) {
@@ -81,33 +62,22 @@
if (urchin.scale.x > 1) urchin.scale.set(1);
});
LK.on('tick', function () {
urchin.move();
- var fishesCopy = fishes.slice();
- for (var i = 0; i < fishesCopy.length; i++) {
- var fish = fishesCopy[i];
- fish.move(urchin.x, urchin.y);
- if (urchin.intersects(fish)) {
+ 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 {
- fish.destroy();
- fishes.splice(fishes.indexOf(fish), 1);
- scoreTxt.text = (parseInt(scoreTxt.text, 10) + 1).toString();
- continue;
+ urchin.push();
}
- fish.destroy();
- fishes.splice(fishes.indexOf(fish), 1);
- scoreTxt.setText((parseInt(scoreTxt.text) + 1).toString());
+ fishes[i].destroy();
+ fishes.splice(i, 1);
+ scoreTxt.text = (parseInt(scoreTxt.text) + 1).toString();
}
}
- if (Math.random() < 0.02) {
- var newBubble = new Bubble();
- newBubble.x = Math.random() * 2048;
- newBubble.y = -100;
- self.addChild(newBubble);
- }
if (Math.random() < 0.01 && fishes.length < 20) {
var newFish = new Fish();
var side = Math.floor(Math.random() * 4);
var targetX, targetY;
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.