User prompt
Замедли скорость прицела в полтора раза
User prompt
Враги должны исчезать после уничтожения
User prompt
Замедли падение врагов в два раза
User prompt
Так я понял ручка джойстика появляется в центре но почему-то сразу оказывается в правом нижнем углу при малейшем сдвиге
User prompt
Теперь она начинает движение из правого нижнего угла
User prompt
Проблема в том что ручка джойстика начинает свое движение не из центра базового круга, а из низа. Это нужно исправить
User prompt
Ускорь движение прицела в 2 раза
User prompt
Джойстик должен начинать свое движение из середины чем дальше маленький круг джойстика от центра большого круга тем быстрее движется прицел
User prompt
Прицел должен наносить урон даже когда стоит на месте и им никто не управляет
User prompt
Прицел всегда должен отображаться поверх падающих обьектов
User prompt
Еще раз исправь и сделай больше
User prompt
Переделай джойстик мне не нравится как он работает
User prompt
Исправь джойстик. Он с первого движения ведет прицел вниз. Каждый раз его поиходится поднимать вверх до нейтральной позиции
User prompt
Моленький круг джойстика при первом движении оказывается внизу, из-за жтого прицел сразу едит аниз и так каждый раз, а нужно что бы он был в середине большого коуга
User prompt
Почему-то приджойстик начинает свое движение не из центра а снизу исправь
User prompt
Джойстик не появляется и не работает
User prompt
Джойстик сделай больше и он должен появляться в любом месте куда тыкнет игрок
User prompt
Изменим немного способ нанесения урона. Добавь уэприцел и экранный джойстик для управления прицелом как во многих мобильных игр
User prompt
Удали весь код и сделай новую игру. Суть игры: сверху будут падать различные обьекты а снизу будет город на который они должны упасть и нанести урон городу. Задача игрока не дать упасть предметам на город методом клика на них, можно просто зажать и с определенной периодичностью будет наносится урон. Эти обьекты условно метеориты и инопланетяне. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
КРУГ НЕ СЖИМАЕТСЯ ВО ВРЕМЯ СТОЛКНОВЕНИЯ С КРАЕМ КАРТЫ
User prompt
кружок должен при столкновении вести себя как желе
User prompt
Please fix the bug: 'TypeError: tween.to is not a function' in or related to this line: 'tween.to(self.circleGraphic, squashDuration, {' Line Number: 28
User prompt
Нужно добавить анимацию кругу как будто он мягкий
User prompt
Сотри весь код и напиши новую игру. Игра простая пока так: в центре экрана появляется круг и начинает двигаться в случайном направлении отталкиваясь от края экрана и продолжая двигаться по траэктории
User prompt
как-то медленно он подпрыгивает и длинные паузы делает перед прыжком мне не нравится
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var City = Container.expand(function () { var self = Container.call(this); self.takeDamage = function (damageAmount) { if (self.health <= 0) return; // Already destroyed self.health -= damageAmount; LK.effects.flashObject(self.graphic, 0xFF0000, 300); // Flash city red if (self.healthDisplay) { self.healthDisplay.setText('City Health: ' + Math.max(0, self.health) + ' / ' + CITY_MAX_HEALTH); } if (self.health <= 0) { self.health = 0; // Cap at 0 LK.showGameOver(); // Trigger game over } }; self.setHealthDisplay = function (textObject) { self.healthDisplay = textObject; self.healthDisplay.setText('City Health: ' + self.health + ' / ' + CITY_MAX_HEALTH); }; // Initialization self.graphic = self.attachAsset('city', { anchorX: 0.5, anchorY: 1.0 }); // Anchor bottom-center self.health = CITY_MAX_HEALTH; self.healthDisplay = null; // To be linked to a Text2 object return self; }); // Base class for falling objects var FallingObject = Container.expand(function (assetId, initialHealth, fallSpeed, objectType) { var self = Container.call(this); self.takeDamage = function (damageAmount) { if (self.isDestroyed) return; self.health -= damageAmount; LK.effects.flashObject(self.graphic, 0xFF0000, 100); // Red flash on hit if (self.health <= 0) { self.destroySelf(); } }; self.destroySelf = function () { if (self.isDestroyed) return; self.isDestroyed = true; // Add a small particle explosion or shrink effect if (tween) { tween.stop(self.graphic); // Stop any ongoing tweens tween(self.graphic, 200, { scaleX: 0.1, scaleY: 0.1, alpha: 0, onComplete: function onComplete() { // Actual removal from game will be handled in game.update } }); } // Points for destroying object LK.setScore(LK.getScore() + (self.objectType === 'meteor' ? 10 : 15)); updateScoreDisplay(); }; self.update = function () { if (self.isDestroyed) return; self.y += self.speedY; }; self.down = function (x, y, eventObj) { if (self.isDestroyed) return; self.takeDamage(CLICK_DAMAGE); // If not already holding or holding a different target if (!game.isPlayerHolding || game.playerHoldingTarget !== self) { game.isPlayerHolding = true; game.playerHoldingTarget = self; if (game.holdDamageInterval) { LK.clearInterval(game.holdDamageInterval); } game.holdDamageInterval = LK.setInterval(function () { if (game.isPlayerHolding && game.playerHoldingTarget === self && !self.isDestroyed) { self.takeDamage(HOLD_DAMAGE_PER_INTERVAL); } else { // Target destroyed or player released finger/mouse elsewhere (handled by game.up) // Or if player switched target by clicking another object if (game.holdDamageInterval) { LK.clearInterval(game.holdDamageInterval); game.holdDamageInterval = null; } } }, HOLD_DAMAGE_INTERVAL_MS); } }; // Initialization self.graphic = self.attachAsset(assetId, { anchorX: 0.5, anchorY: 0.5 }); self.health = initialHealth; self.maxHealth = initialHealth; // Store max health for potential future use (e.g. health bars on objects) self.speedY = fallSpeed; self.isDestroyed = false; self.objectType = objectType; // 'meteor' or 'alien' return self; }); var Meteor = FallingObject.expand(function () { var self = FallingObject.call(this, 'meteor', METEOR_HEALTH, METEOR_SPEED, 'meteor'); // Meteor-specific properties or methods can be added here return self; }); var Alien = FallingObject.expand(function () { var self = FallingObject.call(this, 'alien', ALIEN_HEALTH, ALIEN_SPEED, 'alien'); // Alien-specific properties or methods (e.g., different movement pattern) return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x00001A // Dark deep blue for space }); /**** * Game Code ****/ // Grey city base // Lime green alien (can be simple box for now) // Brownish meteor // --- Game Constants --- var WORLD_WIDTH = 2048; var WORLD_HEIGHT = 2732; var METEOR_HEALTH = 100; var METEOR_SPEED = 3; // Pixels per frame var METEOR_DAMAGE_TO_CITY = 75; var ALIEN_HEALTH = 150; var ALIEN_SPEED = 2.5; var ALIEN_DAMAGE_TO_CITY = 100; var CITY_MAX_HEALTH = 1000; var CLICK_DAMAGE = 35; var HOLD_DAMAGE_PER_INTERVAL = 20; var HOLD_DAMAGE_INTERVAL_MS = 150; // Milliseconds var SPAWN_INTERVAL_MS_MIN = 1200; // Minimum time between spawns var SPAWN_INTERVAL_MS_MAX = 2500; // Maximum time between spawns // --- Global Game Variables --- var cityInstance; var fallingObjects = []; var cityHealthText; // For GUI var scoreText; // For player score var playerHoldingTarget = null; var isPlayerHolding = false; var holdDamageInterval = null; var nextSpawnTime = 0; // --- Helper Functions --- function spawnFallingObject() { var objectType = Math.random() < 0.6 ? 'meteor' : 'alien'; // 60% meteors, 40% aliens var newObject; if (objectType === 'meteor') { newObject = new Meteor(); } else { newObject = new Alien(); } // Position just above the screen, at a random horizontal position newObject.x = Math.random() * (WORLD_WIDTH - newObject.graphic.width) + newObject.graphic.width / 2; newObject.y = -newObject.graphic.height / 2; // Start just off-screen top fallingObjects.push(newObject); game.addChild(newObject); } function updateScoreDisplay() { if (scoreText) { scoreText.setText('Score: ' + LK.getScore()); } } // --- Game Initialization --- // Create and position the city cityInstance = new City(); cityInstance.x = WORLD_WIDTH / 2; cityInstance.y = WORLD_HEIGHT; // Bottom edge of city at bottom of screen game.addChild(cityInstance); // Setup City Health Display cityHealthText = new Text2('', { size: 60, fill: 0xFFFFFF, align: 'center' }); cityHealthText.anchor.set(0.5, 1); // Anchor bottom-center for text LK.gui.bottom.addChild(cityHealthText); // Add to bottom center of GUI cityInstance.setHealthDisplay(cityHealthText); // Link to city instance // Setup Score Display LK.setScore(0); // Initialize score scoreText = new Text2('Score: 0', { size: 60, fill: 0xFFFF00, align: 'center' }); scoreText.anchor.set(0.5, 0); // Anchor top-center // Position score text slightly below the top edge to avoid any engine icons, if necessary // LK.gui.top has y=0. We'll add a small offset. scoreText.y = 20; // Small offset from the very top. LK.gui.top.addChild(scoreText); // --- Event Handlers --- game.up = function (x, y, eventObj) { // This global up handler clears any active hold damaging if (isPlayerHolding) { isPlayerHolding = false; playerHoldingTarget = null; // Clear the specific target if (holdDamageInterval) { LK.clearInterval(holdDamageInterval); holdDamageInterval = null; } } }; // --- Game Loop --- game.update = function () { var currentTime = LK.ticks * (1000 / 60); // Approximate current time in ms // 1. Spawn new falling objects if (currentTime >= nextSpawnTime) { spawnFallingObject(); nextSpawnTime = currentTime + SPAWN_INTERVAL_MS_MIN + Math.random() * (SPAWN_INTERVAL_MS_MAX - SPAWN_INTERVAL_MS_MIN); } // 2. Update and check falling objects for (var i = fallingObjects.length - 1; i >= 0; i--) { var obj = fallingObjects[i]; if (obj.isDestroyed) { // If destruction animation is handled by tween onComplete, // we might need a flag or delay before removing from stage/array. // For now, assume tween alpha/scale handles visual, then remove. if (obj.graphic.alpha === 0 || obj.graphic.scale.x < 0.2) { // Check if tween likely finished if (obj.parent) { // Ensure it's still parented before trying to remove game.removeChild(obj); } fallingObjects.splice(i, 1); } continue; // Skip further processing for destroyed objects } obj.update(); // Move the object // Check for collision with the city // Object's bottom edge: obj.y + obj.graphic.height / 2 // City's top edge: cityInstance.y - cityInstance.graphic.height if (obj.y + obj.graphic.height * 0.5 * obj.graphic.scaleY >= cityInstance.y - cityInstance.graphic.height) { var damageToCity = obj.objectType === 'meteor' ? METEOR_DAMAGE_TO_CITY : ALIEN_DAMAGE_TO_CITY; cityInstance.takeDamage(damageToCity); obj.destroySelf(); // Object is destroyed upon hitting the city (it can also flash/explode) // No need to splice here, the `obj.isDestroyed` check handles it next frame or after tween continue; } // Check if object fell past the bottom of the screen (e.g., if city was already destroyed) if (obj.y - obj.graphic.height / 2 > WORLD_HEIGHT) { obj.destroySelf(); // Or just silently remove // No need to splice here, obj.isDestroyed handles it continue; } } // Safety check: if playerHoldingTarget got destroyed but interval didn't clear if (isPlayerHolding && playerHoldingTarget && playerHoldingTarget.isDestroyed) { isPlayerHolding = false; playerHoldingTarget = null; if (holdDamageInterval) { LK.clearInterval(holdDamageInterval); holdDamageInterval = null; } } };
===================================================================
--- original.js
+++ change.js
@@ -5,151 +5,261 @@
/****
* Classes
****/
-// A green circle
-var BouncingCircle = Container.expand(function () {
+var City = Container.expand(function () {
var self = Container.call(this);
- // Method to animate squash and stretch on collision
- // Methods must be defined before properties are assigned if they use those properties (though JS hoists function defs)
- // Best practice: define methods first.
- self.animateHit = function (targetScaleXFactor, targetScaleYFactor) {
- // Assuming self.circleGraphic.scaleX and self.circleGraphic.scaleY default to 1
- // and should return to 1 after the animation.
- var normalScale = 1.0;
- var squashDuration = 80; // milliseconds
- var returnDuration = 120; // milliseconds
- // Tween to squashed/stretched state
- // Assumes a new tween on the same properties will override any existing one.
- tween(self.circleGraphic, squashDuration, {
- scaleX: normalScale * targetScaleXFactor,
- scaleY: normalScale * targetScaleYFactor,
- onComplete: function onComplete() {
- // Wobble back to normal scale with a jelly effect (overshoot and settle)
- // First overshoot past normal, then return, then settle
- tween(self.circleGraphic, returnDuration, {
- scaleX: normalScale + (targetScaleYFactor - 1) * 0.25,
- scaleY: normalScale + (targetScaleXFactor - 1) * 0.25,
- onComplete: function onComplete() {
- tween(self.circleGraphic, 90, {
- scaleX: normalScale - (targetScaleYFactor - 1) * 0.15,
- scaleY: normalScale - (targetScaleXFactor - 1) * 0.15,
- onComplete: function onComplete() {
- tween(self.circleGraphic, 70, {
- scaleX: normalScale,
- scaleY: normalScale
- });
- }
- });
- }
- });
- }
- });
+ self.takeDamage = function (damageAmount) {
+ if (self.health <= 0) return; // Already destroyed
+ self.health -= damageAmount;
+ LK.effects.flashObject(self.graphic, 0xFF0000, 300); // Flash city red
+ if (self.healthDisplay) {
+ self.healthDisplay.setText('City Health: ' + Math.max(0, self.health) + ' / ' + CITY_MAX_HEALTH);
+ }
+ if (self.health <= 0) {
+ self.health = 0; // Cap at 0
+ LK.showGameOver(); // Trigger game over
+ }
};
+ self.setHealthDisplay = function (textObject) {
+ self.healthDisplay = textObject;
+ self.healthDisplay.setText('City Health: ' + self.health + ' / ' + CITY_MAX_HEALTH);
+ };
+ // Initialization
+ self.graphic = self.attachAsset('city', {
+ anchorX: 0.5,
+ anchorY: 1.0
+ }); // Anchor bottom-center
+ self.health = CITY_MAX_HEALTH;
+ self.healthDisplay = null; // To be linked to a Text2 object
+ return self;
+});
+// Base class for falling objects
+var FallingObject = Container.expand(function (assetId, initialHealth, fallSpeed, objectType) {
+ var self = Container.call(this);
+ self.takeDamage = function (damageAmount) {
+ if (self.isDestroyed) return;
+ self.health -= damageAmount;
+ LK.effects.flashObject(self.graphic, 0xFF0000, 100); // Red flash on hit
+ if (self.health <= 0) {
+ self.destroySelf();
+ }
+ };
+ self.destroySelf = function () {
+ if (self.isDestroyed) return;
+ self.isDestroyed = true;
+ // Add a small particle explosion or shrink effect
+ if (tween) {
+ tween.stop(self.graphic); // Stop any ongoing tweens
+ tween(self.graphic, 200, {
+ scaleX: 0.1,
+ scaleY: 0.1,
+ alpha: 0,
+ onComplete: function onComplete() {
+ // Actual removal from game will be handled in game.update
+ }
+ });
+ }
+ // Points for destroying object
+ LK.setScore(LK.getScore() + (self.objectType === 'meteor' ? 10 : 15));
+ updateScoreDisplay();
+ };
self.update = function () {
- // Update position based on current speed
- self.x += self.speedX;
+ if (self.isDestroyed) return;
self.y += self.speedY;
- // Get UN SCALED dimensions for boundary checks (anchor is 0.5, 0.5)
- // Collision boundary should be consistent and not affected by visual scale animation.
- var baseWidth = self.circleGraphic.width;
- var baseHeight = self.circleGraphic.height;
- var halfWidth = baseWidth * (self.circleGraphic.scaleX || 1) / 2;
- var halfHeight = baseHeight * (self.circleGraphic.scaleY || 1) / 2;
- // Game world dimensions
- var worldWidth = 2048;
- var worldHeight = 2732;
- // Check for collision with horizontal walls
- if (self.x - halfWidth <= 0) {
- // Hit left wall
- self.x = halfWidth; // Clamp position to prevent sticking
- if (self.speedX < 0 && self.lastX - baseWidth / 2 > 0) {
- // Only reverse if moving towards wall and just hit this frame
- self.speedX *= -1;
- self.animateHit(0.7, 1.2); // Squash horizontally, stretch vertically
+ };
+ self.down = function (x, y, eventObj) {
+ if (self.isDestroyed) return;
+ self.takeDamage(CLICK_DAMAGE);
+ // If not already holding or holding a different target
+ if (!game.isPlayerHolding || game.playerHoldingTarget !== self) {
+ game.isPlayerHolding = true;
+ game.playerHoldingTarget = self;
+ if (game.holdDamageInterval) {
+ LK.clearInterval(game.holdDamageInterval);
}
- } else if (self.x + halfWidth >= worldWidth) {
- // Hit right wall
- self.x = worldWidth - halfWidth; // Clamp position
- if (self.speedX > 0 && self.lastX + baseWidth / 2 < worldWidth) {
- // Only reverse if moving towards wall and just hit this frame
- self.speedX *= -1;
- self.animateHit(0.7, 1.2); // Squash horizontally, stretch vertically
- }
+ game.holdDamageInterval = LK.setInterval(function () {
+ if (game.isPlayerHolding && game.playerHoldingTarget === self && !self.isDestroyed) {
+ self.takeDamage(HOLD_DAMAGE_PER_INTERVAL);
+ } else {
+ // Target destroyed or player released finger/mouse elsewhere (handled by game.up)
+ // Or if player switched target by clicking another object
+ if (game.holdDamageInterval) {
+ LK.clearInterval(game.holdDamageInterval);
+ game.holdDamageInterval = null;
+ }
+ }
+ }, HOLD_DAMAGE_INTERVAL_MS);
}
- // Check for collision with vertical walls
- if (self.y - halfHeight <= 0) {
- // Hit top wall
- self.y = halfHeight; // Clamp position
- if (self.speedY < 0 && self.lastY - baseHeight / 2 > 0) {
- // Only reverse if moving towards wall and just hit this frame
- self.speedY *= -1;
- self.animateHit(1.2, 0.7); // Stretch horizontally, squash vertically
- }
- } else if (self.y + halfHeight >= worldHeight) {
- // Hit bottom wall
- self.y = worldHeight - halfHeight; // Clamp position
- if (self.speedY > 0 && self.lastY + baseHeight / 2 < worldHeight) {
- // Only reverse if moving towards wall and just hit this frame
- self.speedY *= -1;
- self.animateHit(1.2, 0.7); // Stretch horizontally, squash vertically
- }
- }
- // Store current position as last position for the next frame
- self.lastX = self.x;
- self.lastY = self.y;
};
- // Attach the visual asset to this container
- // The asset 'bouncingCircleAsset' needs to be defined in the Assets section
- self.circleGraphic = self.attachAsset('bouncingCircleAsset', {
+ // Initialization
+ self.graphic = self.attachAsset(assetId, {
anchorX: 0.5,
- // Center anchor for easier positioning
anchorY: 0.5
});
- // self.circleGraphic.scaleX and self.circleGraphic.scaleY will default to 1.0
- // if not specified in attachAsset or set manually after.
- // Movement properties to be initialized when an instance is created
- self.speedX = 0;
- self.speedY = 0;
- // Store last known position (initialized when circle is created)
- self.lastX = 0;
- self.lastY = 0;
- return self; // Important for class structure
+ self.health = initialHealth;
+ self.maxHealth = initialHealth; // Store max health for potential future use (e.g. health bars on objects)
+ self.speedY = fallSpeed;
+ self.isDestroyed = false;
+ self.objectType = objectType; // 'meteor' or 'alien'
+ return self;
});
+var Meteor = FallingObject.expand(function () {
+ var self = FallingObject.call(this, 'meteor', METEOR_HEALTH, METEOR_SPEED, 'meteor');
+ // Meteor-specific properties or methods can be added here
+ return self;
+});
+var Alien = FallingObject.expand(function () {
+ var self = FallingObject.call(this, 'alien', ALIEN_HEALTH, ALIEN_SPEED, 'alien');
+ // Alien-specific properties or methods (e.g., different movement pattern)
+ return self;
+});
/****
* Initialize Game
****/
var game = new LK.Game({
- backgroundColor: 0x202040 // A nice dark blue/purple background
+ backgroundColor: 0x00001A // Dark deep blue for space
});
/****
* Game Code
****/
-// Create an instance of our BouncingCircle class
-// Game dimensions are 2048x2732 (width x height)
-//Minimalistic tween library which should be used for animations over time, including tinting / colouring an object, scaling, rotating, or changing any game object property.
-var circle = new BouncingCircle();
-// Position the circle in the center of the screen.
-// Its graphic asset has anchorX: 0.5, anchorY: 0.5, so this centers it.
-circle.x = 2048 / 2;
-circle.y = 2732 / 2;
-// Initialize its lastX and lastY properties to its starting position
-circle.lastX = circle.x;
-circle.lastY = circle.y;
-// Set a random initial direction and speed for the circle
-var initialSpeedMagnitude = 8; // Adjust this value for faster or slower movement (pixels per frame)
-var randomAngle = Math.random() * 2 * Math.PI; // Generates a random angle in radians (0 to 2*PI)
-circle.speedX = initialSpeedMagnitude * Math.cos(randomAngle);
-circle.speedY = initialSpeedMagnitude * Math.sin(randomAngle);
-// Safety check: if somehow both speeds are zero (highly unlikely with non-zero magnitude), give it a default push.
-if (circle.speedX === 0 && circle.speedY === 0 && initialSpeedMagnitude !== 0) {
- circle.speedX = initialSpeedMagnitude; // Default to moving right
+// Grey city base
+// Lime green alien (can be simple box for now)
+// Brownish meteor
+// --- Game Constants ---
+var WORLD_WIDTH = 2048;
+var WORLD_HEIGHT = 2732;
+var METEOR_HEALTH = 100;
+var METEOR_SPEED = 3; // Pixels per frame
+var METEOR_DAMAGE_TO_CITY = 75;
+var ALIEN_HEALTH = 150;
+var ALIEN_SPEED = 2.5;
+var ALIEN_DAMAGE_TO_CITY = 100;
+var CITY_MAX_HEALTH = 1000;
+var CLICK_DAMAGE = 35;
+var HOLD_DAMAGE_PER_INTERVAL = 20;
+var HOLD_DAMAGE_INTERVAL_MS = 150; // Milliseconds
+var SPAWN_INTERVAL_MS_MIN = 1200; // Minimum time between spawns
+var SPAWN_INTERVAL_MS_MAX = 2500; // Maximum time between spawns
+// --- Global Game Variables ---
+var cityInstance;
+var fallingObjects = [];
+var cityHealthText; // For GUI
+var scoreText; // For player score
+var playerHoldingTarget = null;
+var isPlayerHolding = false;
+var holdDamageInterval = null;
+var nextSpawnTime = 0;
+// --- Helper Functions ---
+function spawnFallingObject() {
+ var objectType = Math.random() < 0.6 ? 'meteor' : 'alien'; // 60% meteors, 40% aliens
+ var newObject;
+ if (objectType === 'meteor') {
+ newObject = new Meteor();
+ } else {
+ newObject = new Alien();
+ }
+ // Position just above the screen, at a random horizontal position
+ newObject.x = Math.random() * (WORLD_WIDTH - newObject.graphic.width) + newObject.graphic.width / 2;
+ newObject.y = -newObject.graphic.height / 2; // Start just off-screen top
+ fallingObjects.push(newObject);
+ game.addChild(newObject);
}
-// Add the circle instance to the game's display list.
-// The LK engine will automatically call the .update() method of 'circle' each frame.
-game.addChild(circle);
-// No explicit game.update() function is required for this simple game,
-// as the circle's movement and logic are self-contained in its BouncingCircle.update() method.
-// If we had other global game logic that needed to run every frame (e.g., checking win/loss conditions,
-// spawning new objects), we would define game.update = function() { ... }; here.
\ No newline at end of file
+function updateScoreDisplay() {
+ if (scoreText) {
+ scoreText.setText('Score: ' + LK.getScore());
+ }
+}
+// --- Game Initialization ---
+// Create and position the city
+cityInstance = new City();
+cityInstance.x = WORLD_WIDTH / 2;
+cityInstance.y = WORLD_HEIGHT; // Bottom edge of city at bottom of screen
+game.addChild(cityInstance);
+// Setup City Health Display
+cityHealthText = new Text2('', {
+ size: 60,
+ fill: 0xFFFFFF,
+ align: 'center'
+});
+cityHealthText.anchor.set(0.5, 1); // Anchor bottom-center for text
+LK.gui.bottom.addChild(cityHealthText); // Add to bottom center of GUI
+cityInstance.setHealthDisplay(cityHealthText); // Link to city instance
+// Setup Score Display
+LK.setScore(0); // Initialize score
+scoreText = new Text2('Score: 0', {
+ size: 60,
+ fill: 0xFFFF00,
+ align: 'center'
+});
+scoreText.anchor.set(0.5, 0); // Anchor top-center
+// Position score text slightly below the top edge to avoid any engine icons, if necessary
+// LK.gui.top has y=0. We'll add a small offset.
+scoreText.y = 20; // Small offset from the very top.
+LK.gui.top.addChild(scoreText);
+// --- Event Handlers ---
+game.up = function (x, y, eventObj) {
+ // This global up handler clears any active hold damaging
+ if (isPlayerHolding) {
+ isPlayerHolding = false;
+ playerHoldingTarget = null; // Clear the specific target
+ if (holdDamageInterval) {
+ LK.clearInterval(holdDamageInterval);
+ holdDamageInterval = null;
+ }
+ }
+};
+// --- Game Loop ---
+game.update = function () {
+ var currentTime = LK.ticks * (1000 / 60); // Approximate current time in ms
+ // 1. Spawn new falling objects
+ if (currentTime >= nextSpawnTime) {
+ spawnFallingObject();
+ nextSpawnTime = currentTime + SPAWN_INTERVAL_MS_MIN + Math.random() * (SPAWN_INTERVAL_MS_MAX - SPAWN_INTERVAL_MS_MIN);
+ }
+ // 2. Update and check falling objects
+ for (var i = fallingObjects.length - 1; i >= 0; i--) {
+ var obj = fallingObjects[i];
+ if (obj.isDestroyed) {
+ // If destruction animation is handled by tween onComplete,
+ // we might need a flag or delay before removing from stage/array.
+ // For now, assume tween alpha/scale handles visual, then remove.
+ if (obj.graphic.alpha === 0 || obj.graphic.scale.x < 0.2) {
+ // Check if tween likely finished
+ if (obj.parent) {
+ // Ensure it's still parented before trying to remove
+ game.removeChild(obj);
+ }
+ fallingObjects.splice(i, 1);
+ }
+ continue; // Skip further processing for destroyed objects
+ }
+ obj.update(); // Move the object
+ // Check for collision with the city
+ // Object's bottom edge: obj.y + obj.graphic.height / 2
+ // City's top edge: cityInstance.y - cityInstance.graphic.height
+ if (obj.y + obj.graphic.height * 0.5 * obj.graphic.scaleY >= cityInstance.y - cityInstance.graphic.height) {
+ var damageToCity = obj.objectType === 'meteor' ? METEOR_DAMAGE_TO_CITY : ALIEN_DAMAGE_TO_CITY;
+ cityInstance.takeDamage(damageToCity);
+ obj.destroySelf(); // Object is destroyed upon hitting the city (it can also flash/explode)
+ // No need to splice here, the `obj.isDestroyed` check handles it next frame or after tween
+ continue;
+ }
+ // Check if object fell past the bottom of the screen (e.g., if city was already destroyed)
+ if (obj.y - obj.graphic.height / 2 > WORLD_HEIGHT) {
+ obj.destroySelf(); // Or just silently remove
+ // No need to splice here, obj.isDestroyed handles it
+ continue;
+ }
+ }
+ // Safety check: if playerHoldingTarget got destroyed but interval didn't clear
+ if (isPlayerHolding && playerHoldingTarget && playerHoldingTarget.isDestroyed) {
+ isPlayerHolding = false;
+ playerHoldingTarget = null;
+ if (holdDamageInterval) {
+ LK.clearInterval(holdDamageInterval);
+ holdDamageInterval = null;
+ }
+ }
+};
\ No newline at end of file
Метеорит без огня пастельные цвета In-Game asset. 2d. High contrast. No shadows
Похожий
Иконка повышение урона, сочные цвета. In-Game asset. 2d. High contrast. No shadows. Comix
иконка на скорость атаки
надпись upgrade как красивая кнопка In-Game asset. 2d. High contrast. No shadows. comix
центральный круг желтый а внешний оранжевый
голубой вместо оранжевого
Красно оранжевый
Restyled
Разрешение 2048 на 400
молния должна быть с двух концов одинаковая и ответвления смотреть строго вверх и вниз а не наискосок
иконка шанса двойного урона (x2)
иконка голубой молнии без текста и цыферблата
иконка огня
Вместо молнии синяя снежинка, все остальное без изменений
сделать светлее
Комикс
сделать рамку толще в два раза и немного не правильной формы как в комиксах
сделать рамку тоньше сохранив стиль и цвета сочнее
надпись shop как красивая кнопка In-Game asset. 2d. High contrast. No shadows. comix
Рамка для всплывающей меню подсказки. In-Game asset. 2d. High contrast. No shadows
Крестик для закрытия окна. In-Game asset. 2d. High contrast. No shadows
Иконка английского языка флаг без текста In-Game asset. 2d. High contrast. No shadows
Заменить на российский без текста, рамку сохранить
Удалить желтый фон
Флаг земенить на немецкий рамки сохранить
Заменить на испанский, сохранить рамку.
сделать точно такуюже рамку но надпись заменить на shop. звезду заменить на ракету, а стрелку на щит
все оставить как есть но удалить черноту за рамками
круглая иконка подсказки I. In-Game asset. 2d. High contrast. No shadows
убери все звезды оставь только чистое небо
иконка восстановление здоровья много зеленых крестов в рамке, сочные цвета красивый фон. In-Game asset. 2d. High contrast. No shadows
синий щит на ярко оранжевом фоне
залп ракетного огня
шаровая молния. In-Game asset. 2d. High contrast. No shadows
башня тесла с молниями фон голубой
Огненный шар
перекрасить больше желтого и оранжевого
перекрасить больше голубого, светло-голубого,
турецкий флаг
Вместо огненного кольца, огненные шары разлетающие вверх в разные стороны
Текст убрать. Вместо молний снежинки
Вместо молнии снежинка, и покрасить в синий
Льдинка как стеклышко. In-Game asset. 2d. High contrast. No shadows
убрать дырку
бесформенная амеба
удали крывлья оставь только жука
оставь только крылья, удали жука
перекрась
Shoot
Sound effect
Boom
Sound effect
Pokupka
Sound effect
menu
Sound effect
molnia
Sound effect
krit
Sound effect
icetresk
Sound effect
peretik
Sound effect
music1
Music
music2
Music
music3
Music
musicFight
Music
udarshield
Sound effect
startraket
Sound effect
raketaudar
Sound effect
Ognemet
Sound effect
Tresklda
Sound effect
stop
Sound effect
goldsound
Sound effect
alien_bum
Sound effect