User prompt
add an arm swinging animation to the CharacterArm's update function, these should be constructed from sinusoidal equations based on the alpha
User prompt
The CharacterArm and CharacterLeg classes should have empty update methods that takes in an alpha value
User prompt
Create an CharacterArm class and a CharacterLeg class, these should contain the respective upper and lower component images instead of the Character class
User prompt
add a basic running animation to the character in the update method
User prompt
the character should have 2 legs and 2 arms
User prompt
add an ontick even to the game which should call the created character's update method
User prompt
add an empty update function to the character class
User prompt
display a character in the middle of the screen
User prompt
Create a Character class that's a side-view of a person. It should be composed of different individual body parts: upper and lower arms, upper and lower legs, and the body (which will include the head).
User prompt
Remove all the code in the game
Initial prompt
Road Runners
/**** * Classes ****/ var Character = Container.expand(function () { var self = Container.call(this); // Create and attach body parts var body = self.attachAsset('body', { anchorX: 0.5, anchorY: 0.5 }); var armLeft = self.addChild(new CharacterArm()); var armRight = self.addChild(new CharacterArm()); var legLeft = self.addChild(new CharacterLeg()); var legRight = self.addChild(new CharacterLeg()); // Position body parts body.x = 0; body.y = 0; armLeft.x = -body.width / 2; armLeft.y = -body.height / 2; armRight.x = body.width / 2; armRight.y = -body.height / 2; legLeft.x = -body.width / 4; legLeft.y = body.height / 2; legRight.x = body.width / 4; legRight.y = body.height / 2; // Add an empty update function to the Character class self.update = function () {}; }); var CharacterArm = Container.expand(function () { var self = Container.call(this); // Create and attach arm parts var upperArm = self.attachAsset('upperArm', { anchorX: 0.5, anchorY: 0.5 }); var lowerArm = self.attachAsset('lowerArm', { anchorX: 0.5, anchorY: 0.5 }); // Position arm parts upperArm.x = 0; upperArm.y = 0; lowerArm.x = upperArm.x; lowerArm.y = upperArm.y - upperArm.height; }); var CharacterLeg = Container.expand(function () { var self = Container.call(this); // Create and attach leg parts var upperLeg = self.attachAsset('upperLeg', { anchorX: 0.5, anchorY: 0.5 }); var lowerLeg = self.attachAsset('lowerLeg', { anchorX: 0.5, anchorY: 0.5 }); // Position leg parts upperLeg.x = 0; upperLeg.y = 0; lowerLeg.x = upperLeg.x; lowerLeg.y = upperLeg.y + upperLeg.height; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ var character = game.addChild(new Character()); // Position character at the center of the screen character.x = 2048 / 2; character.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
@@ -7,71 +7,59 @@
var body = self.attachAsset('body', {
anchorX: 0.5,
anchorY: 0.5
});
- var upperArmLeft = self.attachAsset('upperArm', {
+ var armLeft = self.addChild(new CharacterArm());
+ var armRight = self.addChild(new CharacterArm());
+ var legLeft = self.addChild(new CharacterLeg());
+ var legRight = self.addChild(new CharacterLeg());
+ // Position body parts
+ body.x = 0;
+ body.y = 0;
+ armLeft.x = -body.width / 2;
+ armLeft.y = -body.height / 2;
+ armRight.x = body.width / 2;
+ armRight.y = -body.height / 2;
+ legLeft.x = -body.width / 4;
+ legLeft.y = body.height / 2;
+ legRight.x = body.width / 4;
+ legRight.y = body.height / 2;
+ // Add an empty update function to the Character class
+ self.update = function () {};
+});
+var CharacterArm = Container.expand(function () {
+ var self = Container.call(this);
+ // Create and attach arm parts
+ var upperArm = self.attachAsset('upperArm', {
anchorX: 0.5,
anchorY: 0.5
});
- var upperArmRight = self.attachAsset('upperArm', {
+ var lowerArm = self.attachAsset('lowerArm', {
anchorX: 0.5,
anchorY: 0.5
});
- var lowerArmLeft = self.attachAsset('lowerArm', {
+ // Position arm parts
+ upperArm.x = 0;
+ upperArm.y = 0;
+ lowerArm.x = upperArm.x;
+ lowerArm.y = upperArm.y - upperArm.height;
+});
+var CharacterLeg = Container.expand(function () {
+ var self = Container.call(this);
+ // Create and attach leg parts
+ var upperLeg = self.attachAsset('upperLeg', {
anchorX: 0.5,
anchorY: 0.5
});
- var lowerArmRight = self.attachAsset('lowerArm', {
+ var lowerLeg = self.attachAsset('lowerLeg', {
anchorX: 0.5,
anchorY: 0.5
});
- var upperLegLeft = self.attachAsset('upperLeg', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- var upperLegRight = self.attachAsset('upperLeg', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- var lowerLegLeft = self.attachAsset('lowerLeg', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- var lowerLegRight = self.attachAsset('lowerLeg', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- // Position body parts
- body.x = 0;
- body.y = 0;
- upperArmLeft.x = -body.width / 2;
- upperArmLeft.y = -body.height / 2;
- upperArmRight.x = body.width / 2;
- upperArmRight.y = -body.height / 2;
- lowerArmLeft.x = upperArmLeft.x;
- lowerArmLeft.y = upperArmLeft.y - upperArmLeft.height;
- lowerArmRight.x = upperArmRight.x;
- lowerArmRight.y = upperArmRight.y - upperArmRight.height;
- upperLegLeft.x = -body.width / 4;
- upperLegLeft.y = body.height / 2;
- upperLegRight.x = body.width / 4;
- upperLegRight.y = body.height / 2;
- lowerLegLeft.x = upperLegLeft.x;
- lowerLegLeft.y = upperLegLeft.y + upperLegLeft.height;
- lowerLegRight.x = upperLegRight.x;
- lowerLegRight.y = upperLegRight.y + upperLegRight.height;
- // Add an empty update function to the Character class
- self.update = function () {
- // Basic running animation
- upperArmLeft.rotation += 0.05;
- upperArmRight.rotation -= 0.05;
- lowerArmLeft.rotation -= 0.05;
- lowerArmRight.rotation += 0.05;
- upperLegLeft.rotation -= 0.05;
- upperLegRight.rotation += 0.05;
- lowerLegLeft.rotation += 0.05;
- lowerLegRight.rotation -= 0.05;
- };
+ // Position leg parts
+ upperLeg.x = 0;
+ upperLeg.y = 0;
+ lowerLeg.x = upperLeg.x;
+ lowerLeg.y = upperLeg.y + upperLeg.height;
});
/****
* Initialize Game
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.