User prompt
Bg=grey
User prompt
Bg=Fly88
User prompt
Add 2 red lines in the middle of game
User prompt
Add 2 lines in the middle of game
User prompt
Bg=grey
User prompt
Bg=cyan
User prompt
At lines in the middle of game
User prompt
Add 2 black lines in the bottom
User prompt
Add 2 black lines in the middle of the game
User prompt
Add 2 lines in the middle of game
User prompt
Bg=grey
User prompt
Bg=black and white
User prompt
Bg=road
User prompt
Bg = light blue
User prompt
Bg = road
User prompt
Score = rock disappears
User prompt
If hero touch rock it disappears
User prompt
Decrease the quantity of obstacle
User prompt
Add rocks
User prompt
Remove rocks
User prompt
Rock = less quantity
User prompt
Increase the quantity of obstacle
User prompt
Les the rock
User prompt
Less rock
User prompt
Decrease in the quantity of rocks
/****
* Classes
****/
var Dot = Container.expand(function () {
var self = Container.call(this);
var dotGraphics = self.attachAsset('dot', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
// Update logic for the dot, if needed
};
});
// Assets will be automatically created and loaded by the LK engine based on their usage in the code.
// For example, if you use LK.getAsset('hero'), the engine will automatically create and load an asset with the id 'hero'.
// Hero class representing the player character
var Hero = Container.expand(function () {
var self = Container.call(this);
var heroGraphics = self.attachAsset('hero', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 8;
self.update = function () {
// Update logic for the hero, such as movement
};
});
var LeftButton = Container.expand(function () {
var self = Container.call(this);
var buttonGraphics = self.attachAsset('leftButton', {
anchorX: 0.5,
anchorY: 0.5
});
self.x = 150;
self.y = 2732 - 150;
self.down = function (x, y, obj) {
hero.x -= hero.speed;
};
});
// Obstacle class representing obstacles in the game
var Obstacle = Container.expand(function () {
var self = Container.call(this);
var obstacleGraphics = self.attachAsset('obstacle', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 8;
self.update = function () {
self.y += self.speed;
if (self.y > 2732) {
self.destroy();
}
};
});
var RightButton = Container.expand(function () {
var self = Container.call(this);
var buttonGraphics = self.attachAsset('rightButton', {
anchorX: 0.5,
anchorY: 0.5
});
self.x = 2048 - 150;
self.y = 2732 - 150;
self.down = function (x, y, obj) {
hero.x += hero.speed;
};
});
var Rock = Container.expand(function () {
var self = Container.call(this);
var rockGraphics = self.attachAsset('rock', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 5;
self.update = function () {
self.y += self.speed;
if (self.y > 2732) {
self.destroy();
}
};
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x808080 // Set background color to grey
});
/****
* Game Code
****/
// Initialize game variables
var line1 = LK.getAsset('dot', {
anchorX: 0.5,
anchorY: 0.5
});
var line2 = LK.getAsset('dot', {
anchorX: 0.5,
anchorY: 0.5
});
line1.scaleX = 2048;
line1.scaleY = 1;
line1.x = 0;
line1.y = 2732 / 2 - 50;
line2.scaleX = 2048;
line2.scaleY = 1;
line2.x = 0;
line2.y = 2732 / 2 + 50;
game.addChild(line1);
game.addChild(line2);
var leftButton = game.addChild(new LeftButton());
var rightButton = game.addChild(new RightButton());
var hero = game.addChild(new Hero());
hero.x = leftButton.x;
hero.y = leftButton.y - 200; // Adjusted to ensure hero spawns above the left button
var obstacles = [];
var rocks = [];
var dot = game.addChild(new Dot());
dot.x = 2048 / 2;
dot.y = 2732 / 2 - 100;
var score = 0;
var scoreTxt = new Text2('0', {
size: 150,
fill: "#ffffff"
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
// Function to handle game updates
game.update = function () {
// Update hero
hero.update();
// Check if dot intersects with left button
if (dot.intersects(leftButton)) {
hero.x -= hero.speed;
dot.x = leftButton.x;
// dot.y = 2732 - 50; // Removed command to prevent dot from moving to the bottom
}
// Check if dot intersects with right button
if (dot.intersects(rightButton)) {
hero.x += hero.speed;
dot.x = rightButton.x;
dot.y = rightButton.y;
}
// Update obstacles
for (var i = obstacles.length - 1; i >= 0; i--) {
obstacles[i].update();
if (hero.intersects(obstacles[i])) {
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
}
}
// Update rocks
for (var i = rocks.length - 1; i >= 0; i--) {
rocks[i].update();
if (hero.intersects(rocks[i])) {
rocks[i].destroy();
rocks.splice(i, 1);
score += 1;
scoreTxt.setText(score.toString());
}
}
// Spawn new obstacles
if (LK.ticks % 40 == 0) {
for (var j = 0; j < 1; j++) {
// Spawn one obstacle at a time
var newObstacle;
newObstacle = new Obstacle();
newObstacle.x = Math.random() * 2048;
newObstacle.y = 0;
obstacles.push(newObstacle);
game.addChild(newObstacle);
}
}
// Spawn new rocks
if (LK.ticks % 50 == 0) {
var newRock = new Rock();
newRock.x = Math.random() * 2048;
newRock.y = 0;
rocks.push(newRock);
game.addChild(newRock);
}
// Check if hero touches the left or right edge of the screen
if (hero.x <= 0 || hero.x >= 2048) {
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
}
// Update score
};
// Handle touch events for hero movement
game.down = function (x, y, obj) {
dot.x = x;
dot.y = y;
};
game.move = function (x, y, obj) {
dot.x = x;
dot.y = y;
};
game.up = function (x, y, obj) {
// No action needed on touch up
}; ===================================================================
--- original.js
+++ change.js
@@ -89,8 +89,26 @@
/****
* Game Code
****/
// Initialize game variables
+var line1 = LK.getAsset('dot', {
+ anchorX: 0.5,
+ anchorY: 0.5
+});
+var line2 = LK.getAsset('dot', {
+ anchorX: 0.5,
+ anchorY: 0.5
+});
+line1.scaleX = 2048;
+line1.scaleY = 1;
+line1.x = 0;
+line1.y = 2732 / 2 - 50;
+line2.scaleX = 2048;
+line2.scaleY = 1;
+line2.x = 0;
+line2.y = 2732 / 2 + 50;
+game.addChild(line1);
+game.addChild(line2);
var leftButton = game.addChild(new LeftButton());
var rightButton = game.addChild(new RightButton());
var hero = game.addChild(new Hero());
hero.x = leftButton.x;
Right button. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Road. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Road Car. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Coin. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.