User prompt
madenci butonunun üstüne başka bir buton asseti koy
User prompt
butonlar arka planın önünde olsun
Code edit (1 edits merged)
Please save this source code
User prompt
butonları sağ alta tablo şeklinde koy
User prompt
sol üstteki butonları kaldır
User prompt
butonlar yan yana tablo şeklinde olsun savaşçı olduğu yerde kalacak şekilde
User prompt
balıkçı balık tuttuğunda açlık 8 azalsın
User prompt
buyButton backgroundun önünde olsun
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'x')' in or related to this line: 'buyButton.x = buyMiner.x; // Align with other buttons' Line Number: 371
User prompt
buyButton kodlarda background olan yere koyma diğer butonların olduğu yere koy
User prompt
background müziği sürekli çalsın
User prompt
savaşçı canavarın yanına gittiğinde savaşma sesi gelsin
User prompt
buyButton backgroundImage in önünde olsun
User prompt
buyButton backgroundImage in arkasında olsun
User prompt
buyButton backgroundImage in önünde olsun
User prompt
Move buyButton further to the right on the screen
User prompt
buyButton daha sağda olsun
User prompt
buyButton daha sağda olsun
User prompt
buyButton daha sağda olsun
User prompt
buyButton sol altta ekranda görünür şekilde olsun
User prompt
buyButton arka planın önünde olsun
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'x')' in or related to this line: 'buyFisherman.x = buyMiner.x;' Line Number: 368
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'x')' in or related to this line: 'buyFisherman.x = buyMiner.x;' Line Number: 368
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'x')' in or related to this line: 'buyWarrior.x = buyFisherman.x;' Line Number: 368
/**** * Classes ****/ var BuyFarmer = Container.expand(function () { var self = Container.call(this); var buyFarmerGraphics = self.attachAsset('farmer', { anchorX: 0.5, anchorY: 0.5 }); self.down = function (x, y, obj) { if (diamonds >= 50) { // Assuming the price for a farmer is 50 diamonds diamonds -= 50; var newFarmer = new Farmer(); newFarmer.x = tent.x; newFarmer.y = tent.y; game.addChild(newFarmer); diamondText.setText('Diamonds: ' + diamonds); } }; }); // Lake asset var BuyFisherman = Container.expand(function () { var self = Container.call(this); var buyFishermanGraphics = self.attachAsset('buyFisherman', { anchorX: 0.5, anchorY: 0.5 }); self.down = function (x, y, obj) { if (diamonds >= 150) { // Assuming the price for a fisherman is 150 diamonds diamonds -= 150; var newFisherman = new Fisherman(); newFisherman.x = tent.x; newFisherman.y = tent.y; game.addChild(newFisherman); diamondText.setText('Diamonds: ' + diamonds); } }; }); var BuyMiner = Container.expand(function () { var self = Container.call(this); var buyMinerGraphics = self.attachAsset('buyMiner', { anchorX: 0.5, anchorY: 0.5 }); self.down = function (x, y, obj) { if (diamonds >= 100) { diamonds -= 100; var newMiner = new Miner(); newMiner.x = tent.x; newMiner.y = tent.y; game.addChild(newMiner); diamondText.setText('Diamonds: ' + diamonds); } }; }); var BuySpeed = Container.expand(function () { var self = Container.call(this); var buySpeedGraphics = self.attachAsset('speedUpgrade', { anchorX: 0.5, anchorY: 0.5 }); self.down = function (x, y, obj) { if (diamonds >= 700) { // Assuming the price for speed upgrade is 700 diamonds diamonds -= 700; // Increase speed of Miner, Fisherman, and Warrior game.children.forEach(function (child) { if (child instanceof Miner || child instanceof Fisherman || child instanceof Warrior) { child.speed += 0.5; // Increase speed by 0.5 } }); diamondText.setText('Diamonds: ' + diamonds); } }; }); var BuyWarrior = Container.expand(function () { var self = Container.call(this); var buyWarriorGraphics = self.attachAsset('buyWarrior', { anchorX: 0.5, anchorY: 0.5 }); self.down = function (x, y, obj) { if (diamonds >= 200) { // Assuming the price for a warrior is 200 diamonds diamonds -= 200; var newWarrior = new Warrior(); newWarrior.x = tent.x; newWarrior.y = tent.y; game.addChild(newWarrior); diamondText.setText('Diamonds: ' + diamonds); } }; }); var Cave = Container.expand(function () { var self = Container.call(this); var caveGraphics = self.attachAsset('cave', { anchorX: 0.5, anchorY: 0.5 }); }); var EnemyMonster = Container.expand(function () { var self = Container.call(this); var enemyMonsterGraphics = self.attachAsset('enemyMonster', { anchorX: 0.5, anchorY: 0.5 }); // Removed movement logic to keep the enemy monster stationary // Method to transition the enemy monster to battle mode self.enterBattleMode = function () { console.log("Enemy Monster is entering battle mode!"); // Add logic for entering battle mode here }; }); // Farmer class to represent the farmer character var Farmer = Container.expand(function () { var self = Container.call(this); var farmerGraphics = self.attachAsset('farmer', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 1; // Speed of the farmer self.collecting = false; // Whether the farmer is collecting crops // Update function to move the farmer self.update = function () { if (!self.collecting) { self.x += self.speed; if (self.x >= barn.x) { self.collecting = true; self.x = barn.x; if (diamonds >= 20) { diamonds -= 20; collectCrops(); } else { self.collecting = false; } } } else { self.x -= self.speed; if (self.x <= tent.x) { self.collecting = false; self.x = tent.x; } } }; }); var Fisherman = Container.expand(function () { var self = Container.call(this); var fishermanGraphics = self.attachAsset('fisherman', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 1; // Speed of the fisherman self.collecting = false; // Whether the fisherman is collecting fish // Update function to move the fisherman self.update = function () { if (!self.collecting) { self.x += self.speed; if (self.x >= lake.x) { LK.getSound('fishingSound').play(); // Play fishing sound when fisherman reaches the lake self.collecting = true; self.x = lake.x; // No hunger decrease when reaching the lake } } else { self.x -= self.speed; if (self.x <= tent.x + 100) { // Start position further along the path by 100 units self.collecting = false; self.x = tent.x; miner.hunger = Math.max(0, miner.hunger - 2); // Decrease hunger level by 2, min 0 hungerText.setText('Hunger: ' + Math.max(0, Math.floor(miner.hunger))); } } }; }); //<Assets used in the game will automatically appear here> //<Write imports for supported plugins here> // Miner class to represent the miner character var Miner = Container.expand(function () { var self = Container.call(this); var minerGraphics = self.attachAsset('miner', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 1.0; // Speed of the miner self.collecting = false; // Whether the miner is collecting diamonds self.hunger = 0; // Initial hunger level // Update function to move the miner self.update = function () { if (!self.collecting) { self.x += self.speed; if (self.x >= cave.x) { LK.getSound('pickaxeSound').play(); // Play pickaxe sound when miner reaches the cave self.collecting = true; self.x = cave.x; collectDiamonds(); // Calculate the number of miners, fishermen, and warriors var numMiners = game.children.filter(function (child) { return child instanceof Miner; }).length; var numFishermen = game.children.filter(function (child) { return child instanceof Fisherman; }).length; var numWarriors = game.children.filter(function (child) { return child instanceof Warrior; }).length; // Increase hunger level over time, faster with more characters self.hunger += 2.0 + 0.4 * (numMiners + numFishermen + numWarriors); if (self.hunger >= 100) { LK.effects.flashScreen(0xff0000, 1000); // Flash screen red LK.showGameOver(); // End the game } } ; } else { self.x -= self.speed; if (self.x <= tent.x + 300) { // Start position further along the path by 300 units self.collecting = false; self.x = tent.x + 300; // Play sound when miner reaches the tent with diamonds LK.getSound('diamondDrop').play(); // Increase diamond count when miner reaches the tent diamonds += 5; // Collect 5 diamonds per trip diamondText.setText('Diamonds: ' + diamonds); } } }; }); var ShelterUpgrade = Container.expand(function () { var self = Container.call(this); var shelterUpgradeGraphics = self.attachAsset('shelterUpgrade', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 1; // Speed of the shelter upgrade self.upgrading = false; // Whether the shelter is being upgraded // Update function to move the shelter upgrade self.update = function () { if (!self.upgrading) { self.x += self.speed; if (self.x >= shelter.x) { self.upgrading = true; self.x = shelter.x; upgradeShelter(); } } else { self.x -= self.speed; if (self.x <= tent.x) { self.upgrading = false; self.x = tent.x; } } }; }); // SpeedUpgrade class to represent the speed upgrade var SpeedUpgrade = Container.expand(function () { var self = Container.call(this); var speedUpgradeGraphics = self.attachAsset('speedUpgrade', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 1; // Speed of the speed upgrade self.upgrading = false; // Whether the speed is being upgraded // Update function to move the speed upgrade self.update = function () { if (!self.upgrading) { self.x += self.speed; if (self.x >= speed.x) { self.upgrading = true; self.x = speed.x; upgradeSpeed(); } } else { self.x -= self.speed; if (self.x <= tent.x) { self.upgrading = false; self.x = tent.x; } } }; }); // Tent class to represent the starting point var Tent = Container.expand(function () { var self = Container.call(this); var tentGraphics = self.attachAsset('tent', { anchorX: 0.5, anchorY: 0.5 }); }); var Warrior = Container.expand(function () { var self = Container.call(this); var warriorGraphics = self.attachAsset('warrior', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 1; // Speed of the warrior self.fighting = false; // Whether the warrior is fighting // Update function to move the warrior self.update = function () { if (!self.fighting) { self.x += self.speed; if (self.x >= enemyMonster.x) { self.fighting = true; self.x = enemyMonster.x; fightEnemies(); // Logic to win a treasure chest winTreasure(); } } else { self.x -= self.speed; if (self.x <= tent.x) { self.fighting = false; self.x = tent.x; } } }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 //Init game with black background }); /**** * Game Code ****/ var buyButton = game.addChild(LK.getAsset('buyButton', { anchorX: 0.5, anchorY: 0.5 })); buyButton.x = 100; // Position near the left edge of the screen buyButton.y = 2732 - 100; // Position near the bottom of the screen var buyFisherman = game.addChild(new BuyFisherman()); buyFisherman.x = buyMiner.x; buyFisherman.y = buyMiner.y + 150 + 37.8; // Move 1 cm lower on the screen var buyWarrior = game.addChild(new BuyWarrior()); buyWarrior.x = buyFisherman.x; buyWarrior.y = buyFisherman.y + 150 + 37.8; // Move 1 cm lower on the screen var buyFarmer = game.addChild(new BuyFarmer()); buyFarmer.x = buyWarrior.x; buyFarmer.y = buyWarrior.y + 150 + 37.8; // Move 1 cm lower on the screen var buySpeed = game.addChild(new BuySpeed()); buySpeed.x = buyFarmer.x; buySpeed.y = buyFarmer.y + 150 + 37.8; // Move 1 cm lower on the screen var buySpeedPrice = new Text2('700 Diamonds', { size: 50, fill: 0xFFFFFF }); buySpeedPrice.anchor.set(0.5, 0); LK.gui.top.addChild(buySpeedPrice); buySpeedPrice.x = buySpeed.x + 150; // Position to the right of the button buySpeedPrice.y = buySpeed.y; var buyMiner = game.addChild(new BuyMiner()); buyMiner.x = 2048 - 200; // Position near the right edge of the screen buyMiner.y = 2732 - 600 + 37.8; // Move 1 cm lower on the screen var buyFisherman = game.addChild(new BuyFisherman()); buyFisherman.x = buyMiner.x; buyFisherman.y = buyMiner.y + 150 + 37.8; // Move 1 cm lower on the screen var buyWarrior = game.addChild(new BuyWarrior()); buyWarrior.x = buyFisherman.x; buyWarrior.y = buyFisherman.y + 150 + 37.8; // Move 1 cm lower on the screen var buyWarriorPrice = new Text2('200 Diamonds', { size: 50, fill: 0xFFFFFF }); buyWarriorPrice.anchor.set(0.5, 0); LK.gui.top.addChild(buyWarriorPrice); buyWarriorPrice.x = buyWarrior.x + 150; // Position to the right of the button buyWarriorPrice.y = buyWarrior.y; var buyWarrior = game.addChild(new BuyWarrior()); buyWarrior.x = buyFisherman.x; buyWarrior.y = buyFisherman.y + 150 + 37.8; // Move 1 cm lower on the screen var buyFisherman = game.addChild(new BuyFisherman()); buyFisherman.x = buyMiner.x; buyFisherman.y = buyMiner.y + 150 + 37.8; // Move 1 cm lower on the screen var buyFarmer = game.addChild(new BuyFarmer()); buyFarmer.x = buyWarrior.x; buyFarmer.y = buyWarrior.y + 150 + 37.8; // Move 1 cm lower on the screen var buyFarmerPrice = new Text2('50 Diamonds', { size: 50, fill: 0xFFFFFF }); buyFarmerPrice.anchor.set(0.5, 0); LK.gui.top.addChild(buyFarmerPrice); buyFarmerPrice.x = buyFarmer.x + 150; // Position to the right of the button buyFarmerPrice.y = buyFarmer.y; var tent = game.addChild(new Tent()); tent.x = 200; tent.y = 1366; // Center vertically function winTreasure() { console.log("Warrior has won a treasure chest!"); treasureChestCount += 1; // Increment the treasure chest count treasureChestText.setText('x' + treasureChestCount); // Update the text to show the count // Add logic to reward the player with a treasure chest treasureChest.visible = true; // Make the treasure chest visible // Check if the player has collected 100 treasure chests if (treasureChestCount >= 100) { LK.showYouWin(); // Show "you win" screen } } // Add a background image to the game var background = LK.getAsset('backgroundImage', { anchorX: 0.5, anchorY: 0.5 }); background.x = 2048 / 2; // Center horizontally background.y = 2732 / 2; // Center vertically game.addChild(background); var cave = game.addChild(new Cave()); cave.x = 1400; // Move cave slightly more to the left cave.y = 1366; // Center vertically var lake = game.addChild(LK.getAsset('lake', { anchorX: 0.5, anchorY: 0.5 })); lake.x = cave.x - 500; // Move lake slightly to the right lake.y = cave.y + 600; // Move lake further down var tent = game.addChild(new Tent()); tent.x = 200; tent.y = 1366; // Center vertically var miner = game.addChild(new Miner()); miner.x = tent.x; miner.y = tent.y; // Score and upgrade system var diamonds = 0; var diamondText = new Text2('Diamonds: 0', { size: 100, fill: 0x000000 }); diamondText.anchor.set(0.5, 0); LK.gui.top.addChild(diamondText); diamondText.y = 50; // Add some space below the diamond text var hungerText = new Text2('Hunger: 100', { size: 100, fill: 0x000000 }); hungerText.anchor.set(0.5, 0); LK.gui.top.addChild(hungerText); hungerText.y = 150; // Position the hunger text further down // Add treasure chest asset next to diamond and hunger indicators var treasureChest = LK.getAsset('treasureChest', { anchorX: 0.5, anchorY: 0.5 }); treasureChest.x = diamondText.x + 450; // Move treasure chest slightly to the left treasureChest.y = diamondText.y + 100; // Move treasure chest further down from the diamond text LK.gui.top.addChild(treasureChest); // Initialize treasure chest count var treasureChestCount = 0; // Display the number of treasure chests collected var treasureChestText = new Text2('x' + treasureChestCount, { size: 50, fill: 0x000000 }); treasureChestText.anchor.set(0.5, 0); treasureChestText.x = treasureChest.x + 150; // Position further to the right of the treasure chest treasureChestText.y = treasureChest.y; LK.gui.top.addChild(treasureChestText); // Function to handle fighting enemies function fightEnemies() { console.log("Warrior is fighting enemies!"); // Add logic for fighting enemies here } // Function to collect fish function collectFish() { miner.hunger = Math.min(100, miner.hunger + 10); // Increase hunger level by 10, max 100 hungerText.setText('Hunger: ' + Math.max(0, Math.floor(miner.hunger))); } // Function to collect diamonds function collectDiamonds() {} // Upgrade system function upgradeTent() { if (diamonds >= 50) { diamonds -= 50; tent.attachAsset('upgradedTent', { anchorX: 0.5, anchorY: 0.5 }); diamondText.setText('Diamonds: ' + diamonds); } } // Event listener for upgrades game.down = function (x, y, obj) { if (x > 1800 && y < 200) { // Assume upgrade button is at top-right upgradeTent(); } }; // Initialize the BuyMiner button var buyMiner = game.addChild(new BuyMiner()); buyMiner.x = 2048 - 200; // Position near the right edge of the screen buyMiner.y = 2732 - 600 + 37.8; // Move 1 cm lower on the screen var buyMinerPrice = new Text2('100 Diamonds', { size: 50, fill: 0xFFFFFF }); buyMinerPrice.anchor.set(0.5, 0); LK.gui.top.addChild(buyMinerPrice); buyMinerPrice.x = buyMiner.x + 150; // Position to the right of the button buyMinerPrice.y = buyMiner.y; var buyFisherman = game.addChild(new BuyFisherman()); buyFisherman.x = buyMiner.x; buyFisherman.y = buyMiner.y + 150 + 37.8; // Move 1 cm lower on the screen var buyFishermanPrice = new Text2('150 Diamonds', { size: 50, fill: 0xFFFFFF }); buyFishermanPrice.anchor.set(0.5, 0); LK.gui.top.addChild(buyFishermanPrice); buyFishermanPrice.x = buyFisherman.x + 150; // Position to the right of the button buyFishermanPrice.y = buyFisherman.y; var buyWarrior = game.addChild(new BuyWarrior()); buyWarrior.x = buyFisherman.x; buyWarrior.y = buyFisherman.y + 150 + 37.8; // Move 1 cm lower on the screen var buyWarriorPrice = new Text2('200 Diamonds', { size: 50, fill: 0xFFFFFF }); buyWarriorPrice.anchor.set(0.5, 0); LK.gui.top.addChild(buyWarriorPrice); buyWarriorPrice.x = buyWarrior.x + 150; // Position to the right of the button buyWarriorPrice.y = buyWarrior.y; var buyMinerPrice = new Text2('100 Diamonds', { size: 50, fill: 0xFFFFFF }); buyMinerPrice.anchor.set(0.5, 0); LK.gui.top.addChild(buyMinerPrice); var buyFisherman = game.addChild(new BuyFisherman()); var buyFishermanPrice = new Text2('150 Diamonds', { size: 50, fill: 0xFFFFFF }); buyFishermanPrice.anchor.set(0.5, 0); LK.gui.top.addChild(buyFishermanPrice); var buyWarrior = game.addChild(new BuyWarrior()); var buyWarriorPrice = new Text2('200 Diamonds', { size: 50, fill: 0xFFFFFF }); buyWarriorPrice.anchor.set(0.5, 0); LK.gui.top.addChild(buyWarriorPrice); var enemyMonster = game.addChild(new EnemyMonster()); enemyMonster.x = cave.x + 500; // Move slightly to the left enemyMonster.y = cave.y; // Align vertically with the cave // Update function for game logic game.update = function () { miner.update(); hungerText.setText('Hunger: ' + Math.max(0, Math.floor(miner.hunger))); // Check if it's time for the enemy monster to make a sound and enter battle mode if (LK.ticks % 1200 === 0) { // Every 20 seconds at 60 FPS LK.getSound('monsterRoar').play(); // Play monster roar sound enemyMonster.enterBattleMode(); // Transition to battle mode } };
/****
* Classes
****/
var BuyFarmer = Container.expand(function () {
var self = Container.call(this);
var buyFarmerGraphics = self.attachAsset('farmer', {
anchorX: 0.5,
anchorY: 0.5
});
self.down = function (x, y, obj) {
if (diamonds >= 50) {
// Assuming the price for a farmer is 50 diamonds
diamonds -= 50;
var newFarmer = new Farmer();
newFarmer.x = tent.x;
newFarmer.y = tent.y;
game.addChild(newFarmer);
diamondText.setText('Diamonds: ' + diamonds);
}
};
});
// Lake asset
var BuyFisherman = Container.expand(function () {
var self = Container.call(this);
var buyFishermanGraphics = self.attachAsset('buyFisherman', {
anchorX: 0.5,
anchorY: 0.5
});
self.down = function (x, y, obj) {
if (diamonds >= 150) {
// Assuming the price for a fisherman is 150 diamonds
diamonds -= 150;
var newFisherman = new Fisherman();
newFisherman.x = tent.x;
newFisherman.y = tent.y;
game.addChild(newFisherman);
diamondText.setText('Diamonds: ' + diamonds);
}
};
});
var BuyMiner = Container.expand(function () {
var self = Container.call(this);
var buyMinerGraphics = self.attachAsset('buyMiner', {
anchorX: 0.5,
anchorY: 0.5
});
self.down = function (x, y, obj) {
if (diamonds >= 100) {
diamonds -= 100;
var newMiner = new Miner();
newMiner.x = tent.x;
newMiner.y = tent.y;
game.addChild(newMiner);
diamondText.setText('Diamonds: ' + diamonds);
}
};
});
var BuySpeed = Container.expand(function () {
var self = Container.call(this);
var buySpeedGraphics = self.attachAsset('speedUpgrade', {
anchorX: 0.5,
anchorY: 0.5
});
self.down = function (x, y, obj) {
if (diamonds >= 700) {
// Assuming the price for speed upgrade is 700 diamonds
diamonds -= 700;
// Increase speed of Miner, Fisherman, and Warrior
game.children.forEach(function (child) {
if (child instanceof Miner || child instanceof Fisherman || child instanceof Warrior) {
child.speed += 0.5; // Increase speed by 0.5
}
});
diamondText.setText('Diamonds: ' + diamonds);
}
};
});
var BuyWarrior = Container.expand(function () {
var self = Container.call(this);
var buyWarriorGraphics = self.attachAsset('buyWarrior', {
anchorX: 0.5,
anchorY: 0.5
});
self.down = function (x, y, obj) {
if (diamonds >= 200) {
// Assuming the price for a warrior is 200 diamonds
diamonds -= 200;
var newWarrior = new Warrior();
newWarrior.x = tent.x;
newWarrior.y = tent.y;
game.addChild(newWarrior);
diamondText.setText('Diamonds: ' + diamonds);
}
};
});
var Cave = Container.expand(function () {
var self = Container.call(this);
var caveGraphics = self.attachAsset('cave', {
anchorX: 0.5,
anchorY: 0.5
});
});
var EnemyMonster = Container.expand(function () {
var self = Container.call(this);
var enemyMonsterGraphics = self.attachAsset('enemyMonster', {
anchorX: 0.5,
anchorY: 0.5
});
// Removed movement logic to keep the enemy monster stationary
// Method to transition the enemy monster to battle mode
self.enterBattleMode = function () {
console.log("Enemy Monster is entering battle mode!");
// Add logic for entering battle mode here
};
});
// Farmer class to represent the farmer character
var Farmer = Container.expand(function () {
var self = Container.call(this);
var farmerGraphics = self.attachAsset('farmer', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 1; // Speed of the farmer
self.collecting = false; // Whether the farmer is collecting crops
// Update function to move the farmer
self.update = function () {
if (!self.collecting) {
self.x += self.speed;
if (self.x >= barn.x) {
self.collecting = true;
self.x = barn.x;
if (diamonds >= 20) {
diamonds -= 20;
collectCrops();
} else {
self.collecting = false;
}
}
} else {
self.x -= self.speed;
if (self.x <= tent.x) {
self.collecting = false;
self.x = tent.x;
}
}
};
});
var Fisherman = Container.expand(function () {
var self = Container.call(this);
var fishermanGraphics = self.attachAsset('fisherman', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 1; // Speed of the fisherman
self.collecting = false; // Whether the fisherman is collecting fish
// Update function to move the fisherman
self.update = function () {
if (!self.collecting) {
self.x += self.speed;
if (self.x >= lake.x) {
LK.getSound('fishingSound').play(); // Play fishing sound when fisherman reaches the lake
self.collecting = true;
self.x = lake.x;
// No hunger decrease when reaching the lake
}
} else {
self.x -= self.speed;
if (self.x <= tent.x + 100) {
// Start position further along the path by 100 units
self.collecting = false;
self.x = tent.x;
miner.hunger = Math.max(0, miner.hunger - 2); // Decrease hunger level by 2, min 0
hungerText.setText('Hunger: ' + Math.max(0, Math.floor(miner.hunger)));
}
}
};
});
//<Assets used in the game will automatically appear here>
//<Write imports for supported plugins here>
// Miner class to represent the miner character
var Miner = Container.expand(function () {
var self = Container.call(this);
var minerGraphics = self.attachAsset('miner', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 1.0; // Speed of the miner
self.collecting = false; // Whether the miner is collecting diamonds
self.hunger = 0; // Initial hunger level
// Update function to move the miner
self.update = function () {
if (!self.collecting) {
self.x += self.speed;
if (self.x >= cave.x) {
LK.getSound('pickaxeSound').play(); // Play pickaxe sound when miner reaches the cave
self.collecting = true;
self.x = cave.x;
collectDiamonds();
// Calculate the number of miners, fishermen, and warriors
var numMiners = game.children.filter(function (child) {
return child instanceof Miner;
}).length;
var numFishermen = game.children.filter(function (child) {
return child instanceof Fisherman;
}).length;
var numWarriors = game.children.filter(function (child) {
return child instanceof Warrior;
}).length;
// Increase hunger level over time, faster with more characters
self.hunger += 2.0 + 0.4 * (numMiners + numFishermen + numWarriors);
if (self.hunger >= 100) {
LK.effects.flashScreen(0xff0000, 1000); // Flash screen red
LK.showGameOver(); // End the game
}
}
;
} else {
self.x -= self.speed;
if (self.x <= tent.x + 300) {
// Start position further along the path by 300 units
self.collecting = false;
self.x = tent.x + 300;
// Play sound when miner reaches the tent with diamonds
LK.getSound('diamondDrop').play();
// Increase diamond count when miner reaches the tent
diamonds += 5; // Collect 5 diamonds per trip
diamondText.setText('Diamonds: ' + diamonds);
}
}
};
});
var ShelterUpgrade = Container.expand(function () {
var self = Container.call(this);
var shelterUpgradeGraphics = self.attachAsset('shelterUpgrade', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 1; // Speed of the shelter upgrade
self.upgrading = false; // Whether the shelter is being upgraded
// Update function to move the shelter upgrade
self.update = function () {
if (!self.upgrading) {
self.x += self.speed;
if (self.x >= shelter.x) {
self.upgrading = true;
self.x = shelter.x;
upgradeShelter();
}
} else {
self.x -= self.speed;
if (self.x <= tent.x) {
self.upgrading = false;
self.x = tent.x;
}
}
};
});
// SpeedUpgrade class to represent the speed upgrade
var SpeedUpgrade = Container.expand(function () {
var self = Container.call(this);
var speedUpgradeGraphics = self.attachAsset('speedUpgrade', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 1; // Speed of the speed upgrade
self.upgrading = false; // Whether the speed is being upgraded
// Update function to move the speed upgrade
self.update = function () {
if (!self.upgrading) {
self.x += self.speed;
if (self.x >= speed.x) {
self.upgrading = true;
self.x = speed.x;
upgradeSpeed();
}
} else {
self.x -= self.speed;
if (self.x <= tent.x) {
self.upgrading = false;
self.x = tent.x;
}
}
};
});
// Tent class to represent the starting point
var Tent = Container.expand(function () {
var self = Container.call(this);
var tentGraphics = self.attachAsset('tent', {
anchorX: 0.5,
anchorY: 0.5
});
});
var Warrior = Container.expand(function () {
var self = Container.call(this);
var warriorGraphics = self.attachAsset('warrior', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 1; // Speed of the warrior
self.fighting = false; // Whether the warrior is fighting
// Update function to move the warrior
self.update = function () {
if (!self.fighting) {
self.x += self.speed;
if (self.x >= enemyMonster.x) {
self.fighting = true;
self.x = enemyMonster.x;
fightEnemies();
// Logic to win a treasure chest
winTreasure();
}
} else {
self.x -= self.speed;
if (self.x <= tent.x) {
self.fighting = false;
self.x = tent.x;
}
}
};
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000 //Init game with black background
});
/****
* Game Code
****/
var buyButton = game.addChild(LK.getAsset('buyButton', {
anchorX: 0.5,
anchorY: 0.5
}));
buyButton.x = 100; // Position near the left edge of the screen
buyButton.y = 2732 - 100; // Position near the bottom of the screen
var buyFisherman = game.addChild(new BuyFisherman());
buyFisherman.x = buyMiner.x;
buyFisherman.y = buyMiner.y + 150 + 37.8; // Move 1 cm lower on the screen
var buyWarrior = game.addChild(new BuyWarrior());
buyWarrior.x = buyFisherman.x;
buyWarrior.y = buyFisherman.y + 150 + 37.8; // Move 1 cm lower on the screen
var buyFarmer = game.addChild(new BuyFarmer());
buyFarmer.x = buyWarrior.x;
buyFarmer.y = buyWarrior.y + 150 + 37.8; // Move 1 cm lower on the screen
var buySpeed = game.addChild(new BuySpeed());
buySpeed.x = buyFarmer.x;
buySpeed.y = buyFarmer.y + 150 + 37.8; // Move 1 cm lower on the screen
var buySpeedPrice = new Text2('700 Diamonds', {
size: 50,
fill: 0xFFFFFF
});
buySpeedPrice.anchor.set(0.5, 0);
LK.gui.top.addChild(buySpeedPrice);
buySpeedPrice.x = buySpeed.x + 150; // Position to the right of the button
buySpeedPrice.y = buySpeed.y;
var buyMiner = game.addChild(new BuyMiner());
buyMiner.x = 2048 - 200; // Position near the right edge of the screen
buyMiner.y = 2732 - 600 + 37.8; // Move 1 cm lower on the screen
var buyFisherman = game.addChild(new BuyFisherman());
buyFisherman.x = buyMiner.x;
buyFisherman.y = buyMiner.y + 150 + 37.8; // Move 1 cm lower on the screen
var buyWarrior = game.addChild(new BuyWarrior());
buyWarrior.x = buyFisherman.x;
buyWarrior.y = buyFisherman.y + 150 + 37.8; // Move 1 cm lower on the screen
var buyWarriorPrice = new Text2('200 Diamonds', {
size: 50,
fill: 0xFFFFFF
});
buyWarriorPrice.anchor.set(0.5, 0);
LK.gui.top.addChild(buyWarriorPrice);
buyWarriorPrice.x = buyWarrior.x + 150; // Position to the right of the button
buyWarriorPrice.y = buyWarrior.y;
var buyWarrior = game.addChild(new BuyWarrior());
buyWarrior.x = buyFisherman.x;
buyWarrior.y = buyFisherman.y + 150 + 37.8; // Move 1 cm lower on the screen
var buyFisherman = game.addChild(new BuyFisherman());
buyFisherman.x = buyMiner.x;
buyFisherman.y = buyMiner.y + 150 + 37.8; // Move 1 cm lower on the screen
var buyFarmer = game.addChild(new BuyFarmer());
buyFarmer.x = buyWarrior.x;
buyFarmer.y = buyWarrior.y + 150 + 37.8; // Move 1 cm lower on the screen
var buyFarmerPrice = new Text2('50 Diamonds', {
size: 50,
fill: 0xFFFFFF
});
buyFarmerPrice.anchor.set(0.5, 0);
LK.gui.top.addChild(buyFarmerPrice);
buyFarmerPrice.x = buyFarmer.x + 150; // Position to the right of the button
buyFarmerPrice.y = buyFarmer.y;
var tent = game.addChild(new Tent());
tent.x = 200;
tent.y = 1366; // Center vertically
function winTreasure() {
console.log("Warrior has won a treasure chest!");
treasureChestCount += 1; // Increment the treasure chest count
treasureChestText.setText('x' + treasureChestCount); // Update the text to show the count
// Add logic to reward the player with a treasure chest
treasureChest.visible = true; // Make the treasure chest visible
// Check if the player has collected 100 treasure chests
if (treasureChestCount >= 100) {
LK.showYouWin(); // Show "you win" screen
}
}
// Add a background image to the game
var background = LK.getAsset('backgroundImage', {
anchorX: 0.5,
anchorY: 0.5
});
background.x = 2048 / 2; // Center horizontally
background.y = 2732 / 2; // Center vertically
game.addChild(background);
var cave = game.addChild(new Cave());
cave.x = 1400; // Move cave slightly more to the left
cave.y = 1366; // Center vertically
var lake = game.addChild(LK.getAsset('lake', {
anchorX: 0.5,
anchorY: 0.5
}));
lake.x = cave.x - 500; // Move lake slightly to the right
lake.y = cave.y + 600; // Move lake further down
var tent = game.addChild(new Tent());
tent.x = 200;
tent.y = 1366; // Center vertically
var miner = game.addChild(new Miner());
miner.x = tent.x;
miner.y = tent.y;
// Score and upgrade system
var diamonds = 0;
var diamondText = new Text2('Diamonds: 0', {
size: 100,
fill: 0x000000
});
diamondText.anchor.set(0.5, 0);
LK.gui.top.addChild(diamondText);
diamondText.y = 50; // Add some space below the diamond text
var hungerText = new Text2('Hunger: 100', {
size: 100,
fill: 0x000000
});
hungerText.anchor.set(0.5, 0);
LK.gui.top.addChild(hungerText);
hungerText.y = 150; // Position the hunger text further down
// Add treasure chest asset next to diamond and hunger indicators
var treasureChest = LK.getAsset('treasureChest', {
anchorX: 0.5,
anchorY: 0.5
});
treasureChest.x = diamondText.x + 450; // Move treasure chest slightly to the left
treasureChest.y = diamondText.y + 100; // Move treasure chest further down from the diamond text
LK.gui.top.addChild(treasureChest);
// Initialize treasure chest count
var treasureChestCount = 0;
// Display the number of treasure chests collected
var treasureChestText = new Text2('x' + treasureChestCount, {
size: 50,
fill: 0x000000
});
treasureChestText.anchor.set(0.5, 0);
treasureChestText.x = treasureChest.x + 150; // Position further to the right of the treasure chest
treasureChestText.y = treasureChest.y;
LK.gui.top.addChild(treasureChestText);
// Function to handle fighting enemies
function fightEnemies() {
console.log("Warrior is fighting enemies!");
// Add logic for fighting enemies here
}
// Function to collect fish
function collectFish() {
miner.hunger = Math.min(100, miner.hunger + 10); // Increase hunger level by 10, max 100
hungerText.setText('Hunger: ' + Math.max(0, Math.floor(miner.hunger)));
}
// Function to collect diamonds
function collectDiamonds() {}
// Upgrade system
function upgradeTent() {
if (diamonds >= 50) {
diamonds -= 50;
tent.attachAsset('upgradedTent', {
anchorX: 0.5,
anchorY: 0.5
});
diamondText.setText('Diamonds: ' + diamonds);
}
}
// Event listener for upgrades
game.down = function (x, y, obj) {
if (x > 1800 && y < 200) {
// Assume upgrade button is at top-right
upgradeTent();
}
};
// Initialize the BuyMiner button
var buyMiner = game.addChild(new BuyMiner());
buyMiner.x = 2048 - 200; // Position near the right edge of the screen
buyMiner.y = 2732 - 600 + 37.8; // Move 1 cm lower on the screen
var buyMinerPrice = new Text2('100 Diamonds', {
size: 50,
fill: 0xFFFFFF
});
buyMinerPrice.anchor.set(0.5, 0);
LK.gui.top.addChild(buyMinerPrice);
buyMinerPrice.x = buyMiner.x + 150; // Position to the right of the button
buyMinerPrice.y = buyMiner.y;
var buyFisherman = game.addChild(new BuyFisherman());
buyFisherman.x = buyMiner.x;
buyFisherman.y = buyMiner.y + 150 + 37.8; // Move 1 cm lower on the screen
var buyFishermanPrice = new Text2('150 Diamonds', {
size: 50,
fill: 0xFFFFFF
});
buyFishermanPrice.anchor.set(0.5, 0);
LK.gui.top.addChild(buyFishermanPrice);
buyFishermanPrice.x = buyFisherman.x + 150; // Position to the right of the button
buyFishermanPrice.y = buyFisherman.y;
var buyWarrior = game.addChild(new BuyWarrior());
buyWarrior.x = buyFisherman.x;
buyWarrior.y = buyFisherman.y + 150 + 37.8; // Move 1 cm lower on the screen
var buyWarriorPrice = new Text2('200 Diamonds', {
size: 50,
fill: 0xFFFFFF
});
buyWarriorPrice.anchor.set(0.5, 0);
LK.gui.top.addChild(buyWarriorPrice);
buyWarriorPrice.x = buyWarrior.x + 150; // Position to the right of the button
buyWarriorPrice.y = buyWarrior.y;
var buyMinerPrice = new Text2('100 Diamonds', {
size: 50,
fill: 0xFFFFFF
});
buyMinerPrice.anchor.set(0.5, 0);
LK.gui.top.addChild(buyMinerPrice);
var buyFisherman = game.addChild(new BuyFisherman());
var buyFishermanPrice = new Text2('150 Diamonds', {
size: 50,
fill: 0xFFFFFF
});
buyFishermanPrice.anchor.set(0.5, 0);
LK.gui.top.addChild(buyFishermanPrice);
var buyWarrior = game.addChild(new BuyWarrior());
var buyWarriorPrice = new Text2('200 Diamonds', {
size: 50,
fill: 0xFFFFFF
});
buyWarriorPrice.anchor.set(0.5, 0);
LK.gui.top.addChild(buyWarriorPrice);
var enemyMonster = game.addChild(new EnemyMonster());
enemyMonster.x = cave.x + 500; // Move slightly to the left
enemyMonster.y = cave.y; // Align vertically with the cave
// Update function for game logic
game.update = function () {
miner.update();
hungerText.setText('Hunger: ' + Math.max(0, Math.floor(miner.hunger)));
// Check if it's time for the enemy monster to make a sound and enter battle mode
if (LK.ticks % 1200 === 0) {
// Every 20 seconds at 60 FPS
LK.getSound('monsterRoar').play(); // Play monster roar sound
enemyMonster.enterBattleMode(); // Transition to battle mode
}
};
madenci çizgi karakter. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
balıkçı animasyon şeklinde. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
savaşçı karikatür şeklinde. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
hazine kutusu. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
light green
yuvarlak balıklı göl. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
kırmızı buton. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
"Collect 100 treasure chests as soon as possible." text. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
orman evi No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat