Code edit (5 edits merged)
Please save this source code
User prompt
Quand la munition ce deplace le jeu freeze totalement
User prompt
Lors d'un tir le jeu freeze
User prompt
Le jeu freeze completement apres un tir
User prompt
Les bullet partent pas dans le bon sens
User prompt
Le hero peux tiré des projectiles en direction de la souris avec des clic gauches, projectile qui retire 10pv au zombie, les zombies on au depart un total de 50pv qui sont visible au dessus d'eux
User prompt
C'est un clic gauche qui provoque le tir
User prompt
Le hero peux tiré des projectiles en direction de la souris, projectile qui retire 10pv au zombie, les zombies on au depart un total de 50pv
User prompt
Les zombies doivent être attirré par le joueur
Code edit (8 edits merged)
Please save this source code
User prompt
Les zombies doivent ce dirigé vers le hero
User prompt
les zombies sont invisible si ils sont hors de la zone d'eclairage de la torche
User prompt
Les zombies doivent ce dirigé vers le hero
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
User prompt
Fix Bug: 'TypeError: Graphics is not a constructor' in this line: 'var triangle = new Graphics();' Line Number: 38
User prompt
Fix Bug: 'TypeError: Graphics is not a constructor' in this line: 'var triangle = new Graphics();' Line Number: 38
User prompt
Rend torchlight triangulaire
User prompt
Fix Bug: 'TypeError: Graphics is not a constructor' in this line: 'var triangle = new Graphics();' Line Number: 38
User prompt
Fix Bug: 'TypeError: Graphics is not a constructor' in this line: 'var triangle = new Graphics();' Line Number: 38
User prompt
Fait en sorte que la forme de la texture torchlight soit triangulaire comme la zone d'éclairage reel de la lampe
User prompt
L'orientation de la torchlight n'est pas bonne, elle doit être face au hero
User prompt
L'orientation de la torchlight n'est pas bonne, elle doit être face au hero
User prompt
Fix Bug: 'ReferenceError: graphics is not defined' in this line: 'graphics.alpha = 0.3;' Line Number: 45
User prompt
Fix Bug: 'TypeError: Graphics is not a constructor' in this line: 'var graphics = new Graphics();' Line Number: 38
/**** * Classes ****/ // Define the Hero class var Hero = Container.expand(function () { var self = Container.call(this); var heroGraphics = self.createAsset('hero', 'Hero character', 0.5, 0.5); self.torchGraphics = self.createAsset('torch', 'Hero torch', 0.5, 0); self.torchGraphics.visible = false; self.orientTorch = function (mousePos) { var angle = Math.atan2(mousePos.y - self.y, mousePos.x - self.x); self.torchGraphics.rotation = angle; self.torchGraphics.visible = true; }; self.speed = 5; self.shoot = function () { var bullet = new HeroBullet(); bullet.x = self.x; bullet.y = self.y; game.addChild(bullet); bullets.push(bullet); }; self.move = function (direction) { self.x += direction.x * self.speed; self.y += direction.y * self.speed; }; }); // Define the TorchLight class var TorchLight = Container.expand(function () { var self = Container.call(this); var lightGraphics = self.createAsset('torchLight', 'Torch light zone', 0.5, 1); self.updatePosition = function (heroPos, torchAngle) { self.x = heroPos.x; self.y = heroPos.y; self.rotation = torchAngle + Math.PI / 2; // Adjust the size and shape of the light zone // Create a triangular shape for the torch light to simulate a cone of light var triangle = new Graphics(); triangle.beginFill(0xffff00, 0.3); triangle.moveTo(0, 0); triangle.lineTo(300, -1200); triangle.lineTo(-300, -1200); triangle.lineTo(0, 0); triangle.endFill(); // Replace the old lightGraphics with the new triangular shape self.removeChild(lightGraphics); lightGraphics = self.addChild(triangle); // Set the pivot to the bottom center of the triangle lightGraphics.pivot.x = 0; lightGraphics.pivot.y = 0; }; }); // Define the HeroBullet class var HeroBullet = Container.expand(function () { var self = Container.call(this); var bulletGraphics = self.createAsset('heroBullet', 'Hero bullet', 0.5, 1); self.speed = -10; self.move = function () { self.y += self.speed; }; }); // Define the Zombie class var Zombie = Container.expand(function () { var self = Container.call(this); var zombieGraphics = self.createAsset('zombie', 'Zombie enemy', 0.5, 0.5); self.speed = 1; self.move = function (torchPos, torchAngle) { self.y += self.speed; if (torchPos) { var angleToZombie = Math.atan2(self.y - torchPos.y, self.x - torchPos.x); var angleDifference = Math.abs(torchAngle - angleToZombie); if (angleDifference < 0.5) { // Assuming torch has a cone of visibility of 0.5 radians self.visible = true; } else { self.visible = false; } } }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 // Init game with black background }); /**** * Game Code ****/ // Initialize important asset arrays var torchLight = game.addChild(new TorchLight()); var bullets = []; var zombies = []; var hero; var isGameOver = false; // Create the hero hero = game.addChild(new Hero()); hero.x = 2048 / 2; hero.y = 2732 - 100; // Position hero near the bottom of the screen // Game logic and event handlers LK.on('keydown', function (obj) { var direction = { x: 0, y: 0 }; var e = obj.event; switch (e.keyCode) { case 37: // left arrow direction.x = -1; break; case 39: // right arrow direction.x = 1; break; case 38: // up arrow direction.y = -1; break; case 40: // down arrow direction.y = 1; break; } hero.move(direction); }); LK.on('tick', function () { if (isGameOver) { LK.showGameOver(); return; } // Move bullets and check for off-screen for (var i = bullets.length - 1; i >= 0; i--) { bullets[i].move(); if (bullets[i].y < 0) { bullets[i].destroy(); bullets.splice(i, 1); } } // Handle torch orientation and make zombies visible if illuminated var torchPos = { x: hero.x, y: hero.y }; var torchAngle = hero.torchGraphics.rotation; // Update torch light position var heroPos = { x: hero.x, y: hero.y }; var torchAngle = hero.torchGraphics.rotation; torchLight.updatePosition(heroPos, torchAngle); // Move zombies and check for collision with hero for (var j = zombies.length - 1; j >= 0; j--) { zombies[j].move(torchPos, torchAngle); if (zombies[j].y > 2732) { zombies[j].destroy(); zombies.splice(j, 1); } else if (zombies[j].intersects(hero) && zombies[j].visible) { isGameOver = true; } } game.on('move', function (obj) { var mousePos = obj.event.getLocalPosition(game); hero.orientTorch(mousePos); }); // Spawn zombies if (LK.ticks % 120 == 0) { // Spawn a zombie every 2 seconds var zombie = new Zombie(); zombie.x = Math.random() * 2048; zombie.y = -50; // Start off-screen zombies.push(zombie); game.addChild(zombie); } });
===================================================================
--- original.js
+++ change.js
@@ -33,16 +33,22 @@
self.x = heroPos.x;
self.y = heroPos.y;
self.rotation = torchAngle + Math.PI / 2;
// Adjust the size and shape of the light zone
- // Create a triangular shape for the torch light zone to simulate a cone of light
- var triangle = LK.getAsset('torchLightTriangle', 'Torch light triangle shape', 0.5, 1);
- triangle.alpha = 0.3;
+ // Create a triangular shape for the torch light to simulate a cone of light
+ var triangle = new Graphics();
+ triangle.beginFill(0xffff00, 0.3);
+ triangle.moveTo(0, 0);
+ triangle.lineTo(300, -1200);
+ triangle.lineTo(-300, -1200);
+ triangle.lineTo(0, 0);
+ triangle.endFill();
+ // Replace the old lightGraphics with the new triangular shape
self.removeChild(lightGraphics);
- self.addChild(triangle);
+ lightGraphics = self.addChild(triangle);
// Set the pivot to the bottom center of the triangle
- triangle.pivot.x = triangle.width / 2;
- triangle.pivot.y = triangle.height;
+ lightGraphics.pivot.x = 0;
+ lightGraphics.pivot.y = 0;
};
});
// Define the HeroBullet class
var HeroBullet = Container.expand(function () {
Un zombie en 2D vue du dessus. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Bullet. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
top down shooter blood. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
top down shooter blood texture. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
top down character with gun de dos. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows. topdown shooter
top down robot with gun. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows. topdown shooter
2d top down zombie boss. Single Game Texture. In-Game asset. 2d. no background. High contrast. No shadows.
weapon reload 2d icon. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Dark background horror. 2d. Blank background. High contrast. No shadows.
replace robot by wall
barbelé militaire 2d
Arrière plan sombre d'horreur avec un angle vu depuis le haut. 2d. Blank background. High contrast. No shadows.