Code edit (4 edits merged)
Please save this source code
User prompt
change the interface text colours to black
Code edit (8 edits merged)
Please save this source code
User prompt
Instead of adding the gameInterface to the game, add it to the middle GUI element
User prompt
Add an Interface class that contains a score (displaying only the score value) and a multiplier below (displayed as the numerical rounded to 1 decimal place, and an "x", eg: "1.0x").
Code edit (1 edits merged)
Please save this source code
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
===================================================================
--- original.js
+++ change.js
@@ -159,8 +159,9 @@
var Foreground = ConfigContainer.expand(function (config) {
var self = ConfigContainer.call(this, config);
config = config || {};
var tint = config.tint !== undefined ? config.tint : 0xFFFFFF;
+ var offset = config.offset !== undefined ? config.offset : 0;
var coverage = config.coverage !== undefined ? config.coverage : 0;
var covered = 0;
var segmentWidth = 0;
var flipX = -1;
@@ -179,22 +180,17 @@
anchorY: 1.0,
scaleX: -flipX,
tint: tint
});
- console.log({
- x: foregroundRight.x,
- anchorX: foregroundRight.anchor.x,
- scaleX: foregroundRight.scale.x
- });
covered += segmentWidth || (segmentWidth = foregroundRight.width + foregroundLeft.width);
flipX *= -1;
} while (covered < coverage);
;
self.update = function () {
- if (self.x <= -segmentWidth * scaleX) {
+ if (self.x <= -(segmentWidth + offset) * scaleX) {
self.x += segmentWidth * scaleX;
}
- if (self.x >= segmentWidth * scaleX) {
+ if (self.x >= (segmentWidth + offset) * scaleX) {
self.x -= segmentWidth * scaleX;
}
};
;
@@ -284,8 +280,9 @@
var FIREWALL_OFFSET = 0.7;
var FIREWALL_SPEED = 0; // 2;
var FIREWALL_SPEED_INC = 0; // 0.1 / GAME_TICKS;
var FIREWALL_START_X = -GAME_WIDTH / 2;
+var FIREWALL_SOUND_COUNT = 4;
var FIREWALL_SOUND_DIVDIST = 1000;
;
// Lilypad Settings
var LILYPAD_ANGLE = 10 * Math.PI / 180;
@@ -305,18 +302,19 @@
var PLAYER_SCREEN_MARGIN = 1.25;
;
// Other Settings
var MOON_SCALING = 0.25;
+var FOREGROUND_OFFSET_X = 200;
var FOREGROUND_COVERAGE = 6 * GAME_WIDTH;
var FOREGROUND_SCALE = 1.0;
+var SHADOWGROUND_OFFSET_X = 200;
+var SHADOWGROUND_OFFSET_Y = 100;
var SHADOWGROUND_SCALE = 0.65;
-var SHADOWGROUND_OFFSET = 200;
;
//==============================================================================
// Game Instances & Variables
//==============================================================================
;
-var soundBackgroundAmbient, soundFireCrackling;
var paused = true;
var gameOver = false;
var background = game.addChild(LK.getAsset('background', {
anchorX: 0.5,
@@ -341,16 +339,16 @@
var pickupContainer = camera.addChild(new Container());
var forefrontContainer = camera.addChild(new Container());
// Foreground instances
var shadowground = foregroundContainer.addChild(new Foreground({
- x: PLAYER_START_X,
- y: -SHADOWGROUND_OFFSET,
+ x: PLAYER_START_X + SHADOWGROUND_OFFSET_X,
+ y: SHADOWGROUND_OFFSET_Y,
tint: 0x111111,
coverage: FOREGROUND_COVERAGE,
scale: SHADOWGROUND_SCALE
}));
var foreground = foregroundContainer.addChild(new Foreground({
- x: PLAYER_START_X,
+ x: PLAYER_START_X + FOREGROUND_OFFSET_X,
tint: 0x808080,
coverage: FOREGROUND_COVERAGE,
scale: FOREGROUND_SCALE
}));
@@ -398,20 +396,24 @@
game.update = function () {
if (gameOver) {
LK.showGameOver();
}
+ // Dynamically loop the fire crackling effect based on distance
+ if (LK.ticks % (GAME_TICKS * 1) === 0) {
+ var distance = frog.x - firewall.x;
+ var volume = Math.pow(1 + distance / FIREWALL_SOUND_DIVDIST, -1);
+ var index = Math.floor(volume * 5);
+ if (index) {
+ LK.getSound('fireCrackling' + index).play();
+ }
+ }
+ // Loop the background music
if (LK.ticks % (GAME_TICKS * 10) === 0) {
- soundFireCrackling = LK.getSound('fireCrackling').play();
- soundBackgroundAmbient = LK.getSound('backgroundAmbient').play();
+ LK.getSound('backgroundAmbient').play();
}
+ // Game over conditions
if (frog.y > 0 || frog.x < firewall.x) {
LK.effects.flashScreen(0xff0000, 1000);
LK.getSound('frogDeath').play();
gameOver = true;
}
- // Update fireCrackling sound
- var distance = frog.x - firewall.x;
- var volume = Math.pow(1 + distance / FIREWALL_SOUND_DIVDIST, -1);
- if (soundFireCrackling) {
- soundFireCrackling.volume = volume;
- }
};
\ 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