Code edit (5 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: soundFireCrackling is undefined' in or related to this line: 'soundFireCrackling.volume = volume;' Line Number: 438
User prompt
Please fix the bug: 'ReferenceError: volume is not defined' in or related to this line: 'soundFireCrackling.volume = volume;' Line Number: 438
Code edit (1 edits merged)
Please save this source code
User prompt
Add a slightly transparent black tinted shapeBox to the firewall. It should have a width of 2 * GAME_WIDTH, a height of 2 * GAME_HEIGHT and an anchor of 1,1
Code edit (2 edits merged)
Please save this source code
User prompt
In the game.update function add an empty if statement, checking if the tick counter is at 10s
Code edit (2 edits merged)
Please save this source code
User prompt
In the game.update method, play the backgroundAmbient sound every 10s
Code edit (1 edits merged)
Please save this source code
User prompt
backgroundAmbient should loop
User prompt
loop the backgroundAmbient sound on game start
Code edit (3 edits merged)
Please save this source code
User prompt
When calling game over also play the frogDeath sound effect
User prompt
When calling game over, also flash the screen red
Code edit (9 edits merged)
Please save this source code
User prompt
add a game.update function that checks if the frogs y position is greater than 0 or it's x position is less than the firewall's x position and call game over
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
Code edit (1 edits merged)
Please save this source code
Code edit (17 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: childInstance is undefined' in or related to this line: 'childInstance.x += x;' Line Number: 234
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: self is undefined' in or related to this line: 'self.shift = function (x, y) {' Line Number: 348
===================================================================
--- original.js
+++ change.js
@@ -142,15 +142,16 @@
var perpendicularAcceleration = PLAYER_GRAVITY * Math.sin(angle + Math.PI / 2);
angularVelocity += perpendicularAcceleration / hookLength;
// Update the frog's rotation and position
velocityAngle += angularVelocity;
- self.x = hookedObj.x + hookLength * Math.cos(velocityAngle);
- self.y = hookedObj.y + hookLength * Math.sin(velocityAngle);
+ velocityX = hookedObj.x + hookLength * Math.cos(velocityAngle) - self.x;
+ velocityY = hookedObj.y + hookLength * Math.sin(velocityAngle) - self.y;
+ console.log(velocityX, velocityY);
+ camera.shift(velocityX, velocityY);
self.rotation = Math.atan2(self.y - hookedObj.y, self.x - hookedObj.x) + Math.PI;
} else {
velocityY += PLAYER_GRAVITY;
- self.x += velocityX;
- self.y += velocityY;
+ camera.shift(velocityX, velocityY);
}
}
};
;
@@ -200,14 +201,19 @@
};
return self;
});
var Camera = ConfigContainer.expand(function (config) {
- var self = ConfigContainer.call(this);
+ var self = ConfigContainer.call(this, config);
var zoom = 1.0;
self.shift = function (x, y) {
for (var i = 0; i < self.children.length; i++) {
- self.children[i].x += x;
+ var childContainer = self.children[i];
+ for (var j = 0; j < childContainer.children.length; j++) {
+ var childInstance = childContainer.children[j];
+ childInstance.x += x;
+ }
}
+ foreground.x += x / 2;
frog.y += y;
};
self.update = function () {
self.scale.set(zoom);
@@ -279,21 +285,24 @@
var camera = game.addChild(new Camera({
x: GAME_WIDTH / 2,
y: GAME_HEIGHT
}));
+// Camera containers
var hookContainer = camera.addChild(new Container());
var lillypadContainer = camera.addChild(new Container());
var pickupContainer = camera.addChild(new Container());
+var forefrontContainer = camera.addChild(new Container());
+// Camera instances
var defaultPad = lillypadContainer.addChild(new Lilypad({
x: PLAYER_START_X,
y: PLAYER_START_Y
}));
-var frog = camera.addChild(new Frog({
+var frog = forefrontContainer.addChild(new Frog({
rotation: Math.PI / 2,
x: PLAYER_START_X,
y: PLAYER_START_Y
}));
-var firewall = camera.addChild(new Firewall({
+var firewall = forefrontContainer.addChild(new Firewall({
x: FIREWALL_START_X,
columns: 10
}));
var targetHook = hookContainer.addChild(new Hook({
@@ -321,11 +330,5 @@
if (paused) {
paused = false;
defaultPad.destroy();
}
-};
-self.shift = function (x, y) {
- for (var i = 0; i < self.children.length; i++) {
- self.children[i].x += x;
- }
- frog.y += y;
};
\ No newline at end of file
fireCrackle
Sound effect
frogTongue
Sound effect
frogDeath
Sound effect
lilypadBounce
Sound effect
noTarget
Sound effect
backgroundAmbient
Sound effect
fireCrackling1
Sound effect
fireCrackling2
Sound effect
fireCrackling3
Sound effect
fireCrackling4
Sound effect
frogBounce
Sound effect
pickupCaught
Sound effect