User prompt
Move the buttons a bit to the right. Also, they will be not be game mode buttons. They will be buttons when clicked on, it brings you to a new gui menu.
User prompt
The new buttons you added should be in the settings GUI area. They should be lined up vertical on the left side of the settings gui with 10 pixels in-between them.
User prompt
Forward the development of the game by adding new settings to the game.
User prompt
Put the positions of the settings gui back to what it was. The settings gui asset was also 1000 x 1000.
User prompt
Forward the GUI development of the game.
User prompt
Use lk.gui to make the settings gui a layer above the falling objects. Keep original positions
User prompt
Bug: The settings button gets small when rotating it.
User prompt
Make the settings gui a layer above the falling objects.
User prompt
redo the centering logic and make sure the settings gui is in the center of the screen.
User prompt
Center the settings gui by the midpoint
User prompt
Now just center it by the middle point of the settings gui. Currently, it is only centered by the vertical.
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'height')' in this line: 'settingsGUI.y = LK.gui.overlay.height / 2;' Line Number: 51
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'width')' in this line: 'settingsGUI.x = LK.gui.overlay.width / 2;' Line Number: 48
User prompt
Don't center it by the game.width and game.height , center it by the size of the screen area.
User prompt
I want it to be centered in the center of the screen. It should be centered by the middle of the settings gui. Here is the size of the asset. 1250 x 1250
User prompt
The size of the settings gui asset is 1250 x 1250. Make sure you use that in consideration when you center the settings gui.
User prompt
Make the settings gui in the center of the screen
Code edit (1 edits merged)
Please save this source code
User prompt
Move the settings gui left
User prompt
Move the settings gui down
User prompt
Remove any multiplier to increase the size of the settings gui. The settings GUI will be the native resolution of the asset.
User prompt
The center of the settings GUI is not in the center of the screen.
User prompt
Make the center of the settings gui in the center of the screen
User prompt
Put the settings GUI in the middle of the screen.
User prompt
Make all of the settings GUI above the game
/****
* Classes
****/
var SettingsGUI = Container.expand(function () {
var self = Container.call(this);
var background = self.createAsset('settingsBackground', 'Settings GUI Background', 0.5, 0.5);
var closeButton = self.createAsset('closeButton', 'Close button', 0.5, 0.5);
closeButton.x = background.width / 2 - closeButton.width / 2;
closeButton.y = -background.height / 2 - closeButton.height / 2;
self.addChild(background);
self.addChild(closeButton);
closeButton.on('down', function () {
self.parent.removeChild(self);
});
});
var SettingsButton = Container.expand(function () {
var self = Container.call(this);
var buttonGraphics = self.createAsset('settingsButton', 'Settings button', 0.5, 0.5);
self.addChild(buttonGraphics);
self.x = 100; // Position from the left edge
self.y = 100; // Position from the top edge
var settingsGUI = null;
self.on('down', function (obj) {
if (!settingsGUI || !game.children.includes(settingsGUI)) {
var updateRotation = function updateRotation() {
if (currentFrame < rotationFrames) {
self.rotation += rotationAmount / rotationFrames;
currentFrame++;
} else {
self.rotation = 0;
LK.off('tick', updateRotation);
}
};
self.isDown = true;
var rotationAmount = Math.PI * 2;
var rotationFrames = 20;
var currentFrame = 0;
LK.on('tick', updateRotation);
}
});
self.on('up', function (obj) {
if (self.isDown) {
self.isDown = false;
self.scale.x /= 1.05;
self.scale.y /= 1.05;
if (!settingsGUI || !game.children.includes(settingsGUI)) {
settingsGUI = new SettingsGUI();
settingsGUI.x = 2048 / 2;
settingsGUI.y = 2732 / 2;
LK.gui.top.addChild(settingsGUI);
}
}
});
self.on('upoutside', function (obj) {
if (self.isDown) {
self.isDown = false;
self.scale.x /= 1.05;
self.scale.y /= 1.05;
}
});
self.on('over', function (obj) {
if (!self.isDown) {
self.scale.x *= 1.05;
self.scale.y *= 1.05;
}
});
self.on('out', function (obj) {
if (!self.isDown) {
self.scale.x /= 1.05;
self.scale.y /= 1.05;
}
});
});
// ShadowGraphics class for shadow visuals
var ShadowGraphics = Container.expand(function () {
var self = Container.call(this);
var graphics = self.createAsset('shadow', 'Shadow effect', 0.5, 0.5);
// Additional visual enhancements for shadow can be added here
});
// Splash effect class
var Splash = Container.expand(function () {
var self = Container.call(this);
// Replace basic splash graphics with enhanced SplashGraphics
var splashGraphics = new SplashGraphics();
self.addChild(splashGraphics);
self.lifeSpan = 30; // Frames until splash fades out
self.update = function () {
self.alpha -= 1 / self.lifeSpan;
if (self.alpha <= 0) {
self.destroy();
} // Destroy splash when faded out
};
LK.on('tick', self.update);
});
// SplashGraphics class for enhanced splash visuals
var SplashGraphics = Container.expand(function () {
var self = Container.call(this);
var graphics = self.createAsset('splash', 'Splash effect', 0.5, 0.5);
// Additional visual enhancements can be added here
});
// Replace basic splash graphics with enhanced SplashGraphics
// Function to create a splash effect
var Particle = Container.expand(function () {
var self = Container.call(this);
var particleGraphics = new ParticleGraphics();
self.addChild(particleGraphics);
self.lifeSpan = 60; // Frames until particle fades out
self.update = function () {
self.alpha -= 1 / self.lifeSpan;
if (self.alpha <= 0) {
self.destroy();
} // Destroy particle when faded out
};
});
var ParticlePool = Container.expand(function () {
var self = Container.call(this);
self.pool = [];
self.maxParticles = 100;
self.getParticle = function () {
for (var i = 0; i < self.pool.length; i++) {
if (self.pool[i].alpha <= 0) {
return self.pool[i];
}
}
if (self.pool.length < self.maxParticles) {
var newParticle = new Particle();
self.pool.push(newParticle);
return newParticle;
}
return null;
};
self.update = function () {
self.pool.forEach(function (particle) {
if (particle.alpha > 0) {
particle.update();
}
});
};
LK.on('tick', self.update);
});
// TimerParticle class for unique TimerItem particle visuals
var TimerParticle = Container.expand(function () {
var self = Container.call(this);
var graphics = self.createAsset('timerParticle', 'Timer item particle', 0.5, 0.5);
self.lifeSpan = 60; // Frames until particle fades out
self.update = function () {
self.alpha -= 1 / self.lifeSpan;
if (self.alpha <= 0) {
self.destroy();
} // Destroy particle when faded out
};
LK.on('tick', self.update);
});
// TimerParticlePool class for pooling TimerItem's unique particles
var TimerParticlePool = Container.expand(function () {
var self = Container.call(this);
self.pool = [];
self.maxParticles = 100;
self.getParticle = function () {
for (var i = 0; i < self.pool.length; i++) {
if (self.pool[i].alpha <= 0) {
return self.pool[i];
}
}
if (self.pool.length < self.maxParticles) {
var newParticle = new TimerParticle();
self.pool.push(newParticle);
return newParticle;
}
return null;
};
self.update = function () {
self.pool.forEach(function (particle) {
if (particle.alpha > 0) {
particle.update();
}
});
};
LK.on('tick', self.update);
});
// Initialize the particle pool
// ParticleGraphics class for enhanced particle visuals
var ParticleGraphics = Container.expand(function () {
var self = Container.call(this);
var graphics = self.createAsset('particle', 'Ball trail particle', 0.5, 0.5);
// Additional visual enhancements can be added here
});
// CoffeeBean class
var CoffeeBean = Container.expand(function () {
var self = Container.call(this);
self.particlePool = new ParticlePool();
self.createParticle = function () {
var particle = this.particlePool.getParticle();
if (particle) {
particle.x = self.x;
particle.y = self.y;
particle.alpha = 1; // Reset particle alpha
if (!self.isDestroyed && game.children.includes(self)) {
game.addChildAt(particle, game.getChildIndex(self));
}
}
};
// Use CoffeeBeanGraphics for coffee bean visuals
var coffeeBeanGraphics = new CoffeeBeanGraphics();
var shadowGraphics = new ShadowGraphics();
shadowGraphics.y = coffeeBeanGraphics.height * 0.1;
shadowGraphics.alpha = 0.5;
self.addChild(shadowGraphics);
self.addChild(coffeeBeanGraphics);
self.speed = (Math.random() * 3 + 2) * 8; // Coffee beans will have speeds between 16 and 40
self.scoreValue = 5; // Default score value for each coffee bean
self.move = function () {
self.y += self.speed;
self.createParticle();
};
self.resetPosition = function () {
self.x = Math.random() * (2048 - coffeeBeanGraphics.width) + coffeeBeanGraphics.width / 2;
self.y = -coffeeBeanGraphics.height;
};
self.isDestroyed = false;
self.resetPosition();
});
// CoffeeBeanGraphics class for enhanced coffee bean visuals
var CoffeeBeanGraphics = Container.expand(function () {
var self = Container.call(this);
var graphics = self.createAsset('coffeeBean', 'Coffee bean graphics', 0.5, 0.5);
// Additional visual enhancements can be added here
});
// Replace basic particle graphics with enhanced ParticleGraphics
// Ball class
var Ball = Container.expand(function () {
var self = Container.call(this);
self.particlePool = new ParticlePool();
self.createParticle = function () {
var particle = this.particlePool.getParticle();
if (particle) {
particle.x = self.x;
particle.y = self.y;
particle.alpha = 1; // Reset particle alpha
if (!self.isDestroyed && game.children.includes(self)) {
game.addChildAt(particle, game.getChildIndex(self));
}
}
};
// Use BallGraphics for ball visuals
var ballGraphics = new BallGraphics();
var shadowGraphics = new ShadowGraphics();
shadowGraphics.y = ballGraphics.height * 0.1;
shadowGraphics.alpha = 0.5;
self.addChild(shadowGraphics);
self.addChild(ballGraphics);
self.speed = (Math.random() * 3 + 2) * 2; // Balls will have speeds between 4 and 10
self.scoreValue = 1; // Default score value for each ball
self.move = function () {
self.y += self.speed;
self.createParticle();
};
self.resetPosition = function () {
self.x = Math.random() * (2048 - ballGraphics.width) + ballGraphics.width / 2;
self.y = -ballGraphics.height;
};
self.isDestroyed = false;
self.resetPosition();
});
// TimerItem class
var TimerItem = Container.expand(function () {
var self = Container.call(this);
self.particlePool = new TimerParticlePool();
self.createParticle = function () {
var particle = this.particlePool.getParticle();
if (particle) {
particle.x = self.x;
particle.y = self.y;
particle.alpha = 1; // Reset particle alpha
if (!self.isDestroyed && game.children.includes(self)) {
game.addChildAt(particle, game.getChildIndex(self));
}
}
};
var timerItemGraphics = self.createAsset('timerItem', 'Falling timer item', 0.5, 0.5);
var shadowGraphics = new ShadowGraphics();
shadowGraphics.y = timerItemGraphics.height * 0.1;
shadowGraphics.alpha = 0.5;
self.addChild(shadowGraphics);
self.addChild(timerItemGraphics);
self.speed = (Math.random() * 3 + 2) * 6; // Timer items will have speeds similar to coffee beans
self.move = function () {
self.y += self.speed;
self.createParticle();
};
self.resetPosition = function () {
self.x = Math.random() * (2048 - timerItemGraphics.width) + timerItemGraphics.width / 2;
self.y = -timerItemGraphics.height;
};
self.isDestroyed = false;
self.resetPosition();
});
// BallGraphics class for enhanced ball visuals
var BallGraphics = Container.expand(function () {
var self = Container.call(this);
var graphics = self.createAsset('ball', 'Ball graphics', 0.5, 0.5);
// Additional visual enhancements can be added here
});
// Cup class
var Cup = Container.expand(function () {
var self = Container.call(this);
// Replace basic cup graphics with enhanced CupGraphics
var cupGraphics = new CupGraphics();
self.addChild(cupGraphics);
self.x = 2048 / 2;
self.y = 2732 - cupGraphics.height / 2;
self.intersects = function (ball) {
var bounds = self.getBounds();
var ballBounds = ball.getBounds();
if (bounds.x < ballBounds.x + ballBounds.width && bounds.x + bounds.width > ballBounds.x && bounds.y < ballBounds.y + ballBounds.height && bounds.y + bounds.height > ballBounds.y) {
LK.setScore(LK.getScore() + ball.scoreValue);
timerSeconds += 1; // Add 1 second to the timer
updateScoreDisplay();
timerTxt.setText(timerSeconds.toString()); // Update the timer display instantly
LK.effects.flashObject(ball, 0xffff00, 300); // Add a yellow glow effect to the ball for 300ms when caught
self.animate(); // Trigger cup animation when a ball is collected
LK.effects.flashObject(ball, 0xffff00, 300); // Add a yellow glow effect to the ball for 300ms when caught
self.animate(); // Trigger cup animation when a ball is collected
return true;
}
return false;
};
self.animate = function () {
var originalScaleX = self.scale.x;
var originalScaleY = self.scale.y;
var scaleFactor = 1.1;
var animationFrames = 7.5;
var currentFrame = 0;
var grow = true;
function updateAnimation() {
if (currentFrame < animationFrames) {
if (grow) {
self.scale.x = originalScaleX * (1 + (scaleFactor - 1) * (currentFrame / animationFrames));
self.scale.y = originalScaleY * (1 + (scaleFactor - 1) * (currentFrame / animationFrames));
} else {
self.scale.x = originalScaleX * (1 + (scaleFactor - 1) * (1 - currentFrame / animationFrames));
self.scale.y = originalScaleY * (1 + (scaleFactor - 1) * (1 - currentFrame / animationFrames));
}
currentFrame++;
} else if (grow) {
grow = false;
currentFrame = 0;
} else {
self.scale.x = originalScaleX;
self.scale.y = originalScaleY;
LK.off('tick', updateAnimation);
}
}
if (!self.animationCooldown) {
self.animationCooldown = true;
LK.setTimeout(function () {
self.animationCooldown = false;
}, 500);
LK.on('tick', updateAnimation);
}
};
});
// CupGraphics class for enhanced cup visuals
var CupGraphics = Container.expand(function () {
var self = Container.call(this);
var graphics = self.createAsset('cup', 'Cup to catch balls', 0.5, 1);
// Additional visual enhancements can be added here
});
/****
* Initialize Game
****/
// Replace basic cup graphics with enhanced CupGraphics
var game = new LK.Game({
backgroundColor: 0x00000000 //Set game background to invisible
});
/****
* Game Code
****/
// Create and set the new background
// Function to create a splash effect
// Replace basic splash graphics with enhanced SplashGraphics
// Function to create a splash effect
game.showSettingsGUI = function () {
var settingsGUI = new SettingsGUI();
settingsGUI.x = 2048 / 2;
settingsGUI.y = 2732 / 2;
LK.gui.overlay.addChild(settingsGUI);
};
var particlePool = new ParticlePool();
function createSplash(x, y) {
var splash = new Splash();
splash.x = x;
splash.y = y;
game.addChild(splash);
}
var background = game.createAsset('background', 'Game background', 0, 0);
background.x = 0; // Set to top left on the x-axis
background.y = 0; // Set to top left on the y-axis
game.addChild(background);
// Initialize game elements
var balls = [];
var cup = game.addChild(new Cup());
var score = 0;
var requiredScore = 10; // The score needed to win
var scoreTxt = new Text2(score.toString(), {
size: 150,
fill: "#ffffff"
});
var timerTxt = new Text2('60', {
size: 100,
fill: "#ffffff"
});
scoreTxt.anchor.set(0.5, 0);
timerTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
LK.gui.top.addChild(timerTxt);
timerTxt.y = scoreTxt.height + 20;
// Add settings button to the top left of the screen
var settingsButton = new SettingsButton();
game.addChild(settingsButton);
// Create a function to update the score display
function updateScoreDisplay() {
scoreTxt.setText(score.toString());
}
// Create a function to add a new ball or coffee bean
function addBall() {
var randomChance = Math.random();
if (randomChance < 0.05) {
var coffeeBean = new CoffeeBean();
balls.push(coffeeBean);
game.addChild(coffeeBean);
} else if (randomChance >= 0.05 && randomChance < 0.06) {
var timerItem = new TimerItem();
balls.push(timerItem);
game.addChild(timerItem);
} else {
var ball = new Ball();
balls.push(ball);
game.addChild(ball);
}
}
// Create a function to end the game
function endGame() {
// Game over logic will be handled in the tick function when timer hits 0
}
// Create a function to handle ball and cup collisions
function handleCollisions() {
for (var i = balls.length - 1; i >= 0; i--) {
if (cup.intersects(balls[i])) {
if (balls[i] instanceof TimerItem) {
timerSeconds += 10; // Add 10 seconds to the timer
} else {
score += balls[i].scoreValue;
updateScoreDisplay();
}
createSplash(balls[i].x, balls[i].y);
balls[i].destroy();
balls.splice(i, 1);
} else if (balls[i].y > 2732) {
balls[i].destroy();
balls.splice(i, 1);
}
}
}
// Create a function to handle dragging the cup
function handleDrag(obj) {
var event = obj.event;
var pos = event.getLocalPosition(game);
cup.x = pos.x;
}
// Add event listeners for dragging the cup
game.on('down', function (obj) {
handleDrag(obj);
});
game.on('move', function (obj) {
handleDrag(obj);
});
// Main game loop
// Removed the gameTimer as the game over logic will be handled in the tick function
var timerSeconds = 60;
LK.on('tick', function () {
// Update ball positions
balls.forEach(function (ball) {
ball.move();
});
// Update timer display and check for game over
if (LK.ticks % 60 == 0) {
if (timerSeconds > 0) {
timerSeconds--;
timerTxt.setText(timerSeconds.toString());
} else {
LK.effects.flashScreen(score >= requiredScore ? 0x00ff00 : 0xff0000, 1000);
LK.showGameOver();
}
}
// Handle collisions
handleCollisions();
// Add new ball
if (LK.ticks % 60 == 0) {
// Every second
addBall();
}
});
Coffee droplet.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. Shadows at the bottom.
Have the coffee cup open at the top
High end Coffee Shop. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. Shadows at the bottom.
Coffee trail going vertical. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. Shadows at the bottom.
Coffee splashing effect. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No Shadows.
Black circle with a bit of transparency.
Coffee Bean With Nothing Else. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Clock, Nothing else in the image.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A white particle trail, vertical. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Remove the plus from this image
Red X. Nothing else.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
White rectangle, curved corners. Small black border. Simple, modern. Aspect ratio 1550 * 2500.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Include only the spike.
Remove the bottom part that is not coming from the center explosion
Rectangular coffee themed start button. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Remove the random stuff below the question mark
Coffee themed button which has the text "gamemode". Make the aspect ratio of this button 5:1. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.