User prompt
Make score chart
User prompt
Make enemies disappear when shot
User prompt
Increase player speed by a bunch
User prompt
Make player move faster
User prompt
Make enemy lives decrease by 1 live when hit
User prompt
Make enemies at top of game
User prompt
Delete lightblue block
User prompt
Delete light blue block
User prompt
Please fix the bug: 'ReferenceError: target is not defined' in or related to this line: 'if (fire.intersects(target)) {' Line Number: 136
User prompt
Make blue blocks bad guys
User prompt
Please fix the bug: 'ReferenceError: player is not defined' in or related to this line: 'if (player.intersects(target)) {' Line Number: 118
User prompt
Please fix the bug: 'Uncaught ReferenceError: player is not defined' in or related to this line: 'fire.x = player.x;' Line Number: 97
User prompt
Make a rocket that shoots red fiery bullets
User prompt
Make player have 3 lives
User prompt
Make joystick for player
User prompt
Make a fire breathing monster
Initial prompt
Creeper99iscool
/**** * Classes ****/ // Define the 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 () { self.y += self.speed; }; }); var FieryBullet = Container.expand(function () { var self = Container.call(this); var fieryBulletGraphics = self.attachAsset('fieryBullet', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 5; self.update = function () { self.y -= self.speed; }; }); // Define the Fire class var Fire = Container.expand(function () { var self = Container.call(this); var fireGraphics = self.attachAsset('fire', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 5; self.update = function () { self.y -= self.speed; }; }); //<Assets used in the game will automatically appear here> // Define the Player class var Rocket = Container.expand(function () { var self = Container.call(this); var rocketGraphics = self.attachAsset('rocket', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 40; self.update = function () { // Rocket update logic }; self.move = function (x, y) { self.x = x; self.y = y; }; }); // Define the Score class var Score = Container.expand(function () { var self = Container.call(this); var scoreGraphics = self.attachAsset('score', { anchorX: 0.5, anchorY: 0.5 }); self.update = function () { // Score update logic }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 //Init game with black background }); /**** * Game Code ****/ // Initialize player, target, fire, enemies, joystick and score var rocket = game.addChild(new Rocket()); rocket.x = 2048 / 2; rocket.y = 2732 - 200; rocket.lives = 3; // Initialize rocket with 3 lives var score = game.addChild(new Score()); score.x = 2048 / 2; score.y = 50; var fieryBullets = []; var fire = game.addChild(new Fire()); fire.x = rocket.x; fire.y = rocket.y; var enemies = []; for (var i = 0; i < 5; i++) { var enemy = game.addChild(new Enemy()); enemy.x = Math.random() * 2048; enemy.y = 0; enemies.push(enemy); } // Handle player movement and fire breathing game.down = function (x, y, obj) { var dx = x - rocket.x; var dy = y - rocket.y; var angle = Math.atan2(dy, dx); rocket.x += Math.cos(angle) * rocket.speed; rocket.y += Math.sin(angle) * rocket.speed; var newFieryBullet = new FieryBullet(); newFieryBullet.x = rocket.x; newFieryBullet.y = rocket.y; fieryBullets.push(newFieryBullet); game.addChild(newFieryBullet); }; // Check for win condition, player lives and enemy movement game.update = function () { if (rocket.lives <= 0) { LK.showGameOver(); // Show game over when rocket has no more lives } for (var i = enemies.length - 1; i >= 0; i--) { var enemy = enemies[i]; if (enemy.y > 2732) { enemy.y = 0; enemy.x = Math.random() * 2048; } if (enemy.intersects(rocket)) { rocket.lives--; enemy.y = 0; enemy.x = Math.random() * 2048; } for (var j = fieryBullets.length - 1; j >= 0; j--) { var fieryBullet = fieryBullets[j]; if (fieryBullet.intersects(enemy)) { enemy.destroy(); enemies.splice(i, 1); fieryBullet.destroy(); fieryBullets.splice(j, 1); // Increase the score by 1 each time an enemy is destroyed score.setText(parseInt(score.getText()) + 1); } } } };
===================================================================
--- original.js
+++ change.js
@@ -52,17 +52,17 @@
self.x = x;
self.y = y;
};
});
-// Define the Target class
-var Target = Container.expand(function () {
+// Define the Score class
+var Score = Container.expand(function () {
var self = Container.call(this);
- var targetGraphics = self.attachAsset('target', {
+ var scoreGraphics = self.attachAsset('score', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
- // Target update logic
+ // Score update logic
};
});
/****
@@ -74,13 +74,16 @@
/****
* Game Code
****/
-// Initialize player, target, fire, enemies and joystick
+// Initialize player, target, fire, enemies, joystick and score
var rocket = game.addChild(new Rocket());
rocket.x = 2048 / 2;
rocket.y = 2732 - 200;
rocket.lives = 3; // Initialize rocket with 3 lives
+var score = game.addChild(new Score());
+score.x = 2048 / 2;
+score.y = 50;
var fieryBullets = [];
var fire = game.addChild(new Fire());
fire.x = rocket.x;
fire.y = rocket.y;
@@ -126,8 +129,10 @@
enemy.destroy();
enemies.splice(i, 1);
fieryBullet.destroy();
fieryBullets.splice(j, 1);
+ // Increase the score by 1 each time an enemy is destroyed
+ score.setText(parseInt(score.getText()) + 1);
}
}
}
};
\ No newline at end of file
Red fiery bullet. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Monster. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Rocket. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Space scene that would be good for an app background. Single Game Texture. In-Game asset. 3d. Blank background. High contrast. No shadows.
Bullet dropping downward. Single Game Texture. In-Game asset. 3D. Blank background. High contrast. No shadows.