User prompt
Сделай секундомер сверху экрана
User prompt
Сделай так чтоб при столкновении героя и врага игра заканчивалась
User prompt
Сделай так чтоб при попадание в врага пули героя враг умирал
User prompt
Сделай чтоб враги игрока таранили а не стреляли
User prompt
Уменьш скорострельность врага на минимум
User prompt
И уменьши скорость атаки
User prompt
Замедли появление врагов
Initial prompt
Выживания в космосе
/****
* Classes
****/
var Stopwatch = Container.expand(function () {
var self = Container.call(this);
var time = 0;
var stopwatchText = new Text2('00:00', {
size: 100,
fill: "#ffffff"
});
self.addChild(stopwatchText);
self.update = function (delta) {
time += delta;
var minutes = Math.floor(time / 60000);
var seconds = Math.floor(time % 60000 / 1000);
stopwatchText.setText(minutes.toString().padStart(2, '0') + ':' + seconds.toString().padStart(2, '0'));
};
});
// Hero class
var Hero = Container.expand(function () {
var self = Container.call(this);
var heroGraphics = self.attachAsset('hero', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
// Hero update logic
};
self.shoot = function () {
// Hero shooting logic
};
});
// Enemy class
var Enemy = Container.expand(function () {
var self = Container.call(this);
var enemyGraphics = self.attachAsset('enemy', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
// Updated logic for enemies to move towards the player's hero
self.y += 5; // Move enemy down the screen towards the player
};
self.shoot = function () {
// Removed shooting logic so enemies will ram the player
};
});
// Bullet class for hero
var HeroBullet = Container.expand(function () {
var self = Container.call(this);
var bulletGraphics = self.attachAsset('heroBullet', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = -10;
self.move = function () {
self.y += self.speed;
};
});
// Bullet class for enemies
var EnemyBullet = Container.expand(function () {
var self = Container.call(this);
var bulletGraphics = self.attachAsset('enemyBullet', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 5;
self.move = function () {
self.y += self.speed;
};
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000 // Init game with black background
});
/****
* Game Code
****/
// Initialize stopwatch
var stopwatch = game.addChild(new Stopwatch());
stopwatch.x = 2048 / 2 - stopwatch.width / 2;
stopwatch.y = 50;
// Define assets for the hero, enemies, and bullets
// Initialize hero
var hero = game.addChild(new Hero());
hero.x = 2048 / 2;
hero.y = 2732 - 150;
// Initialize enemies and bullets arrays
var enemies = [];
var heroBullets = [];
var enemyBullets = [];
// Game tick event
LK.on('tick', function () {
// Update hero
hero.update();
// Update all enemies
for (var i = enemies.length - 1; i >= 0; i--) {
enemies[i].update();
// End game when hero collides with an enemy
if (enemies[i].intersects(hero)) {
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
return;
}
// Check for enemy off-screen
if (enemies[i].y > 2732) {
enemies[i].destroy();
enemies.splice(i, 1);
}
}
// Update all hero bullets
for (var j = heroBullets.length - 1; j >= 0; j--) {
heroBullets[j].move();
// Check for bullet off-screen or collision with enemies
for (var i = enemies.length - 1; i >= 0; i--) {
if (heroBullets[j].intersects(enemies[i])) {
enemies[i].destroy();
enemies.splice(i, 1);
heroBullets[j].destroy();
heroBullets.splice(j, 1);
break; // Exit the loop after destroying the bullet to avoid errors
}
}
if (heroBullets[j] && heroBullets[j].y < 0) {
heroBullets[j].destroy();
heroBullets.splice(j, 1);
}
}
// Update all enemy bullets
for (var k = enemyBullets.length - 1; k >= 0; k--) {
enemyBullets[k].move();
// Check for bullet off-screen or collision with hero
if (enemyBullets[k].y > 2732 || enemyBullets[k].intersects(hero)) {
enemyBullets[k].destroy();
enemyBullets.splice(k, 1);
}
}
// Update stopwatch
stopwatch.update(LK.delta);
// Hero shooting logic
if (LK.ticks % 60 == 0) {
var bullet = new HeroBullet();
bullet.x = hero.x;
bullet.y = hero.y;
heroBullets.push(bullet);
game.addChild(bullet);
}
// Enemy spawning logic
if (LK.ticks % 240 == 0) {
var enemy = new Enemy();
enemy.x = Math.random() * 2048;
enemy.y = -100;
enemies.push(enemy);
game.addChild(enemy);
}
// Enemy shooting logic
});
// Touch event handling for hero movement
game.on('down', function (obj) {
var touchPos = obj.event.getLocalPosition(game);
hero.x = touchPos.x;
hero.y = touchPos.y;
});
game.on('move', function (obj) {
if (obj.event.target === hero) {
var touchPos = obj.event.getLocalPosition(game);
hero.x = touchPos.x;
hero.y = touchPos.y;
}
});
game.on('up', function (obj) {
// Stop moving the hero when touch ends
}); ===================================================================
--- original.js
+++ change.js
@@ -1,7 +1,22 @@
/****
* Classes
****/
+var Stopwatch = Container.expand(function () {
+ var self = Container.call(this);
+ var time = 0;
+ var stopwatchText = new Text2('00:00', {
+ size: 100,
+ fill: "#ffffff"
+ });
+ self.addChild(stopwatchText);
+ self.update = function (delta) {
+ time += delta;
+ var minutes = Math.floor(time / 60000);
+ var seconds = Math.floor(time % 60000 / 1000);
+ stopwatchText.setText(minutes.toString().padStart(2, '0') + ':' + seconds.toString().padStart(2, '0'));
+ };
+});
// Hero class
var Hero = Container.expand(function () {
var self = Container.call(this);
var heroGraphics = self.attachAsset('hero', {
@@ -64,8 +79,12 @@
/****
* Game Code
****/
+// Initialize stopwatch
+var stopwatch = game.addChild(new Stopwatch());
+stopwatch.x = 2048 / 2 - stopwatch.width / 2;
+stopwatch.y = 50;
// Define assets for the hero, enemies, and bullets
// Initialize hero
var hero = game.addChild(new Hero());
hero.x = 2048 / 2;
@@ -119,8 +138,10 @@
enemyBullets[k].destroy();
enemyBullets.splice(k, 1);
}
}
+ // Update stopwatch
+ stopwatch.update(LK.delta);
// Hero shooting logic
if (LK.ticks % 60 == 0) {
var bullet = new HeroBullet();
bullet.x = hero.x;
Космолет с оружием и видом с верху. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Космический булыжниклетящий и круживщейся вокруг своей оси С видом с верха. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Космический патрон смотрящий прямо. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.