User prompt
the gameplay shuold be different. the main hero can't jump, it needs to be static, permanently glued in the center of the screen. the hero has 2 color states, blue and yellow. when the player taps, the hero changes color, toggling between blue and yellow on every tap. coins of differents colors will later be added to go towards the hero, and the hero can only collect the resources of the respective color. so players will have to switch between the hero states, to collect either yellow or blue resources.
Initial prompt
Color Switch
/**** * Classes ****/ // Define the Hero class var Hero = Container.expand(function () { var self = Container.call(this); var heroGraphics = self.createAsset('hero', 'Hero character', 0.5, 0.5); self.speedY = 0; self.gravity = 0.5; self.lift = -10; // Update the hero's position self.update = function () { self.speedY += self.gravity; self.y += self.speedY; // Prevent the hero from moving off-screen if (self.y > game.height - heroGraphics.height / 2) { self.y = game.height - heroGraphics.height / 2; self.speedY = 0; } else if (self.y < heroGraphics.height / 2) { self.y = heroGraphics.height / 2; self.speedY = 0; } }; // Make the hero jump self.jump = function () { self.speedY = self.lift; }; }); // Define the Obstacle class var Obstacle = Container.expand(function (x, y, color) { var self = Container.call(this); var obstacleGraphics = self.createAsset('obstacle', 'Obstacle', 0.5, 0.5); obstacleGraphics.tint = color; self.x = x; self.y = y; // Move the obstacle self.move = function () { self.x -= 5; }; // Check if the obstacle is off-screen self.isOffScreen = function () { return self.x < -obstacleGraphics.width; }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 // Init game with black background }); /**** * Game Code ****/ // Initialize important asset arrays and game variables var hero; var obstacles = []; var colors = [0xFF0000, 0x00FF00, 0x0000FF]; // Red, Green, Blue var score = 0; var scoreTxt; var obstacleTimer = 0; var gameOver = false; // Create the hero hero = game.addChild(new Hero()); hero.x = game.width / 4; hero.y = game.height / 2; // Create the score text scoreTxt = new Text2('0', { size: 150, fill: "#ffffff" }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); // Handle the tap event to make the hero jump game.on('down', function (obj) { if (!gameOver) { hero.jump(); } }); // Game tick event LK.on('tick', function () { if (!gameOver) { // Update the hero hero.update(); // Add a new obstacle every 120 frames (2 seconds) obstacleTimer++; if (obstacleTimer === 120) { obstacleTimer = 0; var color = colors[Math.floor(Math.random() * colors.length)]; var obstacle = new Obstacle(game.width, Math.random() * game.height, color); obstacles.push(obstacle); game.addChild(obstacle); } // Update obstacles for (var i = obstacles.length - 1; i >= 0; i--) { obstacles[i].move(); // Check for collision if (hero.intersects(obstacles[i])) { gameOver = true; LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); } // Remove off-screen obstacles if (obstacles[i].isOffScreen()) { obstacles[i].destroy(); obstacles.splice(i, 1); // Increment score when obstacles go off-screen score++; scoreTxt.setText(score.toString()); } } } });
/****
* Classes
****/
// Define the Hero class
var Hero = Container.expand(function () {
var self = Container.call(this);
var heroGraphics = self.createAsset('hero', 'Hero character', 0.5, 0.5);
self.speedY = 0;
self.gravity = 0.5;
self.lift = -10;
// Update the hero's position
self.update = function () {
self.speedY += self.gravity;
self.y += self.speedY;
// Prevent the hero from moving off-screen
if (self.y > game.height - heroGraphics.height / 2) {
self.y = game.height - heroGraphics.height / 2;
self.speedY = 0;
} else if (self.y < heroGraphics.height / 2) {
self.y = heroGraphics.height / 2;
self.speedY = 0;
}
};
// Make the hero jump
self.jump = function () {
self.speedY = self.lift;
};
});
// Define the Obstacle class
var Obstacle = Container.expand(function (x, y, color) {
var self = Container.call(this);
var obstacleGraphics = self.createAsset('obstacle', 'Obstacle', 0.5, 0.5);
obstacleGraphics.tint = color;
self.x = x;
self.y = y;
// Move the obstacle
self.move = function () {
self.x -= 5;
};
// Check if the obstacle is off-screen
self.isOffScreen = function () {
return self.x < -obstacleGraphics.width;
};
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000 // Init game with black background
});
/****
* Game Code
****/
// Initialize important asset arrays and game variables
var hero;
var obstacles = [];
var colors = [0xFF0000, 0x00FF00, 0x0000FF]; // Red, Green, Blue
var score = 0;
var scoreTxt;
var obstacleTimer = 0;
var gameOver = false;
// Create the hero
hero = game.addChild(new Hero());
hero.x = game.width / 4;
hero.y = game.height / 2;
// Create the score text
scoreTxt = new Text2('0', {
size: 150,
fill: "#ffffff"
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
// Handle the tap event to make the hero jump
game.on('down', function (obj) {
if (!gameOver) {
hero.jump();
}
});
// Game tick event
LK.on('tick', function () {
if (!gameOver) {
// Update the hero
hero.update();
// Add a new obstacle every 120 frames (2 seconds)
obstacleTimer++;
if (obstacleTimer === 120) {
obstacleTimer = 0;
var color = colors[Math.floor(Math.random() * colors.length)];
var obstacle = new Obstacle(game.width, Math.random() * game.height, color);
obstacles.push(obstacle);
game.addChild(obstacle);
}
// Update obstacles
for (var i = obstacles.length - 1; i >= 0; i--) {
obstacles[i].move();
// Check for collision
if (hero.intersects(obstacles[i])) {
gameOver = true;
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
}
// Remove off-screen obstacles
if (obstacles[i].isOffScreen()) {
obstacles[i].destroy();
obstacles.splice(i, 1);
// Increment score when obstacles go off-screen
score++;
scoreTxt.setText(score.toString());
}
}
}
});
minimalist meditation background. no elements. pixelated. 8 bit.. Single Game Texture. In-Game asset. 2d. High contrast. No shadows.
black 8-ball biliard ball. pixelated. 8 bit.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
white round ball with black edges. has a black infinity logo inprinted on it. pixelated. 8 bit.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
round black circle. pixelated. 8 bit.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
white circle with a thin black paintbrushed outline. minimalist. pixelated. 8 bit.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.