User prompt
Ajoute un systeÌme de fraise doreÌe : certaines fraises apparaissent a des moments preÌcis (quand le joueur, Lola viens de deÌpenser au moins 10 gf), ces fraises doreÌe sont des fraises qui sont collectable sans combats !
User prompt
Ajoute de nouveaux ennemis au jeu : les abeilles (volent aleÌatoirement 1 a 2 gf tout les 2 tours lors des combats), les araigneÌes posseÌdent le plus gros nombre de pv de tout les ennemis (aleÌatoirement de 90 a 180), les papillons qui font 30% plus de deÌgaÌts que les autres insectes, et les vers de terre qui sont faibles (aleÌatoirement entre 20 et 40 points de vies)
Remix started
Copy Fraisy-plat
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1"); /**** * Classes ****/ var Cake = Container.expand(function () { var self = Container.call(this); var cakeGraphics = self.attachAsset('cake', { anchorX: 0.5, anchorY: 0.5 }); self.hasStrawberry = false; self.strawberryObj = null; self.hasHeart = false; self.heartObj = null; self.spawnStrawberry = function () { if (!self.hasStrawberry && Math.random() < 0.3) { self.hasStrawberry = true; self.strawberryObj = self.addChild(LK.getAsset('strawberry', { anchorX: 0.5, anchorY: 0.5, y: -50 })); } }; self.spawnHeart = function () { if (!self.hasHeart) { self.hasHeart = true; self.heartObj = self.addChild(LK.getAsset('heart', { anchorX: 0.5, anchorY: 0.5, y: -50 })); } }; self.removeStrawberry = function () { if (self.strawberryObj) { self.strawberryObj.destroy(); self.strawberryObj = null; self.hasStrawberry = false; } }; self.removeHeart = function () { if (self.heartObj) { self.heartObj.destroy(); self.heartObj = null; self.hasHeart = false; } }; self.down = function (x, y, obj) { if (!inCombat) { moveLola(self); } }; return self; }); var Charlotte = Container.expand(function () { var self = Container.call(this); var charlotteGraphics = self.attachAsset('charlotte', { anchorX: 0.5, anchorY: 0.5 }); return self; }); var Enemy = Container.expand(function (type) { var self = Container.call(this); var enemyGraphics = self.attachAsset(type, { anchorX: 0.5, anchorY: 0.5 }); self.type = type; // Set health based on enemy type if (type === 'pinkwasp') { self.health = Math.floor(Math.random() * 41) + 30; // 30-70 HP } else if (type === 'mosquito') { self.health = Math.floor(Math.random() * 76) + 45; // 45-120 HP } else { self.health = Math.floor(Math.random() * 101) + 50; // 50-150 HP } self.maxHealth = self.health; self.hasInvokedTwin = false; self.extraAttackTurn = false; self.attack = function () { return Math.floor(Math.random() * 7) + 2; // 2-8 damage }; return self; }); var Lola = Container.expand(function () { var self = Container.call(this); var lolaGraphics = self.attachAsset('lola', { anchorX: 0.5, anchorY: 0.5 }); self.health = 100; self.maxHealth = 100; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x98fb98 }); /**** * Game Code ****/ var lola; var charlotte; var cakes = []; var currentLevel = storage.currentLevel || 1; var strawberriesCollected = 0; var strawberriesNeeded = calculateStrawberriesNeeded(currentLevel); var inCombat = false; var combatScreen = null; var currentEnemy = null; var playerTurn = true; var gfCoins = storage.gfCoins || 0; var heartSpawned = false; var shopOpen = false; var shopScreen = null; function calculateStrawberriesNeeded(level) { if (level === 1) return 5; return Math.pow(2, level - 1) * 5; } // UI Elements var strawberryCounter = new Text2('Strawberries: 0/1', { size: 60, fill: 0x000000 }); strawberryCounter.anchor.set(0.5, 0); LK.gui.top.addChild(strawberryCounter); strawberryCounter.y = 100; var levelText = new Text2('Level 1', { size: 50, fill: 0x000000 }); levelText.anchor.set(1, 0); LK.gui.topRight.addChild(levelText); levelText.x = -50; levelText.y = 50; var gfCounter = new Text2('GF: 0', { size: 50, fill: 0x000000 }); gfCounter.anchor.set(0, 0); LK.gui.topLeft.addChild(gfCounter); gfCounter.x = 120; gfCounter.y = 50; // Shop button var shopButton = LK.gui.bottom.addChild(LK.getAsset('shopButton', { anchorX: 0.5, anchorY: 1, y: -50 })); var shopButtonText = new Text2('Magasin', { size: 40, fill: 0x000000 }); shopButtonText.anchor.set(0.5, 0.5); shopButton.addChild(shopButtonText); // Add custom background var gameBackground = game.addChild(LK.getAsset('gameBackground', { anchorX: 0.5, anchorY: 0.5, x: 1024, y: 1366 })); // Initialize Lola lola = game.addChild(new Lola()); lola.x = 1024; lola.y = 1800; // Create platform cakes var cakePositions = [{ x: 300, y: 2200 }, { x: 700, y: 1900 }, { x: 1100, y: 2000 }, { x: 1500, y: 1700 }, { x: 1800, y: 2100 }, { x: 400, y: 1600 }, { x: 1000, y: 1400 }, { x: 1600, y: 1500 }]; for (var i = 0; i < cakePositions.length; i++) { var cake = game.addChild(new Cake()); cake.x = cakePositions[i].x; cake.y = cakePositions[i].y; cakes.push(cake); } function moveLola(targetCake) { tween(lola, { x: targetCake.x, y: targetCake.y - 80 }, { duration: 500, easing: tween.easeOut, onFinish: function onFinish() { // Award 1 GF for jumping on cake without strawberry or heart if (!targetCake.hasStrawberry && !targetCake.hasHeart) { gfCoins += 1; storage.gfCoins = gfCoins; updateUI(); } checkStrawberryCollection(targetCake); checkHeartCollection(targetCake); } }); } function checkStrawberryCollection(cake) { if (cake.hasStrawberry) { cake.removeStrawberry(); startCombat(); } } function checkHeartCollection(cake) { if (cake.hasHeart) { // Check if player has enough GF if (gfCoins >= 15) { gfCoins -= 15; storage.gfCoins = gfCoins; // Heal 30% of max health var healAmount = Math.floor(lola.maxHealth * 0.3); lola.health = Math.min(lola.maxHealth, lola.health + healAmount); cake.removeHeart(); heartSpawned = false; updateUI(); } } } function startCombat() { inCombat = true; // Create combat background combatScreen = game.addChild(LK.getAsset('combatBackground', { anchorX: 0.5, anchorY: 0.5, x: 1024, y: 1366, alpha: 0.9 })); // Create enemy var rand = Math.random(); var enemyType; if (rand < 0.25) { enemyType = 'ant'; } else if (rand < 0.5) { enemyType = 'beetle'; } else if (rand < 0.75) { enemyType = 'pinkwasp'; } else { enemyType = 'mosquito'; } currentEnemy = combatScreen.addChild(new Enemy(enemyType)); currentEnemy.x = 0; currentEnemy.y = -200; // Show Lola in combat var combatLola = combatScreen.addChild(LK.getAsset('lola', { anchorX: 0.5, anchorY: 0.5, x: 0, y: 200 })); // Combat UI var enemyHealthText = new Text2('Enemy: ' + currentEnemy.health + '/' + currentEnemy.maxHealth, { size: 50, fill: 0x000000 }); enemyHealthText.anchor.set(0.5, 0.5); enemyHealthText.x = 0; enemyHealthText.y = -400; combatScreen.addChild(enemyHealthText); var lolaHealthText = new Text2('Lola: ' + lola.health + '/' + lola.maxHealth, { size: 50, fill: 0x000000 }); lolaHealthText.anchor.set(0.5, 0.5); lolaHealthText.x = 0; lolaHealthText.y = 400; combatScreen.addChild(lolaHealthText); var actionText = new Text2('Tap to Attack!', { size: 60, fill: 0xFF0000 }); actionText.anchor.set(0.5, 0.5); actionText.x = 0; actionText.y = 0; combatScreen.addChild(actionText); // Store references for updates combatScreen.enemyHealthText = enemyHealthText; combatScreen.lolaHealthText = lolaHealthText; combatScreen.actionText = actionText; playerTurn = true; } function playerAttack() { if (!playerTurn || !currentEnemy) return; var damage = Math.floor(Math.random() * 6) + 5; // 5-10 damage currentEnemy.health -= damage; LK.getSound('attack').play(); // Flash enemy red LK.effects.flashObject(currentEnemy, 0xff0000, 300); combatScreen.enemyHealthText.setText('Enemy: ' + Math.max(0, currentEnemy.health) + '/' + currentEnemy.maxHealth); // Check for pink wasp twin summoning before death if (currentEnemy.type === 'pinkwasp' && currentEnemy.health < 30 && currentEnemy.health > 0 && !currentEnemy.hasInvokedTwin && Math.random() < 0.5) { // Spawn twin wasp currentEnemy.hasInvokedTwin = true; var twinWasp = combatScreen.addChild(new Enemy('pinkwasp')); twinWasp.x = 150; twinWasp.y = -200; twinWasp.health = currentEnemy.maxHealth; twinWasp.maxHealth = currentEnemy.maxHealth; // Replace current enemy with twin currentEnemy.destroy(); currentEnemy = twinWasp; combatScreen.enemyHealthText.setText('Enemy: ' + currentEnemy.health + '/' + currentEnemy.maxHealth); combatScreen.actionText.setText('Twin wasp appears!'); playerTurn = false; LK.setTimeout(function () { playerTurn = true; combatScreen.actionText.setText('Tap to Attack!'); }, 1500); return; } if (currentEnemy.health <= 0) { // Victory strawberriesCollected++; gfCoins += 5; // Award 5 GF for collecting strawberry storage.gfCoins = gfCoins; // Check if heart should spawn after combat if (lola.health < 30 && !heartSpawned) { spawnHeartOnRandomCake(); } updateUI(); LK.getSound('victory').play(); endCombat(); checkLevelComplete(); } else { // Enemy turn playerTurn = false; combatScreen.actionText.setText('Enemy attacks...'); LK.setTimeout(function () { enemyAttack(); }, 1000); } } function enemyAttack() { if (!currentEnemy) return; var damage = currentEnemy.attack(); lola.health -= damage; // Flash Lola red LK.effects.flashObject(lola, 0xff0000, 300); combatScreen.lolaHealthText.setText('Lola: ' + Math.max(0, lola.health) + '/' + lola.maxHealth); if (lola.health <= 0) { // Game Over LK.showGameOver(); } else { // Check if mosquito gets extra attack if (currentEnemy.type === 'mosquito' && !currentEnemy.extraAttackTurn && Math.random() < 0.3) { currentEnemy.extraAttackTurn = true; combatScreen.actionText.setText('Mosquito drains blood! Extra attack!'); LK.setTimeout(function () { var secondDamage = currentEnemy.attack(); lola.health -= secondDamage; LK.effects.flashObject(lola, 0xff0000, 300); combatScreen.lolaHealthText.setText('Lola: ' + Math.max(0, lola.health) + '/' + lola.maxHealth); if (lola.health <= 0) { LK.showGameOver(); } else { playerTurn = true; combatScreen.actionText.setText('Tap to Attack!'); } currentEnemy.extraAttackTurn = false; }, 1000); } else { // Player turn playerTurn = true; combatScreen.actionText.setText('Tap to Attack!'); } } } function endCombat() { inCombat = false; if (combatScreen) { combatScreen.destroy(); combatScreen = null; } currentEnemy = null; } function checkLevelComplete() { if (strawberriesCollected >= strawberriesNeeded) { advanceLevel(); } } function spawnCharlotte() { if (!charlotte) { charlotte = game.addChild(new Charlotte()); charlotte.x = 1024; charlotte.y = 1000; // Add sparkle effect LK.effects.flashObject(charlotte, 0xffff00, 1000); } } function spawnHeartOnRandomCake() { var availableCakes = cakes.filter(function (cake) { return !cake.hasStrawberry && !cake.hasHeart; }); if (availableCakes.length > 0) { var randomCake = availableCakes[Math.floor(Math.random() * availableCakes.length)]; randomCake.spawnHeart(); heartSpawned = true; } } var charlotteMessageScreen = null; function advanceLevel() { // Create Charlotte message screen charlotteMessageScreen = game.addChild(LK.getAsset('combatBackground', { anchorX: 0.5, anchorY: 0.5, x: 1024, y: 1366, alpha: 0.95 })); // Show Charlotte's message var messageText = new Text2("Merci Lola pour tes fraises! Je vais me faire un bon festin avec mes plats,\nmaintenant j'en veux encore plus! Ca va ĂȘtre la fĂȘte!", { size: 50, fill: 0x000000, align: 'center' }); messageText.anchor.set(0.5, 0.5); messageText.x = 0; messageText.y = -100; charlotteMessageScreen.addChild(messageText); // Close button var closeButton = charlotteMessageScreen.addChild(LK.getAsset('shopButton', { anchorX: 0.5, anchorY: 0.5, x: 0, y: 200, scaleX: 1.5 })); var closeText = new Text2('Fermer', { size: 40, fill: 0x000000 }); closeText.anchor.set(0.5, 0.5); closeButton.addChild(closeText); closeButton.down = function () { completeLevel(); }; } function completeLevel() { // Close Charlotte message screen if (charlotteMessageScreen) { charlotteMessageScreen.destroy(); charlotteMessageScreen = null; } currentLevel++; storage.currentLevel = currentLevel; gfCoins += 10; // Award 10 GF for advancing level storage.gfCoins = gfCoins; strawberriesCollected = 0; strawberriesNeeded = calculateStrawberriesNeeded(currentLevel); // Reset Lola's health lola.health = lola.maxHealth; // Reset heart spawning heartSpawned = false; // Remove Charlotte if (charlotte) { charlotte.destroy(); charlotte = null; } updateUI(); } function openShop() { if (shopOpen || inCombat) return; shopOpen = true; // Create shop background shopScreen = game.addChild(LK.getAsset('combatBackground', { anchorX: 0.5, anchorY: 0.5, x: 1024, y: 1366, alpha: 0.95 })); // Shop title var shopTitle = new Text2('Boutique', { size: 80, fill: 0x000000 }); shopTitle.anchor.set(0.5, 0.5); shopTitle.x = 0; shopTitle.y = -500; shopScreen.addChild(shopTitle); // Shop items var shopItems = [{ name: 'GĂąteau Ă la framboise', health: 30, price: 10, y: -300 }, { name: 'Mousse Ă la fraise', health: 40, price: 15, y: -150 }, { name: 'CrĂšme chantilly', health: 40, price: 20, y: 0 }, { name: 'Yaourt Ă la fraise', health: 50, price: 30, y: 150 }, { name: 'Tiramisu aux fraises', health: 60, price: 45, y: 300 }]; shopScreen.items = []; for (var i = 0; i < shopItems.length; i++) { var item = shopItems[i]; // Item background var itemBg = shopScreen.addChild(LK.getAsset('shopButton', { anchorX: 0.5, anchorY: 0.5, x: -200, y: item.y, scaleX: 1.8, scaleY: 1.2 })); // Item text var itemText = new Text2(item.name + ' (+' + item.health + ' HP)', { size: 35, fill: 0x000000 }); itemText.anchor.set(0.5, 0.5); itemText.x = -200; itemText.y = item.y - 15; shopScreen.addChild(itemText); // Price text var priceText = new Text2('Prix: ' + item.price + ' GF', { size: 30, fill: 0x000000 }); priceText.anchor.set(0.5, 0.5); priceText.x = -200; priceText.y = item.y + 15; shopScreen.addChild(priceText); // Buy button var buyButton = shopScreen.addChild(LK.getAsset('shopButton', { anchorX: 0.5, anchorY: 0.5, x: 200, y: item.y, scaleX: 1.2, scaleY: 0.8 })); var buyText = new Text2('Se servir', { size: 35, fill: 0x000000 }); buyText.anchor.set(0.5, 0.5); buyButton.addChild(buyText); // Store item data buyButton.itemData = item; buyButton.down = function (x, y, obj) { buyItem(this.itemData); }; shopScreen.items.push({ background: itemBg, button: buyButton, data: item }); } // Close button var closeButton = shopScreen.addChild(LK.getAsset('shopButton', { anchorX: 0.5, anchorY: 0.5, x: 0, y: 500, scaleX: 1.5 })); var closeText = new Text2('Fermer', { size: 40, fill: 0x000000 }); closeText.anchor.set(0.5, 0.5); closeButton.addChild(closeText); closeButton.down = function () { closeShop(); }; } function buyItem(item) { if (gfCoins >= item.price) { gfCoins -= item.price; storage.gfCoins = gfCoins; // Heal Lola lola.health = Math.min(lola.maxHealth, lola.health + item.health); updateUI(); // Flash green for successful purchase LK.effects.flashScreen(0x00ff00, 500); } else { // Flash red for insufficient funds LK.effects.flashScreen(0xff0000, 500); } } function closeShop() { if (shopScreen) { shopScreen.destroy(); shopScreen = null; } shopOpen = false; } function updateUI() { strawberryCounter.setText('Strawberries: ' + strawberriesCollected + '/' + strawberriesNeeded); levelText.setText('Level ' + currentLevel); gfCounter.setText('GF: ' + gfCoins); } // Shop button handler shopButton.down = function (x, y, obj) { openShop(); }; // Game event handlers game.down = function (x, y, obj) { if (inCombat && playerTurn) { playerAttack(); } }; // Main game loop game.update = function () { // Spawn strawberries randomly if (LK.ticks % 120 === 0) { // Every 2 seconds var randomCake = cakes[Math.floor(Math.random() * cakes.length)]; randomCake.spawnStrawberry(); } // Check Charlotte collision if (charlotte && lola.intersects(charlotte) && strawberriesCollected >= strawberriesNeeded) { charlotte.destroy(); charlotte = null; advanceLevel(); } }; // Start background music LK.playMusic('backgroundMusic'); // Initialize UI updateUI();
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
var Cake = Container.expand(function () {
var self = Container.call(this);
var cakeGraphics = self.attachAsset('cake', {
anchorX: 0.5,
anchorY: 0.5
});
self.hasStrawberry = false;
self.strawberryObj = null;
self.hasHeart = false;
self.heartObj = null;
self.spawnStrawberry = function () {
if (!self.hasStrawberry && Math.random() < 0.3) {
self.hasStrawberry = true;
self.strawberryObj = self.addChild(LK.getAsset('strawberry', {
anchorX: 0.5,
anchorY: 0.5,
y: -50
}));
}
};
self.spawnHeart = function () {
if (!self.hasHeart) {
self.hasHeart = true;
self.heartObj = self.addChild(LK.getAsset('heart', {
anchorX: 0.5,
anchorY: 0.5,
y: -50
}));
}
};
self.removeStrawberry = function () {
if (self.strawberryObj) {
self.strawberryObj.destroy();
self.strawberryObj = null;
self.hasStrawberry = false;
}
};
self.removeHeart = function () {
if (self.heartObj) {
self.heartObj.destroy();
self.heartObj = null;
self.hasHeart = false;
}
};
self.down = function (x, y, obj) {
if (!inCombat) {
moveLola(self);
}
};
return self;
});
var Charlotte = Container.expand(function () {
var self = Container.call(this);
var charlotteGraphics = self.attachAsset('charlotte', {
anchorX: 0.5,
anchorY: 0.5
});
return self;
});
var Enemy = Container.expand(function (type) {
var self = Container.call(this);
var enemyGraphics = self.attachAsset(type, {
anchorX: 0.5,
anchorY: 0.5
});
self.type = type;
// Set health based on enemy type
if (type === 'pinkwasp') {
self.health = Math.floor(Math.random() * 41) + 30; // 30-70 HP
} else if (type === 'mosquito') {
self.health = Math.floor(Math.random() * 76) + 45; // 45-120 HP
} else {
self.health = Math.floor(Math.random() * 101) + 50; // 50-150 HP
}
self.maxHealth = self.health;
self.hasInvokedTwin = false;
self.extraAttackTurn = false;
self.attack = function () {
return Math.floor(Math.random() * 7) + 2; // 2-8 damage
};
return self;
});
var Lola = Container.expand(function () {
var self = Container.call(this);
var lolaGraphics = self.attachAsset('lola', {
anchorX: 0.5,
anchorY: 0.5
});
self.health = 100;
self.maxHealth = 100;
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x98fb98
});
/****
* Game Code
****/
var lola;
var charlotte;
var cakes = [];
var currentLevel = storage.currentLevel || 1;
var strawberriesCollected = 0;
var strawberriesNeeded = calculateStrawberriesNeeded(currentLevel);
var inCombat = false;
var combatScreen = null;
var currentEnemy = null;
var playerTurn = true;
var gfCoins = storage.gfCoins || 0;
var heartSpawned = false;
var shopOpen = false;
var shopScreen = null;
function calculateStrawberriesNeeded(level) {
if (level === 1) return 5;
return Math.pow(2, level - 1) * 5;
}
// UI Elements
var strawberryCounter = new Text2('Strawberries: 0/1', {
size: 60,
fill: 0x000000
});
strawberryCounter.anchor.set(0.5, 0);
LK.gui.top.addChild(strawberryCounter);
strawberryCounter.y = 100;
var levelText = new Text2('Level 1', {
size: 50,
fill: 0x000000
});
levelText.anchor.set(1, 0);
LK.gui.topRight.addChild(levelText);
levelText.x = -50;
levelText.y = 50;
var gfCounter = new Text2('GF: 0', {
size: 50,
fill: 0x000000
});
gfCounter.anchor.set(0, 0);
LK.gui.topLeft.addChild(gfCounter);
gfCounter.x = 120;
gfCounter.y = 50;
// Shop button
var shopButton = LK.gui.bottom.addChild(LK.getAsset('shopButton', {
anchorX: 0.5,
anchorY: 1,
y: -50
}));
var shopButtonText = new Text2('Magasin', {
size: 40,
fill: 0x000000
});
shopButtonText.anchor.set(0.5, 0.5);
shopButton.addChild(shopButtonText);
// Add custom background
var gameBackground = game.addChild(LK.getAsset('gameBackground', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1366
}));
// Initialize Lola
lola = game.addChild(new Lola());
lola.x = 1024;
lola.y = 1800;
// Create platform cakes
var cakePositions = [{
x: 300,
y: 2200
}, {
x: 700,
y: 1900
}, {
x: 1100,
y: 2000
}, {
x: 1500,
y: 1700
}, {
x: 1800,
y: 2100
}, {
x: 400,
y: 1600
}, {
x: 1000,
y: 1400
}, {
x: 1600,
y: 1500
}];
for (var i = 0; i < cakePositions.length; i++) {
var cake = game.addChild(new Cake());
cake.x = cakePositions[i].x;
cake.y = cakePositions[i].y;
cakes.push(cake);
}
function moveLola(targetCake) {
tween(lola, {
x: targetCake.x,
y: targetCake.y - 80
}, {
duration: 500,
easing: tween.easeOut,
onFinish: function onFinish() {
// Award 1 GF for jumping on cake without strawberry or heart
if (!targetCake.hasStrawberry && !targetCake.hasHeart) {
gfCoins += 1;
storage.gfCoins = gfCoins;
updateUI();
}
checkStrawberryCollection(targetCake);
checkHeartCollection(targetCake);
}
});
}
function checkStrawberryCollection(cake) {
if (cake.hasStrawberry) {
cake.removeStrawberry();
startCombat();
}
}
function checkHeartCollection(cake) {
if (cake.hasHeart) {
// Check if player has enough GF
if (gfCoins >= 15) {
gfCoins -= 15;
storage.gfCoins = gfCoins;
// Heal 30% of max health
var healAmount = Math.floor(lola.maxHealth * 0.3);
lola.health = Math.min(lola.maxHealth, lola.health + healAmount);
cake.removeHeart();
heartSpawned = false;
updateUI();
}
}
}
function startCombat() {
inCombat = true;
// Create combat background
combatScreen = game.addChild(LK.getAsset('combatBackground', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1366,
alpha: 0.9
}));
// Create enemy
var rand = Math.random();
var enemyType;
if (rand < 0.25) {
enemyType = 'ant';
} else if (rand < 0.5) {
enemyType = 'beetle';
} else if (rand < 0.75) {
enemyType = 'pinkwasp';
} else {
enemyType = 'mosquito';
}
currentEnemy = combatScreen.addChild(new Enemy(enemyType));
currentEnemy.x = 0;
currentEnemy.y = -200;
// Show Lola in combat
var combatLola = combatScreen.addChild(LK.getAsset('lola', {
anchorX: 0.5,
anchorY: 0.5,
x: 0,
y: 200
}));
// Combat UI
var enemyHealthText = new Text2('Enemy: ' + currentEnemy.health + '/' + currentEnemy.maxHealth, {
size: 50,
fill: 0x000000
});
enemyHealthText.anchor.set(0.5, 0.5);
enemyHealthText.x = 0;
enemyHealthText.y = -400;
combatScreen.addChild(enemyHealthText);
var lolaHealthText = new Text2('Lola: ' + lola.health + '/' + lola.maxHealth, {
size: 50,
fill: 0x000000
});
lolaHealthText.anchor.set(0.5, 0.5);
lolaHealthText.x = 0;
lolaHealthText.y = 400;
combatScreen.addChild(lolaHealthText);
var actionText = new Text2('Tap to Attack!', {
size: 60,
fill: 0xFF0000
});
actionText.anchor.set(0.5, 0.5);
actionText.x = 0;
actionText.y = 0;
combatScreen.addChild(actionText);
// Store references for updates
combatScreen.enemyHealthText = enemyHealthText;
combatScreen.lolaHealthText = lolaHealthText;
combatScreen.actionText = actionText;
playerTurn = true;
}
function playerAttack() {
if (!playerTurn || !currentEnemy) return;
var damage = Math.floor(Math.random() * 6) + 5; // 5-10 damage
currentEnemy.health -= damage;
LK.getSound('attack').play();
// Flash enemy red
LK.effects.flashObject(currentEnemy, 0xff0000, 300);
combatScreen.enemyHealthText.setText('Enemy: ' + Math.max(0, currentEnemy.health) + '/' + currentEnemy.maxHealth);
// Check for pink wasp twin summoning before death
if (currentEnemy.type === 'pinkwasp' && currentEnemy.health < 30 && currentEnemy.health > 0 && !currentEnemy.hasInvokedTwin && Math.random() < 0.5) {
// Spawn twin wasp
currentEnemy.hasInvokedTwin = true;
var twinWasp = combatScreen.addChild(new Enemy('pinkwasp'));
twinWasp.x = 150;
twinWasp.y = -200;
twinWasp.health = currentEnemy.maxHealth;
twinWasp.maxHealth = currentEnemy.maxHealth;
// Replace current enemy with twin
currentEnemy.destroy();
currentEnemy = twinWasp;
combatScreen.enemyHealthText.setText('Enemy: ' + currentEnemy.health + '/' + currentEnemy.maxHealth);
combatScreen.actionText.setText('Twin wasp appears!');
playerTurn = false;
LK.setTimeout(function () {
playerTurn = true;
combatScreen.actionText.setText('Tap to Attack!');
}, 1500);
return;
}
if (currentEnemy.health <= 0) {
// Victory
strawberriesCollected++;
gfCoins += 5; // Award 5 GF for collecting strawberry
storage.gfCoins = gfCoins;
// Check if heart should spawn after combat
if (lola.health < 30 && !heartSpawned) {
spawnHeartOnRandomCake();
}
updateUI();
LK.getSound('victory').play();
endCombat();
checkLevelComplete();
} else {
// Enemy turn
playerTurn = false;
combatScreen.actionText.setText('Enemy attacks...');
LK.setTimeout(function () {
enemyAttack();
}, 1000);
}
}
function enemyAttack() {
if (!currentEnemy) return;
var damage = currentEnemy.attack();
lola.health -= damage;
// Flash Lola red
LK.effects.flashObject(lola, 0xff0000, 300);
combatScreen.lolaHealthText.setText('Lola: ' + Math.max(0, lola.health) + '/' + lola.maxHealth);
if (lola.health <= 0) {
// Game Over
LK.showGameOver();
} else {
// Check if mosquito gets extra attack
if (currentEnemy.type === 'mosquito' && !currentEnemy.extraAttackTurn && Math.random() < 0.3) {
currentEnemy.extraAttackTurn = true;
combatScreen.actionText.setText('Mosquito drains blood! Extra attack!');
LK.setTimeout(function () {
var secondDamage = currentEnemy.attack();
lola.health -= secondDamage;
LK.effects.flashObject(lola, 0xff0000, 300);
combatScreen.lolaHealthText.setText('Lola: ' + Math.max(0, lola.health) + '/' + lola.maxHealth);
if (lola.health <= 0) {
LK.showGameOver();
} else {
playerTurn = true;
combatScreen.actionText.setText('Tap to Attack!');
}
currentEnemy.extraAttackTurn = false;
}, 1000);
} else {
// Player turn
playerTurn = true;
combatScreen.actionText.setText('Tap to Attack!');
}
}
}
function endCombat() {
inCombat = false;
if (combatScreen) {
combatScreen.destroy();
combatScreen = null;
}
currentEnemy = null;
}
function checkLevelComplete() {
if (strawberriesCollected >= strawberriesNeeded) {
advanceLevel();
}
}
function spawnCharlotte() {
if (!charlotte) {
charlotte = game.addChild(new Charlotte());
charlotte.x = 1024;
charlotte.y = 1000;
// Add sparkle effect
LK.effects.flashObject(charlotte, 0xffff00, 1000);
}
}
function spawnHeartOnRandomCake() {
var availableCakes = cakes.filter(function (cake) {
return !cake.hasStrawberry && !cake.hasHeart;
});
if (availableCakes.length > 0) {
var randomCake = availableCakes[Math.floor(Math.random() * availableCakes.length)];
randomCake.spawnHeart();
heartSpawned = true;
}
}
var charlotteMessageScreen = null;
function advanceLevel() {
// Create Charlotte message screen
charlotteMessageScreen = game.addChild(LK.getAsset('combatBackground', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1366,
alpha: 0.95
}));
// Show Charlotte's message
var messageText = new Text2("Merci Lola pour tes fraises! Je vais me faire un bon festin avec mes plats,\nmaintenant j'en veux encore plus! Ca va ĂȘtre la fĂȘte!", {
size: 50,
fill: 0x000000,
align: 'center'
});
messageText.anchor.set(0.5, 0.5);
messageText.x = 0;
messageText.y = -100;
charlotteMessageScreen.addChild(messageText);
// Close button
var closeButton = charlotteMessageScreen.addChild(LK.getAsset('shopButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 0,
y: 200,
scaleX: 1.5
}));
var closeText = new Text2('Fermer', {
size: 40,
fill: 0x000000
});
closeText.anchor.set(0.5, 0.5);
closeButton.addChild(closeText);
closeButton.down = function () {
completeLevel();
};
}
function completeLevel() {
// Close Charlotte message screen
if (charlotteMessageScreen) {
charlotteMessageScreen.destroy();
charlotteMessageScreen = null;
}
currentLevel++;
storage.currentLevel = currentLevel;
gfCoins += 10; // Award 10 GF for advancing level
storage.gfCoins = gfCoins;
strawberriesCollected = 0;
strawberriesNeeded = calculateStrawberriesNeeded(currentLevel);
// Reset Lola's health
lola.health = lola.maxHealth;
// Reset heart spawning
heartSpawned = false;
// Remove Charlotte
if (charlotte) {
charlotte.destroy();
charlotte = null;
}
updateUI();
}
function openShop() {
if (shopOpen || inCombat) return;
shopOpen = true;
// Create shop background
shopScreen = game.addChild(LK.getAsset('combatBackground', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1366,
alpha: 0.95
}));
// Shop title
var shopTitle = new Text2('Boutique', {
size: 80,
fill: 0x000000
});
shopTitle.anchor.set(0.5, 0.5);
shopTitle.x = 0;
shopTitle.y = -500;
shopScreen.addChild(shopTitle);
// Shop items
var shopItems = [{
name: 'GĂąteau Ă la framboise',
health: 30,
price: 10,
y: -300
}, {
name: 'Mousse Ă la fraise',
health: 40,
price: 15,
y: -150
}, {
name: 'CrĂšme chantilly',
health: 40,
price: 20,
y: 0
}, {
name: 'Yaourt Ă la fraise',
health: 50,
price: 30,
y: 150
}, {
name: 'Tiramisu aux fraises',
health: 60,
price: 45,
y: 300
}];
shopScreen.items = [];
for (var i = 0; i < shopItems.length; i++) {
var item = shopItems[i];
// Item background
var itemBg = shopScreen.addChild(LK.getAsset('shopButton', {
anchorX: 0.5,
anchorY: 0.5,
x: -200,
y: item.y,
scaleX: 1.8,
scaleY: 1.2
}));
// Item text
var itemText = new Text2(item.name + ' (+' + item.health + ' HP)', {
size: 35,
fill: 0x000000
});
itemText.anchor.set(0.5, 0.5);
itemText.x = -200;
itemText.y = item.y - 15;
shopScreen.addChild(itemText);
// Price text
var priceText = new Text2('Prix: ' + item.price + ' GF', {
size: 30,
fill: 0x000000
});
priceText.anchor.set(0.5, 0.5);
priceText.x = -200;
priceText.y = item.y + 15;
shopScreen.addChild(priceText);
// Buy button
var buyButton = shopScreen.addChild(LK.getAsset('shopButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 200,
y: item.y,
scaleX: 1.2,
scaleY: 0.8
}));
var buyText = new Text2('Se servir', {
size: 35,
fill: 0x000000
});
buyText.anchor.set(0.5, 0.5);
buyButton.addChild(buyText);
// Store item data
buyButton.itemData = item;
buyButton.down = function (x, y, obj) {
buyItem(this.itemData);
};
shopScreen.items.push({
background: itemBg,
button: buyButton,
data: item
});
}
// Close button
var closeButton = shopScreen.addChild(LK.getAsset('shopButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 0,
y: 500,
scaleX: 1.5
}));
var closeText = new Text2('Fermer', {
size: 40,
fill: 0x000000
});
closeText.anchor.set(0.5, 0.5);
closeButton.addChild(closeText);
closeButton.down = function () {
closeShop();
};
}
function buyItem(item) {
if (gfCoins >= item.price) {
gfCoins -= item.price;
storage.gfCoins = gfCoins;
// Heal Lola
lola.health = Math.min(lola.maxHealth, lola.health + item.health);
updateUI();
// Flash green for successful purchase
LK.effects.flashScreen(0x00ff00, 500);
} else {
// Flash red for insufficient funds
LK.effects.flashScreen(0xff0000, 500);
}
}
function closeShop() {
if (shopScreen) {
shopScreen.destroy();
shopScreen = null;
}
shopOpen = false;
}
function updateUI() {
strawberryCounter.setText('Strawberries: ' + strawberriesCollected + '/' + strawberriesNeeded);
levelText.setText('Level ' + currentLevel);
gfCounter.setText('GF: ' + gfCoins);
}
// Shop button handler
shopButton.down = function (x, y, obj) {
openShop();
};
// Game event handlers
game.down = function (x, y, obj) {
if (inCombat && playerTurn) {
playerAttack();
}
};
// Main game loop
game.update = function () {
// Spawn strawberries randomly
if (LK.ticks % 120 === 0) {
// Every 2 seconds
var randomCake = cakes[Math.floor(Math.random() * cakes.length)];
randomCake.spawnStrawberry();
}
// Check Charlotte collision
if (charlotte && lola.intersects(charlotte) && strawberriesCollected >= strawberriesNeeded) {
charlotte.destroy();
charlotte = null;
advanceLevel();
}
};
// Start background music
LK.playMusic('backgroundMusic');
// Initialize UI
updateUI();
Fourmi. In-Game asset. 2d. High contrast. No shadows
ScarabeÌe. In-Game asset. 2d. High contrast. No shadows
Fraise. In-Game asset. 2d. High contrast. No shadows
GaÌteau aux fraises. In-Game asset. 2d. High contrast. No shadows
Petite fille nommeÌe charlotte. In-Game asset. 2d. High contrast. No shadows
Petite fille nommeÌe lola. In-Game asset. 2d. High contrast. No shadows
Fond d'eÌcran rose. In-Game asset. 2d. High contrast. No shadows
Fond d'eÌcran creÌme a la fraise. In-Game asset. 2d. High contrast. No shadows
Coeur de points de vie. In-Game asset. 2d. High contrast. No shadows
Moustique. In-Game asset. 2d. High contrast. No shadows
GueÌpe rose. In-Game asset. 2d. High contrast. No shadows
Abeille. In-Game asset. 2d. High contrast. No shadows
AraigneÌe. In-Game asset. 2d. High contrast. No shadows
Papillon (insecte). In-Game asset. 2d. High contrast. No shadows
earthworm. In-Game asset. 2d. High contrast. No shadows
Fraise doreÌe. In-Game asset. 2d. High contrast. No shadows