User prompt
Сделай пулю меньше ещё в 2 раза
User prompt
Сделай пулю меньше в 2.5 раза
User prompt
Сделай кнопку стрельбы больше в 5 раз и ещё добавь перезарядку которая длится 0.3 секунды прежде чем игрок вновь сможет выстрелить
User prompt
Добавь круглую кнопку в правый Нижний угол при клике игрок будет выпускать пулю которая убивает врагов
User prompt
Fix Bug: 'ReferenceError: bullets is not defined' in this line: 'for (var b = bullets.length - 1; b >= 0; b--) {' Line Number: 135
User prompt
Fix Bug: 'ReferenceError: bullets is not defined' in this line: 'for (var b = bullets.length - 1; b >= 0; b--) {' Line Number: 135
User prompt
Сделай чтобы игрок стрелял одной пулей при тапе, и чтобы пуля убивала врагов
User prompt
Добавь платформы
User prompt
Добавь партиклы к следам игрока
User prompt
Сделай игру чуть быстрее
User prompt
Сделай падение игрока при свайпе вниз быстрее в 10 раз
User prompt
Сделай падение игрока при свайпе вниз быстрее в 6 раз
User prompt
Сделай падение игрока при свайпе вниз быстрее на 2.5
User prompt
Сделай падение игрока при свайпе быстрее на 2.5
User prompt
Прибавь скорость к падению когда пользователь делает свайп вниз
User prompt
Ещё чуть быстрее
User prompt
Сделай так чтобы когда пользователь делал свайп вниз то чтобы игрок быстро падал
User prompt
А теперь сделай так чтобы когда пользователь делает свайп вниз то чтобы игрок мгновенно падал
User prompt
А теперь сделай так чтобы если пользователь делает два свайпа верх то чтоб игрок сделал двойной прыжок, но не более
User prompt
Убери функцию прижка при теперь, и сделай так чтобы игрок прыгал когда пользователь делает свайп в верх
User prompt
А теперь сделай так, чтобы когда пользователь делал свайп в верх то чтобы игрок прыгал
User prompt
Добавь игроку способность чтобы он быстро приземлился если пользователь делает свайп вниз
User prompt
Сделай так, чтобы если игрок касается к противнику слово или с правой стороны то чтобы игрок проигрывал, а если игрок пригает на противника сверху то чтобы враг умирал и исчезла
User prompt
Добавь чу-чуть силу приказ
Initial prompt
Run Belyash Run
/****
* Classes
****/
// Hero class
var Hero = Container.expand(function () {
var self = Container.call(this);
var heroGraphics = self.createAsset('hero', 'Hero character', 0.5, 0.5);
self.speed = 9;
self.jumpPower = -18;
self.gravity = 0.5;
self.isJumping = false;
self.velocityY = 0;
self.update = function () {
// Apply gravity
if (self.isJumping || self.isFalling) {
self.velocityY += self.gravity;
self.y += self.velocityY;
if (self.y > game.height - heroGraphics.height / 2) {
self.isJumping = false;
self.isFalling = false;
self.jumpCount = 0;
self.y = game.height - heroGraphics.height / 2;
}
}
self.isFalling = false;
};
self.jumpCount = 0;
self.maxJumps = 2;
self.isFalling = false;
self.jump = function () {
if (self.jumpCount < self.maxJumps) {
self.jumpCount++;
self.isJumping = true;
self.velocityY = self.jumpPower;
}
};
self.fallQuickly = function () {
self.isFalling = true;
self.velocityY = self.gravity * 50;
};
});
// Obstacle class
var Obstacle = Container.expand(function () {
var self = Container.call(this);
var obstacleGraphics = self.createAsset('obstacle', 'Obstacle', 0.5, 1);
self.speed = -10;
self.move = function () {
self.x += self.speed;
};
});
// Bullet class
var Bullet = Container.expand(function () {
var self = Container.call(this);
var bulletGraphics = self.createAsset('bullet', 'Hero Bullet', 0.5, 0.5);
self.speed = 15;
self.move = function () {
self.x += self.speed;
};
self.checkCollisionWithObstacles = function (obstacles) {
for (var i = obstacles.length - 1; i >= 0; i--) {
if (self.intersects(obstacles[i])) {
obstacles[i].destroy();
obstacles.splice(i, 1);
self.destroy();
return true;
}
}
return false;
};
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000 // Init game with black background
});
/****
* Game Code
****/
// Initialize hero
var hero = game.addChild(new Hero());
hero.x = game.width / 4;
hero.y = game.height - hero.height / 2;
// Initialize obstacles array
var obstacles = [];
// Initialize score
var score = 0;
var scoreTxt = new Text2(score.toString(), {
size: 150,
fill: "#ffffff"
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
// Game tick event
LK.on('tick', function () {
// Update hero
hero.update();
// Move and check obstacles
for (var i = obstacles.length - 1; i >= 0; i--) {
obstacles[i].move();
// Check for collision with hero
if (hero.intersects(obstacles[i])) {
// Check if hero jumps on top of the obstacle
if (hero.y + hero.height / 2 <= obstacles[i].y - obstacles[i].height / 2 && hero.velocityY > 0) {
// Remove the obstacle if jumped on top
obstacles[i].destroy();
obstacles.splice(i, 1);
} else {
// Game over if collided from the side
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
return;
}
}
// Remove off-screen obstacles
if (obstacles[i].x < -obstacles[i].width) {
obstacles[i].destroy();
obstacles.splice(i, 1);
}
}
// Increment score
score++;
scoreTxt.setText(score.toString());
// Move and check bullets
for (var b = bullets.length - 1; b >= 0; b--) {
bullets[b].move();
if (bullets[b].checkCollisionWithObstacles(obstacles)) {
bullets.splice(b, 1);
} else if (bullets[b].x > game.width) {
bullets[b].destroy();
bullets.splice(b, 1);
}
}
// Add new obstacles
if (LK.ticks % 100 == 0) {
var obstacle = new Obstacle();
obstacle.x = game.width;
obstacle.y = game.height;
obstacles.push(obstacle);
game.addChild(obstacle);
}
});
// Prepare for swipe detection
var swipeStart = null;
var swipeThreshold = 50; // Minimum distance for a swipe to count
// Touch start event to record the start position of a swipe
game.on('down', function (obj) {
var event = obj.event;
swipeStart = event.getLocalPosition(game);
});
// Touch end event to detect a swipe
game.on('up', function (obj) {
var event = obj.event;
var swipeEnd = event.getLocalPosition(game);
if (swipeStart) {
if (Math.abs(swipeEnd.y - swipeStart.y) > swipeThreshold) {
if (swipeStart.y > swipeEnd.y) {
hero.jump();
} else if (swipeStart.y < swipeEnd.y) {
hero.fallQuickly();
}
}
} else {
// Shoot a bullet when the player taps
var bullet = new Bullet();
bullet.x = hero.x + hero.width / 2;
bullet.y = hero.y;
bullets.push(bullet);
game.addChild(bullet);
}
swipeStart = null; // Reset swipe start position
}); ===================================================================
--- original.js
+++ change.js
@@ -47,16 +47,27 @@
self.move = function () {
self.x += self.speed;
};
});
-// Platform class
-var Platform = Container.expand(function () {
+// Bullet class
+var Bullet = Container.expand(function () {
var self = Container.call(this);
- var platformGraphics = self.createAsset('platform', 'Platform', 0.5, 1);
- self.speed = -10;
+ var bulletGraphics = self.createAsset('bullet', 'Hero Bullet', 0.5, 0.5);
+ self.speed = 15;
self.move = function () {
self.x += self.speed;
};
+ self.checkCollisionWithObstacles = function (obstacles) {
+ for (var i = obstacles.length - 1; i >= 0; i--) {
+ if (self.intersects(obstacles[i])) {
+ obstacles[i].destroy();
+ obstacles.splice(i, 1);
+ self.destroy();
+ return true;
+ }
+ }
+ return false;
+ };
});
/****
* Initialize Game
@@ -94,18 +105,15 @@
for (var i = obstacles.length - 1; i >= 0; i--) {
obstacles[i].move();
// Check for collision with hero
if (hero.intersects(obstacles[i])) {
- // Check if hero lands on top of the platform
- if (hero.y + hero.height / 2 <= obstacles[i].y && hero.velocityY > 0) {
- // Land the hero on the platform
- hero.isJumping = false;
- hero.isFalling = false;
- hero.jumpCount = 0;
- hero.y = obstacles[i].y - hero.height / 2;
- hero.velocityY = 0;
- } else if (hero.x + hero.width / 2 > obstacles[i].x && hero.velocityY >= 0) {
- // Game over if collided from the side while falling or not jumping
+ // Check if hero jumps on top of the obstacle
+ if (hero.y + hero.height / 2 <= obstacles[i].y - obstacles[i].height / 2 && hero.velocityY > 0) {
+ // Remove the obstacle if jumped on top
+ obstacles[i].destroy();
+ obstacles.splice(i, 1);
+ } else {
+ // Game over if collided from the side
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
return;
}
@@ -120,15 +128,25 @@
// Increment score
score++;
scoreTxt.setText(score.toString());
+ // Move and check bullets
+ for (var b = bullets.length - 1; b >= 0; b--) {
+ bullets[b].move();
+ if (bullets[b].checkCollisionWithObstacles(obstacles)) {
+ bullets.splice(b, 1);
+ } else if (bullets[b].x > game.width) {
+ bullets[b].destroy();
+ bullets.splice(b, 1);
+ }
+ }
// Add new obstacles
if (LK.ticks % 100 == 0) {
- var platform = new Platform();
- platform.x = game.width;
- platform.y = game.height - platform.height / 2;
- obstacles.push(platform);
- game.addChild(platform);
+ var obstacle = new Obstacle();
+ obstacle.x = game.width;
+ obstacle.y = game.height;
+ obstacles.push(obstacle);
+ game.addChild(obstacle);
}
});
// Prepare for swipe detection
@@ -152,7 +170,14 @@
} else if (swipeStart.y < swipeEnd.y) {
hero.fallQuickly();
}
}
+ } else {
+ // Shoot a bullet when the player taps
+ var bullet = new Bullet();
+ bullet.x = hero.x + hero.width / 2;
+ bullet.y = hero.y;
+ bullets.push(bullet);
+ game.addChild(bullet);
}
swipeStart = null; // Reset swipe start position
});
\ No newline at end of file