User prompt
с течением времени игра должна усложняться
User prompt
houses спавнятся чаще
User prompt
с течением времени игра должна усложняться (время ускоряется, динамика предметов увеличивается
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'forEach')' in this line: 'meteorites.forEach(function (meteorite) {' Line Number: 67
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'forEach')' in this line: 'meteorites.forEach(function (meteorite) {' Line Number: 67
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'forEach')' in this line: 'meteorites.forEach(function (meteorite) {' Line Number: 67
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'forEach')' in this line: 'meteorites.forEach(function (meteorite) {' Line Number: 67
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'forEach')' in this line: 'meteorites.forEach(function (meteorite) {' Line Number: 67
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'forEach')' in this line: 'meteorites.forEach(function (meteorite) {' Line Number: 67
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'forEach')' in this line: 'meteorites.forEach(function (meteorite) {' Line Number: 67
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'forEach')' in this line: 'meteorites.forEach(function (meteorite) {' Line Number: 67
User prompt
метеорит взрывается и исчезает через 15 секунд после прыжка героя
User prompt
герой может вылетать за пределы экрана появляясь на другой строне экрана , это работает только справа и слева
User prompt
ускорь темп игры на 30%
User prompt
увеличь скорость полета и вращения метеорита на 30%
User prompt
главный герой космонавт
User prompt
герой всегда повернул головой в направлении полета
User prompt
герой летит головой вперед
User prompt
герой всегда смотрит в направлении полета
User prompt
герой летит в сторону клика мышкой
User prompt
управление работает в полете
User prompt
героем можно управлять, его толкает в противоположную сторону от клика мышкой
User prompt
героя толкает реактивная тяга
User prompt
постепенно увеличивай скорость врщения
User prompt
темп игры постепенно возрастает
/**** * Classes ****/ var Debris = Container.expand(function () { var self = Container.call(this); var debrisGraphics = self.createAsset('debris', 'Debris graphics', 0.5, 0.5); self.speed = Math.random() * 5 + 2; self.direction = { x: Math.random() * 2 - 1, y: Math.random() * 2 - 1 }; self.move = function () { self.x += self.direction.x * self.speed; self.y += self.direction.y * self.speed; self.speed *= 0.98; // Debris slows down over time if (self.speed < 0.5) { self.destroy(); // Destroy debris when it's slow enough } }; }); var Meteorite = Container.expand(function () { var self = Container.call(this); var meteoriteGraphics = self.createAsset('meteorite', 'Meteorite graphics', 0.5, 0.5); self.speed = Math.random() * 3 + 1; self.direction = { x: Math.random() * 2 - 1, y: Math.random() * 2 - 1 }; self.move = function () { self.x += self.direction.x * self.speed; self.y += self.direction.y * self.speed; }; }); var Star = Container.expand(function () { var self = Container.call(this); var starGraphics = self.createAsset('star', 'Star graphics', 0.5, 0.5); self.speed = Math.random() * 5 + 1; self.move = function () { self.y += self.speed; if (self.y > 2732) { self.y = -self.height; self.x = Math.random() * 2048; self.speed = Math.random() * 5 + 1; } }; }); var Astronaut = Container.expand(function () { var self = Container.call(this); var astronautGraphics = self.createAsset('astronaut', 'Astronaut character', .5, .5); self.speed = 10; self.jump = function () { if (!this.hasJumped) { this.direction = { x: Math.sin(self.rotation), y: -Math.cos(self.rotation) }; this.hasJumped = true; this.firstJump = true; } }; self.hasJumped = false; self.firstJump = false; self.score = 0; self.lastHouse = null; self.scoreTxt = new Text2('0', { size: 150, fill: "#ffffff", weight: 800, dropShadow: true, dropShadowColor: '#000000', dropShadowBlur: 4, dropShadowAngle: Math.PI / 6, dropShadowDistance: 6 }); self.scoreTxt.anchor.set(.5, 0); LK.gui.topCenter.addChild(self.scoreTxt); self.move = function (houses) { if (self.hasJumped) { self.x += self.direction.x * self.speed; self.y += self.direction.y * self.speed; for (var i = 0; i < houses.length; i++) { var dx = self.x - houses[i].x; var dy = self.y - houses[i].y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance < astronautGraphics.width / 2 + houses[i].width / 2 && houses[i] !== self.lastHouse) { self.hasJumped = false; self.lastHouse = houses[i]; self.currentHouse = houses[i]; self.rotationOffset = Math.atan2(dy, dx) - houses[i].rotation; self.score += 1; self.scoreTxt.setText(self.score); if (!houses[i].bomb) { houses[i].bomb = new Bomb(); houses[i].addChild(houses[i].bomb); houses[i].bomb.startTimer(); } break; } } } if (!self.hasJumped && self.currentHouse) { var angle = self.currentHouse.rotation + self.rotationOffset; self.x = self.currentHouse.x + Math.cos(angle) * (self.currentHouse.width / 2 + astronautGraphics.height / 2); self.y = self.currentHouse.y + Math.sin(angle) * (self.currentHouse.width / 2 + astronautGraphics.height / 2); self.rotation = angle + Math.PI / 2; } }; }); var House = Container.expand(function () { var self = Container.call(this); var randomHouseIndex = Math.floor(Math.random() * houseAssets.length); var houseGraphics = self.createAsset(houseAssets[randomHouseIndex], 'House object', .5, .5); self.rotationStep = Math.random() * 0.02 - 0.01; if (self.rotationStep > 0 && self.rotationStep < 0.01) { self.rotationStep = 0.01; } if (self.rotationStep < 0 && self.rotationStep > -0.01) { self.rotationStep = -0.01; } }); var Bomb = Container.expand(function () { var self = Container.call(this); var bombGraphics = self.createAsset('bomb', 'Bomb graphics', 0.5, 0.5); self.timer = null; self.explode = function () { // Explosion effect can be added here var meteorites = self.parent.children.filter(function (child) { return child instanceof Meteorite && self.intersects(child); }); meteorites.forEach(function (meteorite) { for (var i = 0; i < 5; i++) { // Create 5 debris particles var debris = new Debris(); debris.x = meteorite.x; debris.y = meteorite.y; self.parent.addChild(debris); } meteorite.destroy(); // Destroy the meteorite }); // self.destroy(); // Do not destroy the bomb after explosion }; self.startTimer = function () { self.timer = LK.setTimeout(self.explode, 15000); }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ var gameContainer = new Container(); game.addChild(gameContainer); var stars = []; game.spawnStar = function () { var newStar = new Star(); newStar.x = Math.random() * 2048; newStar.y = Math.random() * 2732; gameContainer.addChildAt(newStar, gameContainer.children.length > 1 ? 1 : 0); }; for (var i = 0; i < 50; i++) { game.spawnStar(); } var houseAssets = ['house1', 'house2', 'house3', 'house4', 'house5', 'house6', 'house7', 'house8', 'house9', 'house10']; var background = game.createAsset('background', 'Background image', .5, .5); background.x = 2048 / 2; background.y = 2732 / 2; background.speed = 2; background.move = function () { this.y += this.speed; if (this.y >= 2732) { this.y = 0; } }; game.addChildAt(background, 0); game.setBackgroundColor(0x000000); var gameContainer = new Container(); game.addChild(gameContainer); var astronaut = gameContainer.addChild(new Astronaut()); astronaut.x = 2048 / 2; astronaut.y = 2732 - 300; var houses = []; var houseSpeed = -2; game.spawnHouse = function () { var newHouse = new House(); newHouse.rotation = Math.random() * Math.PI * 2; newHouse.scale.set(Math.random() * 0.5 + 0.5); if (houses.length === 0) { newHouse.x = 2048 / 2; newHouse.y = 2732 / 2; } else { var lastHouseY = houses[houses.length - 1].y; var gameHeightThird = 2732 / 3; newHouse.y = lastHouseY - (Math.random() * gameHeightThird + gameHeightThird); newHouse.x = Math.random() * (2048 - 600) + 300; } houses.push(newHouse); gameContainer.addChildAt(newHouse, 0); }; game.spawnStar = function () { var newStar = new Star(); newStar.x = Math.random() * 2048; newStar.y = Math.random() * 2732; gameContainer.addChildAt(newStar, 1); }; var isGameOver = false; for (var i = 0; i < 8; i++) { game.spawnHouse(); } game.on('down', function (obj) { astronaut.jump(); }); var tickOffset = 0; LK.on('tick', function () { if (isGameOver) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); } else { background.move(); astronaut.move(houses); for (var s = 0; s < gameContainer.children.length; s++) { if (gameContainer.children[s] instanceof Star) { gameContainer.children[s].move(); } } } for (var a = houses.length - 1; a >= 0; a--) { if (astronaut.firstJump) { houses[a].y -= houseSpeed; } houses[a].rotation += houses[a].rotationStep; if (houses[a].x < -50 || houses[a].y > 2732 + houses[a].height) { houses[a].destroy(); houses.splice(a, 1); game.spawnHouse(); } } var astronautScreenX = astronaut.x; var astronautScreenY = astronaut.y + gameContainer.y; if ((astronautScreenX < 0 || astronautScreenX > 2048 || astronautScreenY < 0) && astronaut.hasJumped || astronaut.y > 2732) { isGameOver = true; } });
===================================================================
--- original.js
+++ change.js
@@ -20,19 +20,16 @@
});
var Meteorite = Container.expand(function () {
var self = Container.call(this);
var meteoriteGraphics = self.createAsset('meteorite', 'Meteorite graphics', 0.5, 0.5);
- self.baseSpeed = Math.random() * 5 + 3;
- self.speedIncrease = 0.05;
+ self.speed = Math.random() * 3 + 1;
self.direction = {
x: Math.random() * 2 - 1,
y: Math.random() * 2 - 1
};
self.move = function () {
- self.x += self.direction.x * self.baseSpeed;
- self.y += self.direction.y * self.baseSpeed;
- self.baseSpeed += self.speedIncrease;
- self.speedIncrease += 0.001; // Gradually increase the speed increment to make the game harder over time
+ self.x += self.direction.x * self.speed;
+ self.y += self.direction.y * self.speed;
};
});
var Star = Container.expand(function () {
var self = Container.call(this);
@@ -46,26 +43,20 @@
self.speed = Math.random() * 5 + 1;
}
};
});
-var Santa = Container.expand(function () {
+var Astronaut = Container.expand(function () {
var self = Container.call(this);
- var santaGraphics = self.createAsset('santa', 'Santa character', .5, .5);
+ var astronautGraphics = self.createAsset('astronaut', 'Astronaut character', .5, .5);
self.speed = 10;
- self.jump = function (clickPosition) {
- var dx = clickPosition.x - self.x;
- var dy = clickPosition.y - self.y;
- var angle = Math.atan2(dy, dx);
- this.direction = {
- x: Math.cos(angle),
- y: Math.sin(angle)
- };
+ self.jump = function () {
if (!this.hasJumped) {
- this.reactiveThrust = 15; // Initial reactive thrust value
+ this.direction = {
+ x: Math.sin(self.rotation),
+ y: -Math.cos(self.rotation)
+ };
this.hasJumped = true;
this.firstJump = true;
- } else {
- this.reactiveThrust = 10; // Adjust thrust value for mid-air control
}
};
self.hasJumped = false;
self.firstJump = false;
@@ -84,21 +75,15 @@
self.scoreTxt.anchor.set(.5, 0);
LK.gui.topCenter.addChild(self.scoreTxt);
self.move = function (houses) {
if (self.hasJumped) {
- if (self.reactiveThrust > 0) {
- self.x += self.direction.x * (self.speed + self.reactiveThrust);
- self.y += self.direction.y * (self.speed + self.reactiveThrust);
- self.reactiveThrust *= 0.9; // Decrease thrust over time
- } else {
- self.x += self.direction.x * self.speed;
- self.y += self.direction.y * self.speed;
- }
+ self.x += self.direction.x * self.speed;
+ self.y += self.direction.y * self.speed;
for (var i = 0; i < houses.length; i++) {
var dx = self.x - houses[i].x;
var dy = self.y - houses[i].y;
var distance = Math.sqrt(dx * dx + dy * dy);
- if (distance < santaGraphics.width / 2 + houses[i].width / 2 && houses[i] !== self.lastHouse) {
+ if (distance < astronautGraphics.width / 2 + houses[i].width / 2 && houses[i] !== self.lastHouse) {
self.hasJumped = false;
self.lastHouse = houses[i];
self.currentHouse = houses[i];
self.rotationOffset = Math.atan2(dy, dx) - houses[i].rotation;
@@ -114,27 +99,25 @@
}
}
if (!self.hasJumped && self.currentHouse) {
var angle = self.currentHouse.rotation + self.rotationOffset;
- self.x = self.currentHouse.x + Math.cos(angle) * (self.currentHouse.width / 2 + santaGraphics.height / 2);
- self.y = self.currentHouse.y + Math.sin(angle) * (self.currentHouse.width / 2 + santaGraphics.height / 2);
- self.rotation = Math.atan2(self.direction.y, self.direction.x);
+ self.x = self.currentHouse.x + Math.cos(angle) * (self.currentHouse.width / 2 + astronautGraphics.height / 2);
+ self.y = self.currentHouse.y + Math.sin(angle) * (self.currentHouse.width / 2 + astronautGraphics.height / 2);
+ self.rotation = angle + Math.PI / 2;
}
};
});
var House = Container.expand(function () {
var self = Container.call(this);
var randomHouseIndex = Math.floor(Math.random() * houseAssets.length);
var houseGraphics = self.createAsset(houseAssets[randomHouseIndex], 'House object', .5, .5);
- self.rotationSpeed = Math.random() * 0.02 - 0.01;
- self.rotationAcceleration = 0.0001;
- self.updateRotation = function () {
- self.rotation += self.rotationSpeed;
- self.rotationSpeed += self.rotationAcceleration;
- if (Math.abs(self.rotationSpeed) > 0.05) {
- self.rotationAcceleration = 0; // Stop increasing speed after a certain point
- }
- };
+ self.rotationStep = Math.random() * 0.02 - 0.01;
+ if (self.rotationStep > 0 && self.rotationStep < 0.01) {
+ self.rotationStep = 0.01;
+ }
+ if (self.rotationStep < 0 && self.rotationStep > -0.01) {
+ self.rotationStep = -0.01;
+ }
});
var Bomb = Container.expand(function () {
var self = Container.call(this);
var bombGraphics = self.createAsset('bomb', 'Bomb graphics', 0.5, 0.5);
@@ -197,11 +180,11 @@
game.addChildAt(background, 0);
game.setBackgroundColor(0x000000);
var gameContainer = new Container();
game.addChild(gameContainer);
-var santa = gameContainer.addChild(new Santa());
-santa.x = 2048 / 2;
-santa.y = 2732 - 300;
+var astronaut = gameContainer.addChild(new Astronaut());
+astronaut.x = 2048 / 2;
+astronaut.y = 2732 - 300;
var houses = [];
var houseSpeed = -2;
game.spawnHouse = function () {
var newHouse = new House();
@@ -229,40 +212,37 @@
for (var i = 0; i < 8; i++) {
game.spawnHouse();
}
game.on('down', function (obj) {
- var clickPosition = obj.event.getLocalPosition(game);
- santa.jump(clickPosition);
+ astronaut.jump();
});
var tickOffset = 0;
LK.on('tick', function () {
if (isGameOver) {
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
} else {
background.move();
- background.speed += 0.001; // Gradually increase the background speed to match the game's difficulty
- santa.move(houses);
+ astronaut.move(houses);
for (var s = 0; s < gameContainer.children.length; s++) {
if (gameContainer.children[s] instanceof Star) {
gameContainer.children[s].move();
}
}
}
for (var a = houses.length - 1; a >= 0; a--) {
- if (santa.firstJump) {
+ if (astronaut.firstJump) {
houses[a].y -= houseSpeed;
- houseSpeed -= 0.001; // Gradually increase the house speed to make the game harder over time
}
- houses[a].updateRotation();
+ houses[a].rotation += houses[a].rotationStep;
if (houses[a].x < -50 || houses[a].y > 2732 + houses[a].height) {
houses[a].destroy();
houses.splice(a, 1);
game.spawnHouse();
}
}
- var santaScreenX = santa.x;
- var santaScreenY = santa.y + gameContainer.y;
- if ((santaScreenX < 0 || santaScreenX > 2048 || santaScreenY < 0) && santa.hasJumped || santa.y > 2732) {
+ var astronautScreenX = astronaut.x;
+ var astronautScreenY = astronaut.y + gameContainer.y;
+ if ((astronautScreenX < 0 || astronautScreenX > 2048 || astronautScreenY < 0) && astronaut.hasJumped || astronaut.y > 2732) {
isGameOver = true;
}
});
\ No newline at end of file
космонавт. 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.