Code edit (3 edits merged)
Please save this source code
User prompt
The bear is not at the same ground level as the rest of the assets, correct it.
User prompt
add trees to the background
Code edit (1 edits merged)
Please save this source code
User prompt
the bear should jump from the bottom and have a gravity effect to make the jump feel natural
User prompt
the bear should stay at the left corner, and it jumps when the screen is touched
Initial prompt
Grizzly and the Lemmings
/**** * Classes ****/ // Grizzly Bear class var GrizzlyBear = Container.expand(function () { var self = Container.call(this); var bearGraphics = self.createAsset('grizzlyBear', 'Grizzly Bear running', 0.5, 1); self.isJumping = false; self.jumpHeight = 1500; self.jumpSpeed = 20; self.gravity = 2; self.jump = function () { if (!self.isJumping) { self.isJumping = true; self.jumpSpeed = -50; } }; self.fall = function () { if (self.isJumping) { self.jumpSpeed += self.gravity; self.y += self.jumpSpeed; if (self.y >= 2732 - self.height) { self.y = 2732 - self.height; self.isJumping = false; } } }; }); // Tree class var Tree = Container.expand(function () { var self = Container.call(this); var treeGraphics = self.createAsset('tree', 'Background tree', 0.5, 1); self.speed = 1; self.move = function () { self.x -= self.speed; if (self.x < -self.width) { self.destroy(); } }; }); // Lemming class var Lemming = Container.expand(function () { var self = Container.call(this); var lemmingGraphics = self.createAsset('lemming', 'Lemming running away', 0.5, 1); self.speed = 3; self.move = function () { self.x += self.speed; if (self.x > 2048) { self.destroy(); } }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x87CEEB // Sky blue background }); /**** * Game Code ****/ // Initialize important asset arrays var lemmings = []; var trees = []; var grizzlyBear; // Create the Grizzly Bear grizzlyBear = game.addChild(new GrizzlyBear()); grizzlyBear.x = 100; grizzlyBear.y = 2732 - grizzlyBear.height - 100; // Game tick event LK.on('tick', function () { // Make the Grizzly Bear fall grizzlyBear.fall(); // Move each Lemming for (var i = lemmings.length - 1; i >= 0; i--) { lemmings[i].move(); // Check if Lemming is off screen and destroy it if (lemmings[i].x > 2048) { lemmings[i].destroy(); lemmings.splice(i, 1); } } // Move each Tree for (var i = trees.length - 1; i >= 0; i--) { trees[i].move(); // Check if Tree is off screen and destroy it if (trees[i].x < -trees[i].width) { trees[i].destroy(); trees.splice(i, 1); } } // Spawn Lemmings at intervals if (LK.ticks % 120 === 0) { var newLemming = new Lemming(); newLemming.x = -newLemming.width; newLemming.y = 2732 - newLemming.height; lemmings.push(newLemming); game.addChild(newLemming); } // Spawn Trees at intervals if (LK.ticks % 240 === 0) { var newTree = new Tree(); newTree.x = 2048; newTree.y = 2732 - newTree.height; trees.push(newTree); game.addChild(newTree); } }); // Touch event for Grizzly Bear to jump game.on('down', function () { grizzlyBear.jump(); });
===================================================================
--- original.js
+++ change.js
@@ -67,9 +67,9 @@
var grizzlyBear;
// Create the Grizzly Bear
grizzlyBear = game.addChild(new GrizzlyBear());
grizzlyBear.x = 100;
-grizzlyBear.y = 2732 - grizzlyBear.height;
+grizzlyBear.y = 2732 - grizzlyBear.height - 100;
// Game tick event
LK.on('tick', function () {
// Make the Grizzly Bear fall
grizzlyBear.fall();
Cartoon style cute apple tree with small branches. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Cartoon style cute rock. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A cute lemming running while holding a nutella cup. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows. Cartoon style.