User prompt
Fix Bug: 'Uncaught TypeError: requestAnimationFrame is not a function' in this line: 'requestAnimationFrame(gameLoop);' Line Number: 137
User prompt
Fix Bug: 'Uncaught TypeError: requestAnimationFrame is not a function' in this line: 'requestAnimationFrame(gameLoop);' Line Number: 137
User prompt
zorg er voor dat er minder fps drops zijn
User prompt
kan er voor zorgen dat de game geen fps drops meer heeft
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'intersects')' in this line: 'heroBullets.splice(a, 1);' Line Number: 100
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'intersects')' in this line: 'heroBullets.splice(a, 1);' Line Number: 100
User prompt
zorg dat ik de enemy kan killen
User prompt
Fix Bug: 'TypeError: Cannot set properties of undefined (setting 'speed')' in this line: 'self.speed = 4.23;' Line Number: 30
User prompt
Fix Bug: 'TypeError: Cannot set properties of undefined (setting 'speed')' in this line: 'self.speed = 4.23;' Line Number: 30
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'speed')' in this line: 'self.speed = self.speed || 4.23;' Line Number: 30
User prompt
Fix Bug: 'TypeError: Cannot set properties of undefined (setting 'speed')' in this line: 'self.speed = 4.23;' Line Number: 30
User prompt
Fix Bug: 'TypeError: Cannot set properties of undefined (setting 'speed')' in this line: 'self.speed = 4.23;' Line Number: 29
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'expand')' in this line: 'var SmallEnemy = Enemy.expand(function () {' Line Number: 1
User prompt
zorg er voor dat de enemy gekillt kan worden en als hij gekillt is dat er 2 small enemys uit komen die ook op jou afkomen maar 10% sneller zijn
User prompt
Fix Bug: 'TypeError: self.getStage is not a function' in this line: 'var gameContainer = self.getStage();' Line Number: 81
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'addChild')' in this line: 'self.parent.addChild(smallEnemy1);' Line Number: 81
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'addChild')' in this line: 'gameInstance.addChild(smallEnemy1);' Line Number: 81
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'addChild')' in this line: 'self.parent.addChild(smallEnemy1);' Line Number: 81
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'addChild')' in this line: 'gameInstance.addChild(smallEnemy1);' Line Number: 81
User prompt
zorg er voor dat er 2 andere smallenemy uit de enemy komt die je killt
User prompt
zorg er voor dat er 2 andere enemys uit de enemy komt die je killt
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'intersects')' in this line: 'heroBullets.splice(a, 1);' Line Number: 118
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'addChild')' in this line: 'self.parent.addChild(smallEnemy1, smallEnemy2);' Line Number: 72
User prompt
zorg er voor dat ik de enemy kan killen en dat ie dan in 2 splits en dat er 2 kleinere enemys komen
User prompt
Increase the speed of the hero by 10%
var HeroBullet = Container.expand(function () { var self = Container.call(this); var bulletGraphics = self.createAsset('heroBullet', 'Hero Bullet Graphics', .5, .5); self.speed = -10; self.move = function () { self.x += self.speedX; self.y += self.speedY; }; self.timer = LK.setTimeout(function () { self.destroy(); }, 5000); }); var EnemyBullet = Container.expand(function () { var self = Container.call(this); var bulletGraphics = self.createAsset('enemyBullet', 'Enemy Bullet Graphics', .5, .5); self.speed = 10; self.move = function () { self.x += self.speed; }; self.timer = LK.setTimeout(function () { self.destroy(); }, 5000); }); var Hero = Container.expand(function () { var self = Container.call(this); self.update = function () { if (self.dx && self.dy) { self.x -= self.dx; self.y -= self.dy; self.dx *= 0.99; self.dy *= 0.99; if (Math.abs(self.dx) < 0.01 && Math.abs(self.dy) < 0.01) { self.dx = 0; self.dy = 0; } } }; var heroGraphics = self.createAsset('hero', 'Hero character', .5, .5); self.knockback = function (dx, dy) { self.dx = -dx * 116.886; self.dy = -dy * 116.886; }; }); var Enemy = Container.expand(function () { var self = Container.call(this); var enemyGraphics = self.createAsset('enemy', 'Enemy character', .5, .5); self.health = 100; self.followHero = function (hero) { var dx = hero.x - self.x; var dy = hero.y - self.y; var mag = Math.sqrt(dx * dx + dy * dy); self.x += 3.85 * dx / mag; self.y += 3.85 * dy / mag; }; self.hit = function () { self.health -= 10; if (self.health <= 0) { self.destroy(); } }; }); var Game = Container.expand(function () { var self = Container.call(this); LK.stageContainer.setBackgroundColor(0x000000); var hero = self.addChild(new Hero()); var enemy = self.addChild(new Enemy()); hero.x = 1024; hero.y = 1366; enemy.x = 1024; enemy.y = 1366 - 200; var heroBullets = []; var enemyBullets = []; var isGameOver = false; var tickOffset = 0; var fpsCounter = new Text2('0', { size: 50, fill: '#ffffff' }); LK.gui.topCenter.addChild(fpsCounter); var lastTick = Date.now(); var frameCount = 0; var gameLoop = function () { if (isGameOver) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); return; } frameCount++; var now = Date.now(); if (now - lastTick >= 1000) { fpsCounter.setText(frameCount); frameCount = 0; lastTick = now; } hero.update(); enemy.followHero(hero); for (var a = heroBullets.length - 1; a >= 0; a--) { heroBullets[a].move(); if (heroBullets[a].y < -50 || heroBullets[a].y > 2732 + 50 || heroBullets[a].x < -50 || heroBullets[a].x > 2048 + 50) { heroBullets[a].destroy(); heroBullets.splice(a, 1); } else if (heroBullets[a] && enemy && heroBullets[a].intersects(enemy)) { enemy.hit(); heroBullets[a].destroy(); heroBullets.splice(a, 1); } } for (var a = enemyBullets.length - 1; a >= 0; a--) { if (enemyBullets[a]) { enemyBullets[a].move(); if (enemyBullets[a].y > 2732 + 50) { enemyBullets[a].destroy(); enemyBullets.splice(a, 1); } } } var lastShot = 0; var bulletCount = 0; stage.on('down', function (obj) { var event = obj.event; var pos = event.getLocalPosition(self); var newBullet = new HeroBullet(); newBullet.x = hero.x; newBullet.y = hero.y; var dx = pos.x - hero.x; var dy = pos.y - hero.y; var mag = Math.sqrt(dx * dx + dy * dy); newBullet.speedX = 10 * dx / mag; newBullet.speedY = 10 * dy / mag; heroBullets.push(newBullet); self.addChild(newBullet); hero.knockback(-dx / (mag * 10), -dy / (mag * 10)); }); if (bulletCount > 0) bulletCount--; requestAnimationFrame(gameLoop); }; requestAnimationFrame(gameLoop); ; });
===================================================================
--- original.js
+++ change.js
@@ -78,12 +78,13 @@
});
LK.gui.topCenter.addChild(fpsCounter);
var lastTick = Date.now();
var frameCount = 0;
- LK.on('tick', function () {
+ var gameLoop = function () {
if (isGameOver) {
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
+ return;
}
frameCount++;
var now = Date.now();
if (now - lastTick >= 1000) {
@@ -93,24 +94,25 @@
}
hero.update();
enemy.followHero(hero);
for (var a = heroBullets.length - 1; a >= 0; a--) {
- var bullet = heroBullets[a];
- bullet.move();
- if (bullet.y < -50 || bullet.y > 2732 + 50 || bullet.x < -50 || bullet.x > 2048 + 50 || bullet && enemy && bullet.intersects(enemy)) {
- if (bullet && enemy && bullet.intersects(enemy)) {
- enemy.hit();
- }
- bullet.destroy();
+ heroBullets[a].move();
+ if (heroBullets[a].y < -50 || heroBullets[a].y > 2732 + 50 || heroBullets[a].x < -50 || heroBullets[a].x > 2048 + 50) {
+ heroBullets[a].destroy();
heroBullets.splice(a, 1);
+ } else if (heroBullets[a] && enemy && heroBullets[a].intersects(enemy)) {
+ enemy.hit();
+ heroBullets[a].destroy();
+ heroBullets.splice(a, 1);
}
}
for (var a = enemyBullets.length - 1; a >= 0; a--) {
- var bullet = enemyBullets[a];
- bullet.move();
- if (bullet.y > 2732 + 50) {
- bullet.destroy();
- enemyBullets.splice(a, 1);
+ if (enemyBullets[a]) {
+ enemyBullets[a].move();
+ if (enemyBullets[a].y > 2732 + 50) {
+ enemyBullets[a].destroy();
+ enemyBullets.splice(a, 1);
+ }
}
}
var lastShot = 0;
var bulletCount = 0;
@@ -128,9 +130,10 @@
heroBullets.push(newBullet);
self.addChild(newBullet);
hero.knockback(-dx / (mag * 10), -dy / (mag * 10));
});
- LK.on('tick', function () {
- if (bulletCount > 0) bulletCount--;
- });
- });
+ if (bulletCount > 0) bulletCount--;
+ requestAnimationFrame(gameLoop);
+ };
+ requestAnimationFrame(gameLoop);
+ ;
});
watergun Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
water ball Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
water health bar Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
fire Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
blue play button Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
explosion smoke Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.