User prompt
Rename the global `PLAYER_TONGUE_RANGE` to `PLAYER_TONGUE_RANGE_MAX` and update all its usages. Add a new global under `PLAYER_TONGUE_RANGE_MAX` called `PLAYER_TONGUE_RANGE_MIN`
Code edit (1 edits merged)
Please save this source code
User prompt
the hook should flip it's hook asset's scale.x every 5 to 10 frames
User prompt
Please fix the bug: 'ReferenceError: highlightContainer is not defined' in or related to this line: 'self.highlightContainer = highlightContainer;' Line Number: 183
User prompt
Remove the highlightContainer from the hook and instead attach directly to the highlight instance
User prompt
change the frog's "hookedObj" variable to be "self.hookedObj" instead, and update all references
Code edit (1 edits merged)
Please save this source code
User prompt
change the hook class's disableInterval to be a timeout instead
Code edit (1 edits merged)
Please save this source code
User prompt
Add a disable function to the hook class which sets it's "self.enabled" to false and tints it dark grey for HOOK_OFFLINE ticks, then reverts the changes
User prompt
Please fix the bug: 'TypeError: hookedObj.disable is not a function' in or related to this line: 'hookedObj.disable();' Line Number: 278
User prompt
In the frog release function, if hooked then call a new disable function on the hookedObj and then clear the variable
User prompt
hide the visibility of the frog's collision
Code edit (4 edits merged)
Please save this source code
User prompt
add a 50x50 shapeEllipse to the frog as the collision
Code edit (1 edits merged)
Please save this source code
Code edit (2 edits merged)
Please save this source code
User prompt
Create an empty Spawner class
Code edit (1 edits merged)
Please save this source code
Code edit (7 edits merged)
Please save this source code
User prompt
Add an update function to the hook class. If the hook's x position is less than the firewall's x position, destroy the hook
Code edit (1 edits merged)
Please save this source code
User prompt
after the `targetHook = closestHook;` line, check if the targethook is defined, if it is defined, add the highlight instance as a child to its highlightContainer, add the highlight as a child to the game instance, and hide it
Code edit (3 edits merged)
Please save this source code
User prompt
Inside the game.update function, iterate through the hookContainer's children and find the closest child to the frog within PLAYER_TONGUE_RANGE distance (use distance squared for comparison). The closest hook should be set as the targetHook, otherwise it should be set to undefined
===================================================================
--- original.js
+++ change.js
@@ -22,8 +22,22 @@
}
;
return self;
});
+var Spawner = ConfigContainer.expand(function (config) {
+ var self = ConfigContainer.call(this, config);
+ var spawnFunction = config.spawnFunction;
+ var positionFunction = config.positionFunction;
+ var margin = config.margin;
+ ;
+ self.update = function () {
+ while (self.x - frog.x < margin) {
+ self.x += positionFunction(self);
+ spawnFunction(self, self.x);
+ }
+ };
+ return self;
+});
var Pickup = ConfigContainer.expand(function (config) {
var self = ConfigContainer.call(this, config);
config = config || {};
var collectable = self.attachAsset('collectable', {
@@ -145,12 +159,13 @@
return self;
});
var Highlight = ConfigContainer.expand(function (config) {
var self = ConfigContainer.call(this, config);
- var highlight = self.attachAsset('highlight', {
+ self.addChild(new BorderedSymbol('highlight', {
anchorX: 0.5,
- anchorY: 0.5
- });
+ anchorY: 0.5,
+ weight: 4
+ }));
self.update = function () {
self.rotation += 0.01;
};
return self;
@@ -430,10 +445,81 @@
;
buildTextAssets(text);
return self;
});
-var Spawner = Container.expand(function () {
- var self = Container.call(this);
+/**
+* var config = {
+* x : Number || 0, // See: ConfigContainer
+* y : Number || 0, // See: ConfigContainer
+* rotation : Number || 0, // See: ConfigContainer
+* anchorX : Number || .5,
+* anchorY : Number || .5,
+* scale : Number || undefined,
+* scaleX : Number || scale,
+* scaleY : Number || scale,
+* weight : Number || TEXT_DEFAULT_WEIGHT,
+* width : Number || undefined, // Auto-calculated if left undefined and height is set
+* height : Number || undefined, // Auto-calculated if left undefined and width is set
+* tint : String || 0xFFFFFF, // Not tinted by default
+* border : String || TEXT_DEFAULT_BORDER,
+* }
+**/
+var BorderedSymbol = ConfigContainer.expand(function (symbol, config) {
+ var self = ConfigContainer.call(this, config);
+ config = config || {};
+ var width = config.width !== undefined ? config.width : undefined;
+ var height = config.height !== undefined ? config.height : undefined;
+ var scale = config.scale !== undefined ? config.scale : undefined;
+ var scaleX = config.scaleX !== undefined ? config.scaleX : scale;
+ var scaleY = config.scaleY !== undefined ? config.scaleX : scale;
+ var weight = config.weight !== undefined ? config.weight : TEXT_DEFAULT_WEIGHT;
+ var anchorX = config.anchorX !== undefined ? config.anchorX : .5;
+ var anchorY = config.anchorY !== undefined ? config.anchorY : .5;
+ var symbolTint = config.tint !== undefined ? config.tint : 0xFFFFFF;
+ var borderTint = config.border !== undefined ? config.border : TEXT_DEFAULT_BORDER;
+ var mainSymbol;
+ var symbolAssets = [];
+ ;
+ self.setSymbol = buildSymbolAssets;
+ self.setTint = setTint;
+ ;
+ function setTint(newTint) {
+ // NOTE: Tinting is currently broken (cannot use string)
+ // mainSymbol.tint = newTint;
+ // symbolConfig.tint = newTint
+ }
+ function buildSymbolAssets(newSymbol) {
+ for (var i = 0; i < TEXT_OFFSETS.length; i++) {
+ var main = i === TEXT_OFFSETS.length - 1;
+ var symbolAsset = symbolAssets[i];
+ if (symbolAsset) {
+ symbolAsset.destroy();
+ }
+ symbolAsset = self.attachAsset(newSymbol, {
+ // tint: main ? symbolTint : borderTint,
+ tint: main ? 0xFFFFFF : 0x000000,
+ // NOTE: Tinting is currently broken (cannot use string)
+ x: TEXT_OFFSETS[i][0] * weight,
+ y: TEXT_OFFSETS[i][1] * weight,
+ anchorX: anchorX,
+ anchorY: anchorY
+ });
+ if (width !== undefined && height === undefined) {
+ height = symbolAsset.height * (width / symbolAsset.width);
+ } else if (height !== undefined && width === undefined) {
+ width = symbolAsset.width * (height / symbolAsset.height);
+ }
+ symbolAsset.width = width;
+ symbolAsset.height = height;
+ if (scaleX !== undefined && scaleY !== undefined) {
+ symbolAsset.scale.set(scaleX, scaleY);
+ }
+ symbolAssets[i] = symbolAsset;
+ }
+ mainSymbol = symbolAssets[TEXT_OFFSETS.length - 1];
+ }
+ ;
+ buildSymbolAssets(symbol);
return self;
});
/****
@@ -464,39 +550,44 @@
var MATH_HALF_ROOT_3 = Math.sqrt(3) / 2; // Required by: TEXT_OFFSETS, BorderedText, BorderedSymbol, BorderedShape, SymbolText
;
// Text Settings
var TEXT_OFFSETS = [[0, 1], [MATH_HALF_ROOT_3, 0.5], [MATH_HALF_ROOT_3, -0.5], [0, -1], [-MATH_HALF_ROOT_3, -0.5], [-MATH_HALF_ROOT_3, 0.5], [0, 0]]; // Required by: BorderedText, BorderedSymbol, BorderedShape, SymbolText
-var TEXT_DEFAULT_WEIGHT = 4; // Required by: BorderedText, BorderedSymbol, BorderedShape, SymbolText
-var TEXT_DEFAULT_BORDER = '#000000'; // Required by: BorderedText, BorderedSymbol, BorderedShape, SymbolText
+var TEXT_DEFAULT_WEIGHT = 8; // Required by: BorderedText, BorderedSymbol, BorderedShape, SymbolText
+var TEXT_DEFAULT_BORDER = '#FFFFFF'; // Required by: BorderedText, BorderedSymbol, BorderedShape, SymbolText
var TEXT_DEFAULT_FILL = '#000000'; // Required by: BorderedText, SymbolText
-var TEXT_DEFAULT_FONT = 'Courier'; // Required by: BorderedText, SymbolText
-var TEXT_DEFAULT_SIZE = 100; // Required by: BorderedText, SymbolText
+var TEXT_DEFAULT_FONT = 'Consolas'; // Required by: BorderedText, SymbolText
+var TEXT_DEFAULT_SIZE = 120; // Required by: BorderedText, SymbolText
;
// Firewall Settings
var FIREWALL_OFFSET = 0.7;
var FIREWALL_SPEED = 2;
-var FIREWALL_SPEED_INC = 0.01 / GAME_TICKS;
+var FIREWALL_SPEED_INC = 0.05 / GAME_TICKS;
var FIREWALL_START_X = -GAME_WIDTH / 2 - 500;
var FIREWALL_SOUND_COUNT = 4;
var FIREWALL_SOUND_DIVDIST = 1000;
;
// Lilypad Settings
var LILYPAD_ANGLE = 10 * Math.PI / 180;
var LILYPAD_HEIGHT_FACTOR = 1.025;
var LILYPAD_STALK_OFFSET = -5;
-var LILYPAD_PICKUP_CHANCE = 0.5;
+var LILYPAD_SPAWN_MARGIN = 3000;
+var LILYPAD_SPAWN_X_MIN = 50;
+var LILYPAD_SPAWN_X_VAR = 2450;
+var LILYPAD_SPAWN_Y_MIN = -50;
+var LILYPAD_SPAWN_Y_VAR = -300;
+var LILYPAD_PICKUP_CHANCE = 0.25;
var LILYPAD_PICKUP_OFFSET_MIN = 50;
var LILYPAD_PICKUP_OFFSET_VAR = 100;
;
// Hook Settings
var HOOK_OFFLINE = 1 * GAME_TICKS;
var HOOK_SPAWN_MARGIN = 3000;
-var HOOK_SPAWN_X_MIN = 100;
-var HOOK_SPAWN_X_VAR = 1000;
-var HOOK_SPAWN_Y_MIN = 600;
-var HOOK_SPAWN_Y_VAR = 1000;
+var HOOK_SPAWN_X_MIN = 600;
+var HOOK_SPAWN_X_VAR = 1100;
+var HOOK_SPAWN_Y_MIN = -700;
+var HOOK_SPAWN_Y_VAR = -1300;
var HOOK_DOUBLE_CHANCE = 0.1;
-var HOOK_DOUBLE_SPREAD = 0.2;
+var HOOK_DOUBLE_SPREAD = 0.25;
;
// Player Settings
var PLAYER_START_X = -400;
var PLAYER_START_Y = -1300;
@@ -553,9 +644,9 @@
}));
// Camera containers
var foregroundContainer = camera.addChild(new Container());
var hookContainer = camera.addChild(new Container());
-var lillypadContainer = camera.addChild(new Container());
+var lilypadContainer = camera.addChild(new Container());
var pickupContainer = camera.addChild(new Container());
var forefrontContainer = camera.addChild(new Container());
// Foreground instances
var shadowground = foregroundContainer.addChild(new Foreground({
@@ -571,9 +662,9 @@
coverage: FOREGROUND_COVERAGE,
scale: FOREGROUND_SCALE
}));
// Camera instances
-var defaultPad = lillypadContainer.addChild(new Lilypad({
+var defaultPad = lilypadContainer.addChild(new Lilypad({
x: PLAYER_START_X,
y: PLAYER_START_Y,
active: false,
inert: true
@@ -593,25 +684,29 @@
inert: true
}));
var highlight = targetHook.highlightContainer.addChild(new Highlight());
// Decor lilypads
-lillypadContainer.addChild(new Lilypad({
+lilypadContainer.addChild(new Lilypad({
x: PLAYER_START_X - 50,
y: -500
}));
-lillypadContainer.addChild(new Lilypad({
+lilypadContainer.addChild(new Lilypad({
x: PLAYER_START_X + 100,
y: -300,
inert: true
}));
// Spawners
forefrontContainer.addChild(new Spawner({
+ x: PLAYER_START_X + 100,
spawnFunction: spawnLilypad,
- positionFunction: positionLilypad
+ positionFunction: positionLilypad,
+ margin: LILYPAD_SPAWN_MARGIN
}));
forefrontContainer.addChild(new Spawner({
+ x: targetHook.x,
spawnFunction: spawnHook,
- positionFunction: positionHook
+ positionFunction: positionHook,
+ margin: HOOK_SPAWN_MARGIN
}));
;
//==============================================================================
// Spawner functions
@@ -636,10 +731,17 @@
}
function positionHook(self) {
return HOOK_SPAWN_X_MIN + HOOK_SPAWN_X_VAR * Math.random();
}
-function spawnLilypad(self, x) {}
-function positionLilypad(self) {}
+function spawnLilypad(self, x) {
+ lilypadContainer.addChild(new Lilypad({
+ x: x,
+ y: LILYPAD_SPAWN_Y_MIN + LILYPAD_SPAWN_Y_VAR * Math.random()
+ }));
+}
+function positionLilypad(self) {
+ return LILYPAD_SPAWN_X_MIN + LILYPAD_SPAWN_X_VAR * Math.random();
+}
;
//==============================================================================
// Global events
//==============================================================================
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