User prompt
quando matar 200 monstros voce ganha o record
User prompt
quando o monstro e atirado, o score de quantos monstros matou fica verde com animaçao por 1 segundo
User prompt
CONTINUA PRETO
User prompt
o fundo continua preto
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'intersects')' in or related to this line: 'if (monsters[j].intersects(bullets[k])) {' Line Number: 126
User prompt
deixe o fundo um ativo
User prompt
remova os 1 segundos antes de ele morrer, quando a bala toca nele, ele morre direto
User prompt
ele morre apos 1 segundo, antes disso ele diminui 4% de seu tamanho em uma velocidade rapida
User prompt
resolva isso, ele nao ta morrendo
User prompt
antes dos 2 segundos do monstro morrer quando e atirado, ele diminui um pouco e depois morre
User prompt
a particula sera um ataivo
User prompt
quando o monstro e atirado, ele explode com particulas se espalhando com animaçao
Initial prompt
tirosntro
===================================================================
--- original.js
+++ change.js
@@ -1,62 +1,82 @@
-/****
+/****
* 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.y += self.speed;
- };
+ var self = Container.call(this);
+ var bulletGraphics = self.attachAsset('bullet', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.speed = -10;
+ self.update = function () {
+ self.y += self.speed;
+ };
});
// Hero class
var Hero = Container.expand(function () {
- var self = Container.call(this);
- var heroGraphics = self.attachAsset('hero', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- self.shoot = function () {
- var newBullet = new Bullet();
- newBullet.x = self.x;
- newBullet.y = self.y;
- bullets.push(newBullet);
- game.addChild(newBullet);
- };
+ var self = Container.call(this);
+ var heroGraphics = self.attachAsset('hero', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.shoot = function () {
+ var newBullet = new Bullet();
+ newBullet.x = self.x;
+ newBullet.y = self.y;
+ bullets.push(newBullet);
+ game.addChild(newBullet);
+ };
});
// Monster class
var Monster = Container.expand(function () {
- var self = Container.call(this);
- var monsterGraphics = self.attachAsset('monster', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- self.speed = 2;
- self.update = function () {
- var dx = hero.x - self.x;
- var dy = hero.y - self.y;
- var dist = Math.sqrt(dx * dx + dy * dy);
- self.x += dx / dist * self.speed;
- self.y += dy / dist * self.speed;
- };
+ var self = Container.call(this);
+ var monsterGraphics = self.attachAsset('monster', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.speed = 2;
+ self.update = function () {
+ var dx = hero.x - self.x;
+ var dy = hero.y - self.y;
+ var dist = Math.sqrt(dx * dx + dy * dy);
+ self.x += dx / dist * self.speed;
+ self.y += dy / dist * self.speed;
+ };
});
+// Particle class
+var Particle = Container.expand(function () {
+ var self = Container.call(this);
+ var particleGraphics = self.attachAsset('bullet', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.speedX = Math.random() * 10 - 5;
+ self.speedY = Math.random() * 10 - 5;
+ self.update = function () {
+ self.x += self.speedX;
+ self.y += self.speedY;
+ self.speedX *= 0.99;
+ self.speedY *= 0.99;
+ self.alpha *= 0.96;
+ if (self.alpha < 0.01) {
+ self.destroy();
+ }
+ };
+});
-/****
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000 //Init game with black background
+ backgroundColor: 0x000000 //Init game with black background
});
-/****
+/****
* Game Code
-****/
+****/
// Initialize variables
var hero = new Hero();
hero.x = 2048 / 2;
hero.y = 2732 - 200;
@@ -64,56 +84,69 @@
var bullets = [];
var monsters = [];
var score = 0;
var scoreTxt = new Text2('0', {
- size: 150,
- fill: "#ffffff"
+ size: 150,
+ fill: "#ffffff"
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
// Spawn monsters at intervals
var spawnMonster = LK.setInterval(function () {
- var newMonster = new Monster();
- newMonster.x = Math.random() * 2048;
- newMonster.y = 0;
- monsters.push(newMonster);
- game.addChild(newMonster);
+ var newMonster = new Monster();
+ newMonster.x = Math.random() * 2048;
+ newMonster.y = 0;
+ monsters.push(newMonster);
+ game.addChild(newMonster);
}, 2000);
// Handle game updates
game.update = function () {
- for (var i = bullets.length - 1; i >= 0; i--) {
- bullets[i].update();
- if (bullets[i].y < -50) {
- bullets[i].destroy();
- bullets.splice(i, 1);
- }
- }
- for (var j = monsters.length - 1; j >= 0; j--) {
- monsters[j].update();
- if (monsters[j].intersects(hero)) {
- LK.effects.flashScreen(0xff0000, 1000);
- LK.showGameOver();
- }
- for (var k = bullets.length - 1; k >= 0; k--) {
- if (monsters[j].intersects(bullets[k])) {
- monsters[j].destroy();
- bullets[k].destroy();
- monsters.splice(j, 1);
- bullets.splice(k, 1);
- score++;
- scoreTxt.setText(score);
- break;
- }
- }
- }
+ for (var i = bullets.length - 1; i >= 0; i--) {
+ bullets[i].update();
+ if (bullets[i].y < -50) {
+ bullets[i].destroy();
+ bullets.splice(i, 1);
+ }
+ }
+ for (var j = monsters.length - 1; j >= 0; j--) {
+ monsters[j].update();
+ if (monsters[j].intersects(hero)) {
+ LK.effects.flashScreen(0xff0000, 1000);
+ LK.showGameOver();
+ }
+ for (var k = bullets.length - 1; k >= 0; k--) {
+ if (monsters[j].intersects(bullets[k])) {
+ // Create particles when the monster is destroyed
+ for (var p = 0; p < 100; p++) {
+ var newParticle = new Particle();
+ newParticle.x = monsters[j].x;
+ newParticle.y = monsters[j].y;
+ game.addChild(newParticle);
+ }
+ monsters[j].destroy();
+ bullets[k].destroy();
+ monsters.splice(j, 1);
+ bullets.splice(k, 1);
+ score++;
+ scoreTxt.setText(score);
+ break;
+ }
+ }
+ }
};
// Handle touch events
game.down = function (x, y, obj) {
- hero.shoot();
+ hero.shoot();
};
game.move = function (x, y, obj) {
- hero.x = x;
- hero.y = y;
+ hero.x = x;
+ hero.y = y;
};
game.up = function (x, y, obj) {
- // No action needed on touch up
-};
\ No newline at end of file
+ // No action needed on touch up
+};
+// Update particles
+for (var i = game.children.length - 1; i >= 0; i--) {
+ if (game.children[i] instanceof Particle) {
+ game.children[i].update();
+ }
+}
\ No newline at end of file
uma bola preta com chifres, e com olhos vermelhos com um sorriso assustador, fundo png. Single Game Texture. In-Game asset. 3d. Blank background. High contrast. No shadows.
uma bola verde, com olhos azuiis fofos , fundo png. Single Game Texture. In-Game asset. 3d. Blank background. High contrast. No shadows.
uma particula vermelha brilhante, fundo png. Single Game Texture. In-Game asset. 3d. Blank background. High contrast. No shadows.
pariculas cinzas, fundo png. Single Game Texture. In-Game asset. 3d. Blank background. High contrast. No shadows.
uma rua com ceu azul, fundo png. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.