Code edit (12 edits merged)
Please save this source code
User prompt
In the RoadSegment's transition function, use the stepChance var to determine stepUp and stepDown booleans calculated from the chance of stepChance succeeding
Code edit (1 edits merged)
Please save this source code
User prompt
Add a circle asset to the road class after the segment creation; with a width and height of 500, black tint, and anchor of 0.5,0.5
User prompt
Please fix the bug: 'TypeError: self is undefined' in or related to this line: 'var circle = self.attachAsset('circle', {' Line Number: 221
User prompt
Add a circle asset to the road class after the segments, with a width and height of 500, black tint, and anchor of 0.5,0.5
User prompt
remove the 2nd, duplication segment construction snippet
User prompt
Move the circle construction under the segment creation
User prompt
Add a circle asset to the road class with a width and height of 500, black tint, and anchor of 0.5,0.5
User prompt
change the background colour to sky blue
User prompt
segment.rotation should be in radians
User prompt
create two new classes: A RoadSegment class that contains the roadSegment asset (with anchor of 0,1), and a Road class containing 30 RoadSegments equally rotated around the origin. Then create and show a Road instance in the middle of the screen
Code edit (1 edits merged)
Please save this source code
Code edit (3 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: alpha is undefined' in or related to this line: 'numberText.setText(alpha.toFixed(1));' Line Number: 67
Code edit (2 edits merged)
Please save this source code
User prompt
display a number text in the top center of the screen
Code edit (1 edits merged)
Please save this source code
Code edit (16 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: character.update is not a function' in or related to this line: 'character.update();' Line Number: 167
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
User prompt
Please fix the bug: 'ReferenceError: body is not defined' in or related to this line: 'armLeft.x = -body.width / 2 + armOffsetX;' Line Number: 120
/**** * 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; ; return self; }); var CharacterLeg = ConfigContainer.expand(function (config) { var self = ConfigContainer.call(this, config); // Leg settings var upperBaseAngle = Math.PI * 3 / 8; var lowerBaseOffset = 135; var footBaseOffset = 100; // Create and attach leg parts var upper = self.attachAsset('upperLeg', { rotation: upperBaseAngle, anchorY: 0.1, tint: config.tint || 0xFFFFFF }); var lower = self.addChild(new ConfigContainer({ y: lowerBaseOffset, tint: config.tint || 0xFFFFFF })); lower.attachAsset('lowerLeg', { anchorX: 0.65, tint: config.tint || 0xFFFFFF }); var foot = lower.attachAsset('foot', { y: footBaseOffset, anchorX: 0.2, anchorY: 0.05, tint: config.tint || 0xFFFFFF }); self.update = function (alpha) { var upperSwing = Math.sin(alpha * Math.PI * 2) * Math.PI / 3; self.rotation = upperSwing; lower.rotation = Math.abs(-1.2 * upperSwing); }; }); var CharacterArm = ConfigContainer.expand(function (config) { var self = ConfigContainer.call(this, config); // Arm settings var upperBaseAngle = -Math.PI * 3 / 8; var lowerBaseAngle = -Math.PI / 4; var lowerHoldAngle = -Math.PI * 3 / 4; var lowerBaseOffset = 90; // Create and attach arm parts var upper = self.attachAsset('upperArm', { rotation: upperBaseAngle, anchorX: 0.85, anchorY: 0.25, tint: config.tint || 0xFFFFFF }); var lower = self.attachAsset('lowerArm', { y: lowerBaseOffset, rotation: lowerBaseAngle + lowerHoldAngle, anchorX: 0.95, anchorY: 0.05, tint: config.tint || 0xFFFFFF }); self.update = function (alpha) { var upperSwing = Math.sin(alpha * Math.PI * 2) * Math.PI / 4; // Swing between -45 and 45 degrees var lowerSwing = -upperSwing / 2; self.rotation = -upperSwing; lower.rotation = lowerBaseAngle + lowerHoldAngle + lowerSwing; }; }); var Character = ConfigContainer.expand(function (config) { var self = ConfigContainer.call(this, config); // Body settings var armOffsetX = 15; var armOffsetY = 30; var pelvisOffsetX = -15; var legOffsetX = 5; // Create and attach body parts var armRight = self.addChild(new CharacterArm({ y: armOffsetY, tint: 0x999999 })); var legRight = self.addChild(new CharacterLeg({ x: pelvisOffsetX + legOffsetX, tint: 0x999999 })); var torso = self.attachAsset('torso', { anchorX: 0.5 }); var head = self.attachAsset('head', { anchorX: 0.15, anchorY: 0.95 }); var pelvis = self.attachAsset('pelvis', { x: pelvisOffsetX, y: torso.height, anchorX: 0.5, anchorY: 0.2 }); var legLeft = self.addChild(new CharacterLeg({ x: pelvisOffsetX - legOffsetX })); var armLeft = self.addChild(new CharacterArm({ y: armOffsetY })); // Position body parts armLeft.x = -torso.width / 2 + armOffsetX; armRight.x = torso.width / 2 - armOffsetX; legLeft.y = torso.height + pelvis.height / 3; legRight.y = torso.height + pelvis.height / 3; // Add an empty update function to the Character class self.runAlpha = 0; self.update = function () { this.runAlpha += 0.01; armLeft.update(this.runAlpha); armRight.update(this.runAlpha - 0.5); legLeft.update(this.runAlpha); legRight.update(this.runAlpha - 0.5); }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ var character = game.addChild(new Character({ x: 2048 / 2, y: 2732 / 2 })); // Add an ontick event to the game which calls the character's update method LK.on('tick', function () { character.update(); });
===================================================================
--- original.js
+++ change.js
@@ -44,19 +44,19 @@
anchorY: 0.05,
tint: config.tint || 0xFFFFFF
});
self.update = function (alpha) {
- var upperSwing = Math.sin(alpha * Math.PI * 2) * Math.PI / 4; // Swing between -45 and 45 degrees
+ var upperSwing = Math.sin(alpha * Math.PI * 2) * Math.PI / 3;
self.rotation = upperSwing;
- lower.rotation = Math.abs(-2 * upperSwing);
+ lower.rotation = Math.abs(-1.2 * upperSwing);
};
});
var CharacterArm = ConfigContainer.expand(function (config) {
var self = ConfigContainer.call(this, config);
// Arm settings
var upperBaseAngle = -Math.PI * 3 / 8;
var lowerBaseAngle = -Math.PI / 4;
- var lowerHoldAngle = -Math.PI / 2;
+ var lowerHoldAngle = -Math.PI * 3 / 4;
var lowerBaseOffset = 90;
// Create and attach arm parts
var upper = self.attachAsset('upperArm', {
rotation: upperBaseAngle,
@@ -71,9 +71,9 @@
anchorY: 0.05,
tint: config.tint || 0xFFFFFF
});
self.update = function (alpha) {
- var upperSwing = Math.sin(alpha * Math.PI * 2) * Math.PI / 3; // Swing between -45 and 45 degrees
+ var upperSwing = Math.sin(alpha * Math.PI * 2) * Math.PI / 4; // Swing between -45 and 45 degrees
var lowerSwing = -upperSwing / 2;
self.rotation = -upperSwing;
lower.rotation = lowerBaseAngle + lowerHoldAngle + lowerSwing;
};
white
white
circle sliced into many pieces, flat image. 2d, white background, shadowless.
pixel art of a tall, tree. game asset, 2d, white background, shadowless.
Pixel art street lamp. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art cloud. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art sun. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.