User prompt
Lower limit, not upper limit
User prompt
Make the "glass" effect appear even when some jam touches the edge ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Add 2 things: 1: that "Glass" appears when you break a jar and 2: that the glass vanishes effect ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Make the main bread (asset name: Bread) disappear when dead_bread appears
User prompt
The Sprite/Asset "bread_dead" should be the game over,i mean should appear when you lose.
User prompt
Add a hammer power-up to break jams
Code edit (1 edits merged)
Please save this source code
User prompt
Bread vs Jam
Initial prompt
In a strange world, there's a war. Bread versus jam. You are a loaf of bread. Win and earn coins to buy skins.
/****
* Plugins
****/
var storage = LK.import("@upit/storage.v1", {
coins: 0,
selectedSkin: 0
});
/****
* Classes
****/
var Bread = Container.expand(function () {
var self = Container.call(this);
var breadGraphics = self.attachAsset('bread', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
// Bread position is controlled by drag
};
return self;
});
var Jam = Container.expand(function () {
var self = Container.call(this);
var jamGraphics = self.attachAsset('jam', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 3;
self.lastY = self.y;
self.lastIntersecting = false;
self.update = function () {
self.y += self.speed;
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0xFFF8DC
});
/****
* Game Code
****/
// Game state variables
var bread = null;
var jams = [];
var score = 0;
var waveCount = 0;
var jamSpawnRate = 30;
var jamBaseSpeed = 3;
var dragNode = null;
var lastDodgeTime = 0;
// UI elements
var scoreText = new Text2('0', {
size: 140,
fill: '#8B4513'
});
scoreText.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreText);
var waveText = new Text2('Wave: 1', {
size: 100,
fill: '#8B4513'
});
waveText.anchor.set(0.5, 0);
waveText.x = 1024;
LK.gui.top.addChild(waveText);
// Initialize bread at center bottom
bread = game.addChild(new Bread());
bread.x = 1024;
bread.y = 2400;
// Wave progression timer
var waveTimer = LK.setInterval(function () {
waveCount++;
jamSpawnRate = Math.max(15, 30 - waveCount * 2);
jamBaseSpeed = 3 + waveCount * 0.5;
waveText.setText('Wave: ' + waveCount);
}, 8000);
// Jam spawn system
var spawnCounter = 0;
function spawnJam() {
var newJam = new Jam();
newJam.x = Math.random() * 1900 + 50;
newJam.y = -80;
newJam.speed = jamBaseSpeed + (Math.random() * 1 - 0.5);
newJam.lastY = newJam.y;
newJam.lastIntersecting = false;
jams.push(newJam);
game.addChild(newJam);
}
// Game loop
game.update = function () {
// Spawn jams based on current spawn rate
spawnCounter++;
if (spawnCounter >= jamSpawnRate) {
spawnJam();
spawnCounter = 0;
}
// Update and check all jams
for (var i = jams.length - 1; i >= 0; i--) {
var jam = jams[i];
// Off-screen detection
if (jam.lastY >= -100 && jam.y < -100) {
jam.destroy();
jams.splice(i, 1);
continue;
}
// Intersection detection with bread
var currentIntersecting = jam.intersects(bread);
if (!jam.lastIntersecting && currentIntersecting) {
// Collision detected - game over
LK.effects.flashScreen(0xFF0000, 800);
LK.getSound('hit').play();
// Convert score to coins (1 point = 1 coin)
var coinsEarned = Math.floor(score / 10);
storage.coins = (storage.coins || 0) + coinsEarned;
LK.setScore(score);
LK.showGameOver();
}
// Dodge detection - when jam passes bread without collision
if (jam.lastY < bread.y && jam.y >= bread.y && !currentIntersecting) {
if (LK.ticks - lastDodgeTime > 10) {
score++;
scoreText.setText(score);
LK.getSound('dodge').play();
lastDodgeTime = LK.ticks;
}
}
jam.lastY = jam.y;
jam.lastIntersecting = currentIntersecting;
}
};
// Touch/drag controls
game.move = function (x, y, obj) {
if (dragNode) {
dragNode.x = x;
dragNode.y = y;
// Clamp bread position to game area
if (dragNode.x < 60) dragNode.x = 60;
if (dragNode.x > 2048 - 60) dragNode.x = 2048 - 60;
if (dragNode.y < 60) dragNode.y = 60;
if (dragNode.y > 2732 - 60) dragNode.y = 2732 - 60;
}
};
game.down = function (x, y, obj) {
dragNode = bread;
game.move(x, y, obj);
};
game.up = function (x, y, obj) {
dragNode = null;
};
// Start music
LK.playMusic('bgmusic', {
loop: true
}); ===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,158 @@
-/****
+/****
+* Plugins
+****/
+var storage = LK.import("@upit/storage.v1", {
+ coins: 0,
+ selectedSkin: 0
+});
+
+/****
+* Classes
+****/
+var Bread = Container.expand(function () {
+ var self = Container.call(this);
+ var breadGraphics = self.attachAsset('bread', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.update = function () {
+ // Bread position is controlled by drag
+ };
+ return self;
+});
+var Jam = Container.expand(function () {
+ var self = Container.call(this);
+ var jamGraphics = self.attachAsset('jam', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.speed = 3;
+ self.lastY = self.y;
+ self.lastIntersecting = false;
+ self.update = function () {
+ self.y += self.speed;
+ };
+ return self;
+});
+
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000
+ backgroundColor: 0xFFF8DC
+});
+
+/****
+* Game Code
+****/
+// Game state variables
+var bread = null;
+var jams = [];
+var score = 0;
+var waveCount = 0;
+var jamSpawnRate = 30;
+var jamBaseSpeed = 3;
+var dragNode = null;
+var lastDodgeTime = 0;
+// UI elements
+var scoreText = new Text2('0', {
+ size: 140,
+ fill: '#8B4513'
+});
+scoreText.anchor.set(0.5, 0);
+LK.gui.top.addChild(scoreText);
+var waveText = new Text2('Wave: 1', {
+ size: 100,
+ fill: '#8B4513'
+});
+waveText.anchor.set(0.5, 0);
+waveText.x = 1024;
+LK.gui.top.addChild(waveText);
+// Initialize bread at center bottom
+bread = game.addChild(new Bread());
+bread.x = 1024;
+bread.y = 2400;
+// Wave progression timer
+var waveTimer = LK.setInterval(function () {
+ waveCount++;
+ jamSpawnRate = Math.max(15, 30 - waveCount * 2);
+ jamBaseSpeed = 3 + waveCount * 0.5;
+ waveText.setText('Wave: ' + waveCount);
+}, 8000);
+// Jam spawn system
+var spawnCounter = 0;
+function spawnJam() {
+ var newJam = new Jam();
+ newJam.x = Math.random() * 1900 + 50;
+ newJam.y = -80;
+ newJam.speed = jamBaseSpeed + (Math.random() * 1 - 0.5);
+ newJam.lastY = newJam.y;
+ newJam.lastIntersecting = false;
+ jams.push(newJam);
+ game.addChild(newJam);
+}
+// Game loop
+game.update = function () {
+ // Spawn jams based on current spawn rate
+ spawnCounter++;
+ if (spawnCounter >= jamSpawnRate) {
+ spawnJam();
+ spawnCounter = 0;
+ }
+ // Update and check all jams
+ for (var i = jams.length - 1; i >= 0; i--) {
+ var jam = jams[i];
+ // Off-screen detection
+ if (jam.lastY >= -100 && jam.y < -100) {
+ jam.destroy();
+ jams.splice(i, 1);
+ continue;
+ }
+ // Intersection detection with bread
+ var currentIntersecting = jam.intersects(bread);
+ if (!jam.lastIntersecting && currentIntersecting) {
+ // Collision detected - game over
+ LK.effects.flashScreen(0xFF0000, 800);
+ LK.getSound('hit').play();
+ // Convert score to coins (1 point = 1 coin)
+ var coinsEarned = Math.floor(score / 10);
+ storage.coins = (storage.coins || 0) + coinsEarned;
+ LK.setScore(score);
+ LK.showGameOver();
+ }
+ // Dodge detection - when jam passes bread without collision
+ if (jam.lastY < bread.y && jam.y >= bread.y && !currentIntersecting) {
+ if (LK.ticks - lastDodgeTime > 10) {
+ score++;
+ scoreText.setText(score);
+ LK.getSound('dodge').play();
+ lastDodgeTime = LK.ticks;
+ }
+ }
+ jam.lastY = jam.y;
+ jam.lastIntersecting = currentIntersecting;
+ }
+};
+// Touch/drag controls
+game.move = function (x, y, obj) {
+ if (dragNode) {
+ dragNode.x = x;
+ dragNode.y = y;
+ // Clamp bread position to game area
+ if (dragNode.x < 60) dragNode.x = 60;
+ if (dragNode.x > 2048 - 60) dragNode.x = 2048 - 60;
+ if (dragNode.y < 60) dragNode.y = 60;
+ if (dragNode.y > 2732 - 60) dragNode.y = 2732 - 60;
+ }
+};
+game.down = function (x, y, obj) {
+ dragNode = bread;
+ game.move(x, y, obj);
+};
+game.up = function (x, y, obj) {
+ dragNode = null;
+};
+// Start music
+LK.playMusic('bgmusic', {
+ loop: true
});
\ No newline at end of file
Jar of jam. In-Game asset. 2d. High contrast. No shadows
Hammer. In-Game asset. 2d. High contrast. No shadows
Bread with feet and hands with jam on top and it's dead. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
pieces of glass with spilled jam. In-Game asset. 2d. High contrast. No shadows