User prompt
make that there are more ennemy pig
Code edit (1 edits merged)
Please save this source code
User prompt
make that the ennemy pigs bigger
User prompt
make that you clic on the spacebar, a bullet goes from the pig to the nearest ennemy pig
User prompt
Make the pig bigger
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'intersects')' in or related to this line: 'if (enemyPigs[i].intersects(playerPig)) {' Line Number: 136
User prompt
make that if the pig is touched by a ennemy pig he will die
User prompt
make that if the bullet touch a enemyPig he will die
User prompt
Please fix the bug: 'Uncaught TypeError: window.addEventListener is not a function' in or related to this line: 'window.addEventListener('keydown', function (event) {' Line Number: 98
User prompt
Make that if you clic spacebar the pig choots a bullet
User prompt
make the pig can move every where in the map
Initial prompt
pig wars
/****
* Classes
****/
// Create a class for the enemy pigs
var EnemyPig = Container.expand(function () {
var self = Container.call(this);
var pigGraphics = self.attachAsset('enemyPig', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
// Enemy pig's behavior goes here
};
});
// The game engine will automatically load the assets
// Create a class for the player's pig
var PlayerPig = Container.expand(function () {
var self = Container.call(this);
var pigGraphics = self.attachAsset('playerPig', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
// Player pig's behavior goes here
};
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87CEEB // Sky blue background
});
/****
* Game Code
****/
// Initialize the player's pig
var playerPig = game.addChild(new PlayerPig());
playerPig.x = 2048 / 2; // Center the player's pig horizontally
playerPig.y = 2732 - playerPig.height / 2; // Position the player's pig at the bottom of the screen
// Initialize an array to hold the enemy pigs
var enemyPigs = [];
// Spawn an enemy pig every 2 seconds
LK.setInterval(function () {
var enemyPig = new EnemyPig();
enemyPig.x = Math.random() * 2048; // Random horizontal position
enemyPig.y = -enemyPig.height / 2; // Start just off the top of the screen
enemyPigs.push(enemyPig);
game.addChild(enemyPig);
}, 2000);
// Update the game state every frame
game.update = function () {
// Move the enemy pigs down the screen
for (var i = 0; i < enemyPigs.length; i++) {
enemyPigs[i].y += 5;
// If an enemy pig has reached the bottom of the screen, remove it
if (enemyPigs[i].y > 2732 + enemyPigs[i].height / 2) {
game.removeChild(enemyPigs[i]);
enemyPigs.splice(i, 1);
i--; // Adjust the index to account for the removed pig
}
}
};
A pig with a gun. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
monster pig horrorific. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a bullet. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.