User prompt
Add another enemy type with a new sprite which moves 5 times as fast. Their spawn rate function is 1/16 + 1/16 * Math.Max(1, score/1200)
User prompt
If the player kills fast enemy give them a temporory powerup which lasts 6 seconds. The power up doubles fire rate
User prompt
Give FastEnemy a different sprite
User prompt
add another enemy type which moves twice as fast. This enemy does not spawn normally, but a normal enemy turns into this type with 1/12 chance when it spawns
User prompt
Vary enemy speed by a maximum of 10% faster or slower
Code edit (1 edits merged)
Please save this source code
User prompt
Make sure maximum enemy spawn rate is not achieved until score is 1000 or higher
User prompt
Enemy spawn rate should increase with score. Minimum is 1.5 per second. Maximum is 3 per second.
User prompt
Adjust enemy spawn rate relative to score. When score is 0, spawn 1.5 enemies per second. When score reaches 300 or higher, spawn 3 enemies per second. Increase it lineally between these two extremes
User prompt
3 per second
User prompt
4 per second
User prompt
Adjust enemy spawn rate to 5 per second
User prompt
When enemy hits player set score to 0
User prompt
Move the score to the top middle
User prompt
Add a score count in the top right of the screen (not too close to the edge). Every time enemy and bullet collide, add 10 to score
User prompt
decrease fire rate by half
User prompt
Add variable to track if mouse is held down. When its held down, shoot continuously
User prompt
Shoot continuously if mouse held down
User prompt
If the player shoots, he cant shoot again for another 0.2 seconds
User prompt
Limit fire rate to every 0.2 seconds
User prompt
If mouse button is held down, shoot continuously at 0.2 second intervals
User prompt
Please fix the bug: 'Uncaught TypeError: setInterval is not a function' in or related to this line: 'shootingInterval = setInterval(function () {' Line Number: 86
User prompt
Shoot continuously if the mouse is held down
User prompt
If I hold the mouse down, make the player shoot continuously. Put a limit on the rate of fire to 3 shots per second
User prompt
If an enemy collides with the player, remove the enemy
/**** * Classes ****/ //<Assets used in the game will automatically appear here> // Bullet class var Bullet = Container.expand(function () { var self = Container.call(this); var bulletGraphics = self.attachAsset('bullet', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 10; self.update = function () { self.x += self.speed * Math.cos(self.rotation); self.y += self.speed * Math.sin(self.rotation); }; }); // Enemy class var Enemy = Container.expand(function () { var self = Container.call(this); var enemyGraphics = self.attachAsset('enemy', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 2; self.update = function () { var dx = player.x - self.x; var dy = player.y - self.y; var angle = Math.atan2(dy, dx); self.x += self.speed * Math.cos(angle); self.y += self.speed * Math.sin(angle); }; }); // Player class var Player = Container.expand(function () { var self = Container.call(this); var playerGraphics = self.attachAsset('character', { anchorX: 0.5, anchorY: 0.5 }); self.rotation = 0; self.bullets = []; self.shoot = function () { var bullet = new Bullet(); bullet.x = self.x; bullet.y = self.y; bullet.rotation = self.rotation; self.bullets.push(bullet); game.addChild(bullet); }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 //Init game with black background }); /**** * Game Code ****/ // Initialize player var player = new Player(); player.x = 2048 / 2; player.y = 2732 / 2; game.addChild(player); // Handle mouse move to rotate player game.move = function (x, y, obj) { var localPos = game.toLocal(obj.global); var dx = localPos.x - player.x; var dy = localPos.y - player.y; player.rotation = Math.atan2(dy, dx); }; // Handle mouse down to shoot var shootingInterval; game.down = function (x, y, obj) { shootingInterval = LK.setInterval(function () { player.shoot(); }, 100); }; game.up = function (x, y, obj) { clearInterval(shootingInterval); }; // Update game state // Initialize enemies array var enemies = []; game.update = function () { // Create enemies at random points along the edge if (LK.ticks % 60 == 0) { var enemy = new Enemy(); var side = Math.floor(Math.random() * 4); switch (side) { case 0: // top enemy.x = Math.random() * 2048; enemy.y = 0; break; case 1: // right enemy.x = 2048; enemy.y = Math.random() * 2732; break; case 2: // bottom enemy.x = Math.random() * 2048; enemy.y = 2732; break; case 3: // left enemy.x = 0; enemy.y = Math.random() * 2732; break; } enemies.push(enemy); game.addChild(enemy); } for (var i = player.bullets.length - 1; i >= 0; i--) { player.bullets[i].update(); if (player.bullets[i].x < 0 || player.bullets[i].x > 2048 || player.bullets[i].y < 0 || player.bullets[i].y > 2732) { player.bullets[i].destroy(); player.bullets.splice(i, 1); } else { for (var j = enemies.length - 1; j >= 0; j--) { if (player.bullets[i].intersects(enemies[j])) { player.bullets[i].destroy(); player.bullets.splice(i, 1); enemies[j].destroy(); enemies.splice(j, 1); break; } } } } for (var j = enemies.length - 1; j >= 0; j--) { if (player.intersects(enemies[j])) { enemies[j].destroy(); enemies.splice(j, 1); } } };
===================================================================
--- original.js
+++ change.js
@@ -74,9 +74,9 @@
};
// Handle mouse down to shoot
var shootingInterval;
game.down = function (x, y, obj) {
- shootingInterval = setInterval(function () {
+ shootingInterval = LK.setInterval(function () {
player.shoot();
}, 100);
};
game.up = function (x, y, obj) {
Fireball with angry face. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows. 8 bit
Grinning creepy ball shaped clown face. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows. 8 bit
Burning ball shaped creepy grinning devil. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows. 8 bit
Creepy Jester clown with a fat circular belly, grinning and carying a trident. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows. 8 bit
Dark night sky. Dim stars. DMT psychedelic. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows. 8 bit