Code edit (2 edits merged)
Please save this source code
User prompt
add continous background looping to the top of screen
User prompt
add continous background looping to the top of screen
User prompt
add loop the background movement to the left of screen
User prompt
add a forward movement to the entire game in a looping with same background
User prompt
add a forward movement to the entire game in a looping background
Code edit (2 edits merged)
Please save this source code
User prompt
scale the bike asset little bit bigger
Code edit (2 edits merged)
Please save this source code
User prompt
change the bike position at bottom center of the screen
Code edit (1 edits merged)
Please save this source code
User prompt
create a class for bike and position it on the center of the screen
User prompt
create a asset and assign as a background for this game
User prompt
remove all code
User prompt
Please fix the bug: 'ReferenceError: ball is not defined' in or related to this line: 'ball.update();' Line Number: 38
User prompt
remove all assets and its code
User prompt
add a forward movement to the entire game in a looping background
User prompt
add a default forward movement to the entire game with background attached
User prompt
add a default forward movement to the entire game
User prompt
add a forward movement to the entire game in a looping
User prompt
add a forward movement to the entire game in a looping background
Code edit (1 edits merged)
Please save this source code
User prompt
add a forward movement to the entire game in a looping background
User prompt
add a forward movement to the entire game in a looping background
Code edit (2 edits merged)
Please save this source code
/****
* Classes
****/
// Create a Background class
var Background = Container.expand(function () {
var self = Container.call(this);
// Attach background asset
var backgroundGraphics = self.attachAsset('background', {
anchorX: 0.5,
anchorY: 0.5
});
// Set background speed
self.speed = 5;
// This is automatically called every game tick, if the background is attached!
self.update = function () {
// Move background downwards
self.y += self.speed;
// If the background has moved off the screen, reset its position
if (self.y >= 2732) {
self.y = 0;
}
};
});
// Create a Bike class
var Bike = Container.expand(function () {
var self = Container.call(this);
// Attach bike asset
var bikeGraphics = self.attachAsset('bike', {
anchorX: 0.5,
anchorY: 0.5
});
// Set bike speed
self.speed = 5;
// This is automatically called every game tick, if the bike is attached!
self.update = function () {
// No movement
};
});
/****
* Initialize Game
****/
// Initialize bike asset
var game = new LK.Game({
backgroundColor: 0x000000 //Init game with black background
});
/****
* Game Code
****/
// Initialize a second background
var background2 = game.addChild(new Background());
// Position the second background above the first
background2.x = 2048 / 2;
background2.y = -2732 / 2;
// Add bike to the game
// Initialize background
var background = game.addChild(new Background());
// Position background at the center of the screen
background.x = 2048 / 2;
background.y = 2732 / 2;
var bike = game.addChild(new Bike());
// Position bike at the center horizontally and at the lower end of the screen vertically
bike.x = 2048 / 2; // Middle of the screen horizontally
bike.y = 2732 * 0.8; // Lower end of the screen vertically
// Move bike
bike.update();
// Check if bike has reached the finish line
if (bike.x >= 2048) {
// Bike has reached the finish line, show game over
LK.showGameOver();
} ===================================================================
--- original.js
+++ change.js
@@ -1,7 +1,27 @@
/****
* Classes
****/
+// Create a Background class
+var Background = Container.expand(function () {
+ var self = Container.call(this);
+ // Attach background asset
+ var backgroundGraphics = self.attachAsset('background', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ // Set background speed
+ self.speed = 5;
+ // This is automatically called every game tick, if the background is attached!
+ self.update = function () {
+ // Move background downwards
+ self.y += self.speed;
+ // If the background has moved off the screen, reset its position
+ if (self.y >= 2732) {
+ self.y = 0;
+ }
+ };
+});
// Create a Bike class
var Bike = Container.expand(function () {
var self = Container.call(this);
// Attach bike asset
@@ -27,15 +47,23 @@
/****
* Game Code
****/
+// Initialize a second background
+var background2 = game.addChild(new Background());
+// Position the second background above the first
+background2.x = 2048 / 2;
+background2.y = -2732 / 2;
// Add bike to the game
-// Initialize bike asset
-var background = game.addChild(LK.getAsset('background', {}));
+// Initialize background
+var background = game.addChild(new Background());
+// Position background at the center of the screen
+background.x = 2048 / 2;
+background.y = 2732 / 2;
var bike = game.addChild(new Bike());
// Position bike at the center horizontally and at the lower end of the screen vertically
bike.x = 2048 / 2; // Middle of the screen horizontally
-bike.y = 2732 * 0.3; // Lower end of the screen vertically
+bike.y = 2732 * 0.8; // Lower end of the screen vertically
// Move bike
bike.update();
// Check if bike has reached the finish line
if (bike.x >= 2048) {
sci fi bike with person riding facing right side Single Game Texture. In-Game asset. High contrast. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
sci fi bike with person riding facing right side Single Game Texture. In-Game asset. High contrast.
asteroid falling diffrent colors Single Game Texture. In-Game asset. High contrast. No Background