Code edit (1 edits merged)
Please save this source code
User prompt
When releasing, convert the tangential velocity into the new vx and vy
User prompt
Similarly apply the tangential velocity solution while the frog is attached to the hook, and revert it once the release function is called
User prompt
Assuming the frog is the body in this example, please add a vx, vy to it, and allow it to be affected by gravity.
User prompt
make the pink tongue a slightly darker pink
Code edit (1 edits merged)
Please save this source code
User prompt
tint the tongue body and tip pink
Code edit (1 edits merged)
Please save this source code
User prompt
In the Frog's attach function, if hook is defined, create a new FrogTongue with the length calculated from dx and dy. In the Frog's release function, destroy the tongue
Code edit (3 edits merged)
Please save this source code
User prompt
Create a new frogTongue class (inheriting from ConfigContainer) which contains a shapeBox (tongueBody) and shapeEllipse (tongueTip)
User prompt
Create a new frogTongue class which contains a shapeBox (tongueBody) and shapeEllipse (tongueTip)
Code edit (1 edits merged)
Please save this source code
User prompt
if the hook is defined, also rotate the frog's rotation toward the hook
User prompt
in the frogs attach function, check if the hook is defined and play the frogTongue sound, otherwise play the noTarget sound
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: defaultHook is not defined' in or related to this line: 'var highlight = defaultHook.highlightContainer.addChild(new Highlight());' Line Number: 227
User prompt
Rename defaultHook to targetHook
Code edit (1 edits merged)
Please save this source code
User prompt
Add an "attach" function to the frog class which takes in a hook
Code edit (1 edits merged)
Please save this source code
User prompt
Add a new Highlight class comprising of the highlight which slowly rotated in the update function
Code edit (3 edits merged)
Please save this source code
User prompt
Add a hookContainer empty Containers to the camera class
User prompt
Rename the lilypadStalk asset to stalk and rename its usage in the lilypad class
/**** * Classes ****/ /** * config { * x : Number || 0, * y : Number || 0, * rotation : Number || 0, * } **/ var ConfigContainer = Container.expand(function (config) { var self = Container.call(this); config = config || {}; ; self.x = config.x || 0; self.y = config.y || 0; self.rotation = config.rotation || 0; if (config.scale !== undefined || config.scaleX !== undefined || config.scaleY !== undefined) { var scaleX = config.scaleX !== undefined ? config.scaleX : config.scale !== undefined ? config.scale : 1; var scaleY = config.scaleY !== undefined ? config.scaleY : config.scale !== undefined ? config.scale : 1; self.scale.set(scaleX, scaleY); } ; return self; }); var Lilypad = ConfigContainer.expand(function (config) { var self = ConfigContainer.call(this, config); var stalk = self.attachAsset('stalk', { anchorX: 0.5, y: LILYPAD_STALK_OFFSET, width: 15, height: -(self.y + LILYPAD_STALK_OFFSET) * LILYPAD_HEIGHT_FACTOR, rotation: LILYPAD_ANGLE * (1 - 2 * Math.random()), tint: 0x90ee90 // light green }); var lilypad = self.attachAsset('lilypad', { anchorX: 0.5, anchorY: 0.5 }); return self; }); var Hook = ConfigContainer.expand(function (config) { var self = ConfigContainer.call(this, config); var highlightContainer = self.addChild(new Container()); var hook = self.attachAsset('hook', { anchorX: 0.5, anchorY: 0.5 }); return self; }); var Frog = ConfigContainer.expand(function (config) { var self = ConfigContainer.call(this, config); var frog = self.attachAsset('frog', { anchorX: 0.5, anchorY: 0.75 }); return self; }); var Foreground = ConfigContainer.expand(function (config) { var self = ConfigContainer.call(this, config); var foreground1 = self.attachAsset('foreground', { anchorX: 0.0, anchorY: 1.0, tint: 0x808080 // 50% grey }); var foreground2 = self.attachAsset('foreground', { anchorX: 1.0, anchorY: 1.0, scaleX: -1, x: foreground1.width, tint: 0x808080 // 50% grey }); return self; }); var Firewall = ConfigContainer.expand(function (config) { var self = ConfigContainer.call(this, config); var speed = FIREWALL_SPEED; var columns = []; var columnCount = config.columns || 0; var firewallBase = self.attachAsset('firewallBase', { anchorX: 0.5, anchorY: 1.0 }); columns.push(firewallBase); for (var i = 0; i < columnCount; i++) { var firewallColumn = LK.getAsset('firewallColumn', {}); var column = self.attachAsset('firewallColumn', { anchorX: 0.5, anchorY: 1.0, y: -firewallBase.height * FIREWALL_OFFSET - i * firewallColumn.height * FIREWALL_OFFSET, scaleX: Math.random() > 0.5 ? 1 : -1 }); columns.push(column); } self.update = function () { var randomColumn = columns[Math.floor(Math.random() * columns.length)]; randomColumn.scale.x *= -1; speed += FIREWALL_SPEED_INC; self.x += speed; }; return self; }); var Camera = ConfigContainer.expand(function (config) { var self = ConfigContainer.call(this, config); var zoom = 1.0; self.update = function () { self.scale.set(zoom); moon.scale.set(zoom); }; }); /**** * Initialize Game ****/ //<Assets used in the game will automatically appear here> var game = new LK.Game({ backgroundColor: 0x000000 //Init game with black background }); /**** * Game Code ****/ ; //============================================================================== // Global Constants & Settings //============================================================================== ; // Game Constants var GAME_TICKS = 60; var GAME_WIDTH = 2048; var GAME_HEIGHT = 2732; ; // Firewall Settings 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; ; // Lilypad Settings var LILYPAD_ANGLE = 10 * Math.PI / 180; var LILYPAD_HEIGHT_FACTOR = 1.025; var LILYPAD_STALK_OFFSET = -5; ; // Player Settings var PLAYER_START_X = -300; var PLAYER_START_Y = -1000; var PLAYER_RANGE = 650; ; //============================================================================== // Game Instances & Variables //============================================================================== ; var background = game.addChild(LK.getAsset('background', { anchorX: 0.5, anchorY: 1.0, x: GAME_WIDTH / 2, y: GAME_HEIGHT })); var moon = game.addChild(LK.getAsset('moon', { anchorX: 0.5, anchorY: 0.5, x: GAME_WIDTH / 2, y: GAME_HEIGHT / 2 })); var foreground = game.addChild(new Foreground({ y: GAME_HEIGHT })); var camera = game.addChild(new Camera({ x: GAME_WIDTH / 2, y: GAME_HEIGHT })); var lillypadContainer = camera.addChild(new Container()); var pickupContainer = camera.addChild(new Container()); var hookContainer = camera.addChild(new Container()); var startingPad = lillypadContainer.addChild(new Lilypad({ x: PLAYER_START_X, y: PLAYER_START_Y })); var frog = camera.addChild(new Frog({ x: PLAYER_START_X, y: PLAYER_START_Y })); // Decor lilypads lillypadContainer.addChild(new Lilypad({ x: PLAYER_START_X - 50, y: -500 })); lillypadContainer.addChild(new Lilypad({ x: PLAYER_START_X + 100, y: -300 })); var firewall = camera.addChild(new Firewall({ x: FIREWALL_START_X, columns: 10 }));
===================================================================
--- original.js
+++ change.js
@@ -170,8 +170,9 @@
y: GAME_HEIGHT
}));
var lillypadContainer = camera.addChild(new Container());
var pickupContainer = camera.addChild(new Container());
+var hookContainer = camera.addChild(new Container());
var startingPad = lillypadContainer.addChild(new Lilypad({
x: PLAYER_START_X,
y: PLAYER_START_Y
}));
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