User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'y')' in this line: 'var angleToZombie = Math.atan2(self.y - torchPos.y, self.x - torchPos.x);' Line Number: 44
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'rotation')' in this line: 'var torchAngle = hero.torchGraphics.rotation;' Line Number: 119
User prompt
Fix Bug: 'TypeError: hero.getChildByName is not a function' in this line: 'var torchAngle = hero.getChildByName('torch').rotation;' Line Number: 119
User prompt
Fix Bug: 'Uncaught TypeError: window.addEventListener is not a function' in this line: 'window.addEventListener('keydown', function (e) {' Line Number: 75
User prompt
Le hero doit ce deplacer uniquement avec le clavier, il possède une torche qu'il est possible d'orienté uniquement avec la souris, les zombies ne sont pas visible car il fait sombre et c'est uniquement si le hero oriente la torche vers un zombie que celu-ci devient visible
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'addEventListener')' in this line: 'document.addEventListener('keydown', function (event) {' Line Number: 63
User prompt
Le personnage doit se deplacer avec le clavier et les fleche il utilise une torche pour voir autour de lui
User prompt
Change les sprites des zombies par un truc plus réalise
Initial prompt
Zombie Night Survival
/**** * 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.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 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('realisticZombie', 'Realistic Zombie enemy', 0.5, 0.5); self.speed = 1; self.move = function () { self.y += self.speed; }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 // Init game with black background }); /**** * Game Code ****/ // Initialize important asset arrays 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 game.on('down', function (obj) { var touchPos = obj.event.getLocalPosition(game); var direction = { x: 0, y: 0 }; if (touchPos.x < hero.x) { direction.x = -1; } else if (touchPos.x > hero.x) { direction.x = 1; } hero.move(direction); hero.shoot(); }); 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); } } // Move zombies and check for collision with hero for (var j = zombies.length - 1; j >= 0; j--) { zombies[j].move(); if (zombies[j].y > 2732) { zombies[j].destroy(); zombies.splice(j, 1); } else if (zombies[j].intersects(hero)) { isGameOver = true; } } // 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
@@ -1,51 +1,51 @@
-/****
+/****
* 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.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;
- };
+ var self = Container.call(this);
+ var heroGraphics = self.createAsset('hero', 'Hero character', 0.5, 0.5);
+ 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 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;
- };
+ 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 () {
- self.y += self.speed;
- };
+ var self = Container.call(this);
+ var zombieGraphics = self.createAsset('realisticZombie', 'Realistic Zombie enemy', 0.5, 0.5);
+ self.speed = 1;
+ self.move = function () {
+ self.y += self.speed;
+ };
});
-/****
+/****
* Initialize Game
****/
var game = new LK.Game({
- backgroundColor: 0x000000 // Init game with black background
+ backgroundColor: 0x000000 // Init game with black background
});
-/****
+/****
* Game Code
****/
// Initialize important asset arrays
var bullets = [];
@@ -57,50 +57,50 @@
hero.x = 2048 / 2;
hero.y = 2732 - 100; // Position hero near the bottom of the screen
// Game logic and event handlers
game.on('down', function (obj) {
- var touchPos = obj.event.getLocalPosition(game);
- var direction = {
- x: 0,
- y: 0
- };
- if (touchPos.x < hero.x) {
- direction.x = -1;
- } else if (touchPos.x > hero.x) {
- direction.x = 1;
- }
- hero.move(direction);
- hero.shoot();
+ var touchPos = obj.event.getLocalPosition(game);
+ var direction = {
+ x: 0,
+ y: 0
+ };
+ if (touchPos.x < hero.x) {
+ direction.x = -1;
+ } else if (touchPos.x > hero.x) {
+ direction.x = 1;
+ }
+ hero.move(direction);
+ hero.shoot();
});
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);
- }
- }
- // Move zombies and check for collision with hero
- for (var j = zombies.length - 1; j >= 0; j--) {
- zombies[j].move();
- if (zombies[j].y > 2732) {
- zombies[j].destroy();
- zombies.splice(j, 1);
- } else if (zombies[j].intersects(hero)) {
- isGameOver = true;
- }
- }
- // 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);
- }
+ 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);
+ }
+ }
+ // Move zombies and check for collision with hero
+ for (var j = zombies.length - 1; j >= 0; j--) {
+ zombies[j].move();
+ if (zombies[j].y > 2732) {
+ zombies[j].destroy();
+ zombies.splice(j, 1);
+ } else if (zombies[j].intersects(hero)) {
+ isGameOver = true;
+ }
+ }
+ // 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);
+ }
});
\ No newline at end of file
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.