/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1"); /**** * Classes ****/ // Bee (player) var Bee = Container.expand(function () { var self = Container.call(this); var beeSprite = self.attachAsset('bee', { anchorX: 0.5, anchorY: 0.5 }); self.radius = 60; // for collision // Flap animation self.flapTween = function () { tween(beeSprite, { scaleY: 0.85 }, { duration: 120, easing: tween.easeIn, onFinish: function onFinish() { tween(beeSprite, { scaleY: 1 }, { duration: 120, easing: tween.easeOut }); } }); }; // Called every tick self.update = function () { // Bee can have a little idle movement self.y += Math.sin(LK.ticks / 20) * 0.7; }; return self; }); // Deadzone (danger) var Deadzone = Container.expand(function () { var self = Container.call(this); var sprite = self.attachAsset('deadzone', { anchorX: 0.5, anchorY: 0.5 }); self.radius = 100; // Move horizontally self.dir = Math.random() > 0.5 ? 1 : -1; self.update = function () { self.x += self.dir * 4; if (self.x < 200) self.dir = 1; if (self.x > 2048 - 200) self.dir = -1; }; return self; }); // Flower var Flower = Container.expand(function () { var self = Container.call(this); self.pollinated = false; self.withered = false; self.timer = 0; self.flowerSprite = self.attachAsset('flower', { anchorX: 0.5, anchorY: 0.5 }); self.radius = 55; // Ajoute la barre de fanaison sous la fleur self.witherBarBg = self.attachAsset('witherBarBg', { anchorX: 0.5, anchorY: 0 }); self.witherBarBg.y = 60; self.witherBar = self.attachAsset('witherBar', { anchorX: 0.5, anchorY: 0 }); self.witherBar.y = 62; // Pollinate the flower self.pollinate = function () { if (self.pollinated || self.withered) return; self.pollinated = true; self.flowerSprite.destroy(); self.flowerSprite = self.attachAsset('flower_pollinated', { anchorX: 0.5, anchorY: 0.5 }); // Animate illumination self.flowerSprite.alpha = 0.5; tween(self.flowerSprite, { alpha: 1 }, { duration: 400, easing: tween.easeOut }); // Barre verte et pleine self.witherBar.width = 58; self.witherBar.tint = 0x8fff6f; self.witherBar.alpha = 0.8; }; // Wither the flower self.wither = function () { if (self.pollinated || self.withered) return; self.withered = true; tween(self.flowerSprite, { alpha: 0.2 }, { duration: 600, easing: tween.linear }); // Barre grise et vide self.witherBar.width = 10; self.witherBar.tint = 0x888888; self.witherBar.alpha = 0.4; }; // Called every tick self.update = function () { if (!self.pollinated && !self.withered) { self.timer++; if (self.timer > 480) { // 8 seconds to wither self.wither(); } // Met à jour la barre de fanaison var t = Math.min(1, self.timer / 480); self.witherBar.width = 58 * (1 - t); if (t < 0.5) self.witherBar.tint = 0xffe066; // jaune else if (t < 0.85) self.witherBar.tint = 0xffa500; // orange else self.witherBar.tint = 0x8b4513; // brun self.witherBar.alpha = 0.9; } else if (self.pollinated) { self.witherBar.width = 58; self.witherBar.tint = 0x8fff6f; self.witherBar.alpha = 0.8; } else if (self.withered) { self.witherBar.width = 10; self.witherBar.tint = 0x888888; self.witherBar.alpha = 0.4; } }; return self; }); // Pesticide (danger) var Pesticide = Container.expand(function () { var self = Container.call(this); var sprite = self.attachAsset('pesticide', { anchorX: 0.5, anchorY: 0.5 }); self.radius = 45; // Move downwards self.update = function () { self.y += 7; }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0xc6f7e2 // Pastel green-blue }); /**** * Game Code ****/ // Play background music // Bee (player) // Flower (target) // Pollinated flower (illuminated) // Pesticide (danger) // Dead zone (danger) // Sound for pollination // Music (background) LK.playMusic('nature_bg'); // Initialize LK score system LK.setScore(0); // Score and UI - use LK score system var score = LK.getScore(); var scoreTxt = new Text2('0', { size: 120, fill: "#222" }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); // Système de niveaux var level = 1; var pollinatedThisLevel = 0; var pollinateGoal = 2; // Niveau 1→2 : 2 fleurs // Affiche le niveau et le nombre de fleurs restantes à butiner en haut de l'écran var levelTxt = new Text2('', { size: 80, fill: "#3a3" }); levelTxt.anchor.set(0.5, 0); // Place la bannière du niveau au centre du jeu (canvas) levelTxt.x = 2048 / 2; levelTxt.y = 40; game.addChild(levelTxt); // Met à jour l'affichage du niveau et du nombre de fleurs restantes à butiner function updateLevelTxt() { var reste = Math.max(0, pollinateGoal - pollinatedThisLevel); levelTxt.setText('Niveau ' + level + ' | Fleurs à butiner : ' + reste + '/' + pollinateGoal); } scoreTxt.setText(LK.getScore()); updateLevelTxt(); function nextLevel() { level += 1; pollinatedThisLevel = 0; pollinateGoal += 3; updateLevelTxt(); // Check win condition - niveau 666 (nombre du diable MDR) if (level > 666) { LK.showYouWin(); return; } // Recrée les fleurs spawnFlowers(); // Reset dangers for (var i = 0; i < pesticides.length; i++) { pesticides[i].destroy(); } for (var i = 0; i < deadzones.length; i++) { deadzones[i].destroy(); } pesticides = []; deadzones = []; spawnPesticide(); spawnDeadzone(); witheredCount = 0; scoreTxt.setText(LK.getScore()); } // Flowers, dangers, and bee var flowers = []; var pesticides = []; var deadzones = []; var bee = new Bee(); game.addChild(bee); // Place bee at start bee.x = 2048 / 2; bee.y = 2732 - 350; // --- Editeur visuel de fanaison --- var flowerEditorBg = new Container(); var flowerEditorBars = []; var flowerEditorMargin = 30; var flowerEditorWidth = 2048 - 2 * flowerEditorMargin; var flowerEditorHeight = 60; var flowerEditorY = 180; // sous le score LK.gui.top.addChild(flowerEditorBg); function updateFlowerEditor() { // Nettoie les barres précédentes for (var i = 0; i < flowerEditorBars.length; i++) { if (flowerEditorBars[i].parent) flowerEditorBars[i].parent.removeChild(flowerEditorBars[i]); } flowerEditorBars = []; // Affiche une barre par fleur var n = flowers.length; if (n === 0) return; var barW = flowerEditorWidth / n - 6; for (var i = 0; i < n; i++) { var f = flowers[i]; var bar = new Container(); // Couleur selon état var color = 0x8fff6f; // vert pollinisé if (f.withered) color = 0x888888; // gris fané else if (!f.pollinated) { // Gradient du jaune vif au orange puis brun var t = Math.min(1, f.timer / 480); if (t < 0.5) color = 0xffe066; // jaune else if (t < 0.85) color = 0xffa500; // orange else color = 0x8b4513; // brun } // Rectangle var barRect = LK.getAsset('flowerEditorBar', {}); barRect.width = barW; barRect.height = flowerEditorHeight; barRect.tint = color; bar.addChild(barRect); // Si pollinisé, petit effet if (f.pollinated) { barRect.alpha = 0.7 + 0.3 * Math.sin(LK.ticks / 10 + i); } else if (f.withered) { barRect.alpha = 0.4; } else { barRect.alpha = 0.9; } bar.x = flowerEditorMargin + i * (barW + 6); bar.y = flowerEditorY; LK.gui.top.addChild(bar); flowerEditorBars.push(bar); } } // Place flowers in a grid, but with some randomness function spawnFlowers() { flowers = []; var rows = 4; var cols = 5; var marginX = 300; var marginY = 400; var spacingX = (2048 - 2 * marginX) / (cols - 1); var spacingY = (1500 - marginY) / (rows - 1); for (var r = 0; r < rows; r++) { for (var c = 0; c < cols; c++) { var f = new Flower(); f.x = marginX + c * spacingX + (Math.random() - 0.5) * 60; f.y = 600 + r * spacingY + (Math.random() - 0.5) * 60; flowers.push(f); game.addChild(f); } } } spawnFlowers(); // Spawn initial dangers function spawnPesticide() { var p = new Pesticide(); p.x = 200 + Math.random() * (2048 - 400); p.y = -100; pesticides.push(p); game.addChild(p); } function spawnDeadzone() { var d = new Deadzone(); d.x = 400 + Math.random() * (2048 - 800); d.y = 1200 + Math.random() * 800; deadzones.push(d); game.addChild(d); } spawnPesticide(); spawnDeadzone(); // Timers for spawning dangers var pesticideTimer = 0; var deadzoneTimer = 0; // Track dragging var draggingBee = false; // Track withered flowers var witheredCount = 0; // Helper: collision between two objects with .x, .y, .radius function isColliding(a, b) { var dx = a.x - b.x; var dy = a.y - b.y; var dist = Math.sqrt(dx * dx + dy * dy); return dist < a.radius + b.radius; } // Move handler (drag bee) function handleMove(x, y, obj) { if (draggingBee) { // Clamp bee inside game area var bx = Math.max(bee.radius, Math.min(2048 - bee.radius, x)); var by = Math.max(bee.radius + 100, Math.min(2732 - bee.radius, y)); bee.x = bx; bee.y = by; bee.flapTween(); } } game.move = handleMove; // Down handler (start drag if on bee) game.down = function (x, y, obj) { var dx = x - bee.x; var dy = y - bee.y; if (dx * dx + dy * dy < bee.radius * bee.radius) { draggingBee = true; handleMove(x, y, obj); } }; // Up handler (stop drag) game.up = function (x, y, obj) { draggingBee = false; }; // Main update loop game.update = function () { // Update bee bee.update(); // Update flowers for (var i = 0; i < flowers.length; i++) { flowers[i].update(); } // Met à jour l'éditeur visuel updateFlowerEditor(); // Update dangers for (var i = pesticides.length - 1; i >= 0; i--) { var p = pesticides[i]; p.update(); // Remove if off screen if (p.y > 2732 + 100) { p.destroy(); pesticides.splice(i, 1); } } for (var i = deadzones.length - 1; i >= 0; i--) { deadzones[i].update(); } // Spawn new dangers pesticideTimer++; if (pesticideTimer > 90 + Math.random() * 60) { // every 1.5-2.5s spawnPesticide(); pesticideTimer = 0; } deadzoneTimer++; if (deadzoneTimer > 300 + Math.random() * 200) { // every 5-8s spawnDeadzone(); deadzoneTimer = 0; } // Check bee-flower collision for (var i = 0; i < flowers.length; i++) { var f = flowers[i]; if (!f.pollinated && !f.withered && isColliding(bee, f)) { f.pollinate(); LK.getSound('pollinate').play(); LK.setScore(LK.getScore() + 1); pollinatedThisLevel += 1; scoreTxt.setText(LK.getScore()); updateLevelTxt(); // Vérifie si l'objectif de niveau est atteint if (pollinatedThisLevel >= pollinateGoal) { // Passe au niveau suivant LK.effects.flashScreen(0x8fff6f, 800); LK.setTimeout(function () { nextLevel(); }, 900); return; } // Animate bee tween(bee, { scaleX: 1.15, scaleY: 0.85 }, { duration: 120, easing: tween.easeIn, onFinish: function onFinish() { tween(bee, { scaleX: 1, scaleY: 1 }, { duration: 120, easing: tween.easeOut }); } }); } } // Check bee-pesticide collision for (var i = 0; i < pesticides.length; i++) { if (isColliding(bee, pesticides[i])) { LK.getSound('danger').play(); LK.effects.flashScreen(0x4444ff, 800); LK.showGameOver(); return; } } // Check bee-deadzone collision for (var i = 0; i < deadzones.length; i++) { if (isColliding(bee, deadzones[i])) { LK.getSound('danger').play(); LK.effects.flashScreen(0x888888, 800); LK.showGameOver(); return; } } // Check withered flowers var newWithered = 0; for (var i = 0; i < flowers.length; i++) { if (flowers[i].withered) newWithered++; } if (newWithered !== witheredCount) { witheredCount = newWithered; // If too many withered, game over if (witheredCount >= 5) { LK.effects.flashScreen(0x888888, 1200); LK.showGameOver(); return; } } // Condition de défaite : si toutes les fleurs sont fanées ou pollinisées et objectif non atteint var allFlowersFinished = true; var availableFlowers = 0; for (var i = 0; i < flowers.length; i++) { if (!flowers[i].pollinated && !flowers[i].withered) { allFlowersFinished = false; availableFlowers++; } } if (allFlowersFinished && pollinatedThisLevel < pollinateGoal) { // Pas assez de fleurs pollinisées et plus de fleurs disponibles : game over LK.effects.flashScreen(0xff2222, 1200); LK.showGameOver(); return; } };
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
// Bee (player)
var Bee = Container.expand(function () {
var self = Container.call(this);
var beeSprite = self.attachAsset('bee', {
anchorX: 0.5,
anchorY: 0.5
});
self.radius = 60; // for collision
// Flap animation
self.flapTween = function () {
tween(beeSprite, {
scaleY: 0.85
}, {
duration: 120,
easing: tween.easeIn,
onFinish: function onFinish() {
tween(beeSprite, {
scaleY: 1
}, {
duration: 120,
easing: tween.easeOut
});
}
});
};
// Called every tick
self.update = function () {
// Bee can have a little idle movement
self.y += Math.sin(LK.ticks / 20) * 0.7;
};
return self;
});
// Deadzone (danger)
var Deadzone = Container.expand(function () {
var self = Container.call(this);
var sprite = self.attachAsset('deadzone', {
anchorX: 0.5,
anchorY: 0.5
});
self.radius = 100;
// Move horizontally
self.dir = Math.random() > 0.5 ? 1 : -1;
self.update = function () {
self.x += self.dir * 4;
if (self.x < 200) self.dir = 1;
if (self.x > 2048 - 200) self.dir = -1;
};
return self;
});
// Flower
var Flower = Container.expand(function () {
var self = Container.call(this);
self.pollinated = false;
self.withered = false;
self.timer = 0;
self.flowerSprite = self.attachAsset('flower', {
anchorX: 0.5,
anchorY: 0.5
});
self.radius = 55;
// Ajoute la barre de fanaison sous la fleur
self.witherBarBg = self.attachAsset('witherBarBg', {
anchorX: 0.5,
anchorY: 0
});
self.witherBarBg.y = 60;
self.witherBar = self.attachAsset('witherBar', {
anchorX: 0.5,
anchorY: 0
});
self.witherBar.y = 62;
// Pollinate the flower
self.pollinate = function () {
if (self.pollinated || self.withered) return;
self.pollinated = true;
self.flowerSprite.destroy();
self.flowerSprite = self.attachAsset('flower_pollinated', {
anchorX: 0.5,
anchorY: 0.5
});
// Animate illumination
self.flowerSprite.alpha = 0.5;
tween(self.flowerSprite, {
alpha: 1
}, {
duration: 400,
easing: tween.easeOut
});
// Barre verte et pleine
self.witherBar.width = 58;
self.witherBar.tint = 0x8fff6f;
self.witherBar.alpha = 0.8;
};
// Wither the flower
self.wither = function () {
if (self.pollinated || self.withered) return;
self.withered = true;
tween(self.flowerSprite, {
alpha: 0.2
}, {
duration: 600,
easing: tween.linear
});
// Barre grise et vide
self.witherBar.width = 10;
self.witherBar.tint = 0x888888;
self.witherBar.alpha = 0.4;
};
// Called every tick
self.update = function () {
if (!self.pollinated && !self.withered) {
self.timer++;
if (self.timer > 480) {
// 8 seconds to wither
self.wither();
}
// Met à jour la barre de fanaison
var t = Math.min(1, self.timer / 480);
self.witherBar.width = 58 * (1 - t);
if (t < 0.5) self.witherBar.tint = 0xffe066; // jaune
else if (t < 0.85) self.witherBar.tint = 0xffa500; // orange
else self.witherBar.tint = 0x8b4513; // brun
self.witherBar.alpha = 0.9;
} else if (self.pollinated) {
self.witherBar.width = 58;
self.witherBar.tint = 0x8fff6f;
self.witherBar.alpha = 0.8;
} else if (self.withered) {
self.witherBar.width = 10;
self.witherBar.tint = 0x888888;
self.witherBar.alpha = 0.4;
}
};
return self;
});
// Pesticide (danger)
var Pesticide = Container.expand(function () {
var self = Container.call(this);
var sprite = self.attachAsset('pesticide', {
anchorX: 0.5,
anchorY: 0.5
});
self.radius = 45;
// Move downwards
self.update = function () {
self.y += 7;
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0xc6f7e2 // Pastel green-blue
});
/****
* Game Code
****/
// Play background music
// Bee (player)
// Flower (target)
// Pollinated flower (illuminated)
// Pesticide (danger)
// Dead zone (danger)
// Sound for pollination
// Music (background)
LK.playMusic('nature_bg');
// Initialize LK score system
LK.setScore(0);
// Score and UI - use LK score system
var score = LK.getScore();
var scoreTxt = new Text2('0', {
size: 120,
fill: "#222"
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
// Système de niveaux
var level = 1;
var pollinatedThisLevel = 0;
var pollinateGoal = 2; // Niveau 1→2 : 2 fleurs
// Affiche le niveau et le nombre de fleurs restantes à butiner en haut de l'écran
var levelTxt = new Text2('', {
size: 80,
fill: "#3a3"
});
levelTxt.anchor.set(0.5, 0);
// Place la bannière du niveau au centre du jeu (canvas)
levelTxt.x = 2048 / 2;
levelTxt.y = 40;
game.addChild(levelTxt);
// Met à jour l'affichage du niveau et du nombre de fleurs restantes à butiner
function updateLevelTxt() {
var reste = Math.max(0, pollinateGoal - pollinatedThisLevel);
levelTxt.setText('Niveau ' + level + ' | Fleurs à butiner : ' + reste + '/' + pollinateGoal);
}
scoreTxt.setText(LK.getScore());
updateLevelTxt();
function nextLevel() {
level += 1;
pollinatedThisLevel = 0;
pollinateGoal += 3;
updateLevelTxt();
// Check win condition - niveau 666 (nombre du diable MDR)
if (level > 666) {
LK.showYouWin();
return;
}
// Recrée les fleurs
spawnFlowers();
// Reset dangers
for (var i = 0; i < pesticides.length; i++) {
pesticides[i].destroy();
}
for (var i = 0; i < deadzones.length; i++) {
deadzones[i].destroy();
}
pesticides = [];
deadzones = [];
spawnPesticide();
spawnDeadzone();
witheredCount = 0;
scoreTxt.setText(LK.getScore());
}
// Flowers, dangers, and bee
var flowers = [];
var pesticides = [];
var deadzones = [];
var bee = new Bee();
game.addChild(bee);
// Place bee at start
bee.x = 2048 / 2;
bee.y = 2732 - 350;
// --- Editeur visuel de fanaison ---
var flowerEditorBg = new Container();
var flowerEditorBars = [];
var flowerEditorMargin = 30;
var flowerEditorWidth = 2048 - 2 * flowerEditorMargin;
var flowerEditorHeight = 60;
var flowerEditorY = 180; // sous le score
LK.gui.top.addChild(flowerEditorBg);
function updateFlowerEditor() {
// Nettoie les barres précédentes
for (var i = 0; i < flowerEditorBars.length; i++) {
if (flowerEditorBars[i].parent) flowerEditorBars[i].parent.removeChild(flowerEditorBars[i]);
}
flowerEditorBars = [];
// Affiche une barre par fleur
var n = flowers.length;
if (n === 0) return;
var barW = flowerEditorWidth / n - 6;
for (var i = 0; i < n; i++) {
var f = flowers[i];
var bar = new Container();
// Couleur selon état
var color = 0x8fff6f; // vert pollinisé
if (f.withered) color = 0x888888; // gris fané
else if (!f.pollinated) {
// Gradient du jaune vif au orange puis brun
var t = Math.min(1, f.timer / 480);
if (t < 0.5) color = 0xffe066; // jaune
else if (t < 0.85) color = 0xffa500; // orange
else color = 0x8b4513; // brun
}
// Rectangle
var barRect = LK.getAsset('flowerEditorBar', {});
barRect.width = barW;
barRect.height = flowerEditorHeight;
barRect.tint = color;
bar.addChild(barRect);
// Si pollinisé, petit effet
if (f.pollinated) {
barRect.alpha = 0.7 + 0.3 * Math.sin(LK.ticks / 10 + i);
} else if (f.withered) {
barRect.alpha = 0.4;
} else {
barRect.alpha = 0.9;
}
bar.x = flowerEditorMargin + i * (barW + 6);
bar.y = flowerEditorY;
LK.gui.top.addChild(bar);
flowerEditorBars.push(bar);
}
}
// Place flowers in a grid, but with some randomness
function spawnFlowers() {
flowers = [];
var rows = 4;
var cols = 5;
var marginX = 300;
var marginY = 400;
var spacingX = (2048 - 2 * marginX) / (cols - 1);
var spacingY = (1500 - marginY) / (rows - 1);
for (var r = 0; r < rows; r++) {
for (var c = 0; c < cols; c++) {
var f = new Flower();
f.x = marginX + c * spacingX + (Math.random() - 0.5) * 60;
f.y = 600 + r * spacingY + (Math.random() - 0.5) * 60;
flowers.push(f);
game.addChild(f);
}
}
}
spawnFlowers();
// Spawn initial dangers
function spawnPesticide() {
var p = new Pesticide();
p.x = 200 + Math.random() * (2048 - 400);
p.y = -100;
pesticides.push(p);
game.addChild(p);
}
function spawnDeadzone() {
var d = new Deadzone();
d.x = 400 + Math.random() * (2048 - 800);
d.y = 1200 + Math.random() * 800;
deadzones.push(d);
game.addChild(d);
}
spawnPesticide();
spawnDeadzone();
// Timers for spawning dangers
var pesticideTimer = 0;
var deadzoneTimer = 0;
// Track dragging
var draggingBee = false;
// Track withered flowers
var witheredCount = 0;
// Helper: collision between two objects with .x, .y, .radius
function isColliding(a, b) {
var dx = a.x - b.x;
var dy = a.y - b.y;
var dist = Math.sqrt(dx * dx + dy * dy);
return dist < a.radius + b.radius;
}
// Move handler (drag bee)
function handleMove(x, y, obj) {
if (draggingBee) {
// Clamp bee inside game area
var bx = Math.max(bee.radius, Math.min(2048 - bee.radius, x));
var by = Math.max(bee.radius + 100, Math.min(2732 - bee.radius, y));
bee.x = bx;
bee.y = by;
bee.flapTween();
}
}
game.move = handleMove;
// Down handler (start drag if on bee)
game.down = function (x, y, obj) {
var dx = x - bee.x;
var dy = y - bee.y;
if (dx * dx + dy * dy < bee.radius * bee.radius) {
draggingBee = true;
handleMove(x, y, obj);
}
};
// Up handler (stop drag)
game.up = function (x, y, obj) {
draggingBee = false;
};
// Main update loop
game.update = function () {
// Update bee
bee.update();
// Update flowers
for (var i = 0; i < flowers.length; i++) {
flowers[i].update();
}
// Met à jour l'éditeur visuel
updateFlowerEditor();
// Update dangers
for (var i = pesticides.length - 1; i >= 0; i--) {
var p = pesticides[i];
p.update();
// Remove if off screen
if (p.y > 2732 + 100) {
p.destroy();
pesticides.splice(i, 1);
}
}
for (var i = deadzones.length - 1; i >= 0; i--) {
deadzones[i].update();
}
// Spawn new dangers
pesticideTimer++;
if (pesticideTimer > 90 + Math.random() * 60) {
// every 1.5-2.5s
spawnPesticide();
pesticideTimer = 0;
}
deadzoneTimer++;
if (deadzoneTimer > 300 + Math.random() * 200) {
// every 5-8s
spawnDeadzone();
deadzoneTimer = 0;
}
// Check bee-flower collision
for (var i = 0; i < flowers.length; i++) {
var f = flowers[i];
if (!f.pollinated && !f.withered && isColliding(bee, f)) {
f.pollinate();
LK.getSound('pollinate').play();
LK.setScore(LK.getScore() + 1);
pollinatedThisLevel += 1;
scoreTxt.setText(LK.getScore());
updateLevelTxt();
// Vérifie si l'objectif de niveau est atteint
if (pollinatedThisLevel >= pollinateGoal) {
// Passe au niveau suivant
LK.effects.flashScreen(0x8fff6f, 800);
LK.setTimeout(function () {
nextLevel();
}, 900);
return;
}
// Animate bee
tween(bee, {
scaleX: 1.15,
scaleY: 0.85
}, {
duration: 120,
easing: tween.easeIn,
onFinish: function onFinish() {
tween(bee, {
scaleX: 1,
scaleY: 1
}, {
duration: 120,
easing: tween.easeOut
});
}
});
}
}
// Check bee-pesticide collision
for (var i = 0; i < pesticides.length; i++) {
if (isColliding(bee, pesticides[i])) {
LK.getSound('danger').play();
LK.effects.flashScreen(0x4444ff, 800);
LK.showGameOver();
return;
}
}
// Check bee-deadzone collision
for (var i = 0; i < deadzones.length; i++) {
if (isColliding(bee, deadzones[i])) {
LK.getSound('danger').play();
LK.effects.flashScreen(0x888888, 800);
LK.showGameOver();
return;
}
}
// Check withered flowers
var newWithered = 0;
for (var i = 0; i < flowers.length; i++) {
if (flowers[i].withered) newWithered++;
}
if (newWithered !== witheredCount) {
witheredCount = newWithered;
// If too many withered, game over
if (witheredCount >= 5) {
LK.effects.flashScreen(0x888888, 1200);
LK.showGameOver();
return;
}
}
// Condition de défaite : si toutes les fleurs sont fanées ou pollinisées et objectif non atteint
var allFlowersFinished = true;
var availableFlowers = 0;
for (var i = 0; i < flowers.length; i++) {
if (!flowers[i].pollinated && !flowers[i].withered) {
allFlowersFinished = false;
availableFlowers++;
}
}
if (allFlowersFinished && pollinatedThisLevel < pollinateGoal) {
// Pas assez de fleurs pollinisées et plus de fleurs disponibles : game over
LK.effects.flashScreen(0xff2222, 1200);
LK.showGameOver();
return;
}
};
Fullscreen modern App Store landscape banner, 16:9, high definition, for a game titled "L’Abeille Messagère" and with the description "Devenez une abeille, semez la lumière en pollinisant les fleurs, évitez les dangers, et sauvez la nature en redonnant vie au champ.". No text on banner!
Fleurs. In-Game asset. 2d. High contrast. No shadows
Danger. In-Game asset. 2d. High contrast. No shadows