User prompt
Если игрок пересек объект prep или pref, то game over
User prompt
Если игрок пересек объекты prep и prepf, то game over
Code edit (1 edits merged)
Please save this source code
User prompt
Если игрок пересекается с prep1 gameover
User prompt
как изменить высоту прыжка, сейчас по X улетает высоко, нужно ниже
User prompt
как изменить высоту прыжка, сейчас по X улетает высоко, нужно ниже
User prompt
исправь это
User prompt
уменьшить высоту прыжка
User prompt
Уменьшить высоту прыжка
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'tween(player, {' Line Number: 78 ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Please fix the bug: 'Timeout.tick error: Can't find variable: tween' in or related to this line: 'tween(ball, {' Line Number: 564 ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Сделай свои рекомендации
User prompt
Проверять пересечения child и prep
User prompt
Проверять столкновения в радиусе объекта character и prep
User prompt
При столкновении characterи prep game over
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'if (!player.inAir && !player.doubleJump) {' Line Number: 98
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'if (!player.inAir && !player.doubleJump) {' Line Number: 60
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'if (!player.doubleJump || player.inAir && !player.doubleJump) {' Line Number: 122
User prompt
Please fix the bug: 'Timeout.tick error: Can't find variable: player' in or related to this line: 'game.setChildIndex(player, game.children.length - 1); // Move player to the top' Line Number: 376
User prompt
Please fix the bug: 'Timeout.tick error: Can't find variable: player' in or related to this line: 'game.setChildIndex(player, game.children.length - 1); // Move player to the top' Line Number: 376
User prompt
Сделать объект character основным игроком, с которым в будущем будем сравнивать столкновения с другими объектами
User prompt
Усложни игру еще
User prompt
Усложни игру
User prompt
Сделать проверку на столкновения объекта character и prep
User prompt
Сделать проверку на столкновения объекта character и prep
===================================================================
--- original.js
+++ change.js
@@ -1,10 +1,5 @@
/****
-* Plugins
-****/
-var tween = LK.import("@upit/tween.v1");
-
-/****
* Classes
****/
// test
var ButtonBot = Container.expand(function () {
@@ -22,50 +17,54 @@
LK.setTimeout(function () {
self.isPressed = false; // Reset pressed state after a short delay
}, 200); // 200ms debounce delay
self.scale.set(0.9); // Add press effect by scaling down
- if (!character.inAir && !character.doubleJump) {
- character.rotation -= Math.PI / 2.25; // Rotate 80 degrees counter-clockwise
- } else if (character.inAir || character.doubleJump) {
- tween(character, {
- y: 2732 / 2 - 250
- }, {
- duration: 100,
- onFinish: function onFinish() {
- character.inAir = false;
- character.doubleJump = false;
- character.y = 2732 / 2 - 250;
+ if (!player.inAir && !player.doubleJump) {
+ player.rotation -= Math.PI / 2.25; // Rotate 80 degrees counter-clockwise
+ } else if (player.inAir || player.doubleJump) {
+ var jumpDuration = 100;
+ var jumpStartTime = Date.now();
+ var jumpInterval = LK.setInterval(function () {
+ var elapsed = Date.now() - jumpStartTime;
+ var progress = elapsed / jumpDuration;
+ if (progress >= 1) {
+ player.y = 2732 / 2 - 250;
+ player.inAir = false;
+ player.doubleJump = false;
+ LK.clearInterval(jumpInterval);
+ } else {
+ player.y = player.y - 400 * progress;
}
- });
+ }, 16);
}
- if (character.inAir || character.doubleJump) {
- if (!character.hasRotated) {
- character.rotation -= Math.PI / 2.25; // Rotate 80 degrees counter-clockwise
- character.hasRotated = true; // Ensure rotation only occurs once
+ if (player.inAir || player.doubleJump) {
+ if (!player.hasRotated) {
+ player.rotation -= Math.PI / 2.25; // Rotate 80 degrees counter-clockwise
+ player.hasRotated = true; // Ensure rotation only occurs once
}
- tween(character, {
+ tween(player, {
y: 2732 / 2 - 250
}, {
duration: 100,
onFinish: function onFinish() {
- character.inAir = false;
- character.doubleJump = false;
- character.y = 2732 / 2 - 250;
- character.hasRotated = false; // Reset rotation flag
+ player.inAir = false;
+ player.doubleJump = false;
+ player.y = 2732 / 2 - 250;
+ player.hasRotated = false; // Reset rotation flag
}
});
} else {
- character.hasRotated = false; // Reset rotation flag if not in air or double jump
+ player.hasRotated = false; // Reset rotation flag if not in air or double jump
}
};
// Add up event to reset rotation
self.up = function (x, y, obj) {
self.isPressed = false; // Reset pressed state
self.scale.set(1); // Reset scale to original size
- if (!character.inAir && !character.doubleJump) {
- character.rotation += Math.PI / 2.25; // Rotate back 80 degrees clockwise
- } else if (character.inAir || character.doubleJump) {
- character.rotation += Math.PI / 2.25; // Rotate back 80 degrees clockwise
+ if (!player.inAir && !player.doubleJump) {
+ player.rotation += Math.PI / 2.25; // Rotate back 80 degrees clockwise
+ } else if (player.inAir || player.doubleJump) {
+ player.rotation += Math.PI / 2.25; // Rotate back 80 degrees clockwise
}
};
});
// Create a button top class
@@ -84,56 +83,73 @@
LK.setTimeout(function () {
self.isPressed = false; // Reset pressed state after a short delay
}, 200); // 200ms debounce delay
self.scale.set(0.9); // Add press effect by scaling down
- if (!character.doubleJump || character.inAir && !character.doubleJump) {
- if (character.inAir) {
- character.doubleJump = true;
- tween(character, {
- y: character.y - 400,
- rotation: character.rotation - Math.PI * 2
- }, {
- duration: 230,
- easing: tween.easeInOut,
- onFinish: function onFinish() {
- character.inAir = true; // Allow another jump
- tween(character, {
- y: 2732 / 2 - 250
- }, {
- duration: 800,
- onFinish: function onFinish() {
- character.inAir = false;
- character.doubleJump = false;
- character.y = 2732 / 2 - 250;
+ if (!player.doubleJump || player.inAir && !player.doubleJump) {
+ if (player.inAir) {
+ player.doubleJump = true;
+ var doubleJumpDuration = 230;
+ var doubleJumpStartTime = Date.now();
+ var doubleJumpInterval = LK.setInterval(function () {
+ var elapsed = Date.now() - doubleJumpStartTime;
+ var progress = elapsed / doubleJumpDuration;
+ if (progress >= 1) {
+ player.y = player.y - 400;
+ player.rotation -= Math.PI * 2;
+ player.inAir = true;
+ LK.clearInterval(doubleJumpInterval);
+ var fallDuration = 800;
+ var fallStartTime = Date.now();
+ var fallInterval = LK.setInterval(function () {
+ var fallElapsed = Date.now() - fallStartTime;
+ var fallProgress = fallElapsed / fallDuration;
+ if (fallProgress >= 1) {
+ player.y = 2732 / 2 - 250;
+ player.inAir = false;
+ player.doubleJump = false;
+ LK.clearInterval(fallInterval);
+ } else {
+ player.y = player.y - 400 * (1 - fallProgress);
}
- });
+ }, 16);
+ } else {
+ player.y = player.y - 400 * progress;
}
- });
+ }, 16);
return;
}
- character.inAir = true;
- character.doubleJump = false;
- character.lastY = character.y; // Update lastY immediately after jump initiation
- character.lastX = character.x; // Update lastX immediately after jump initiation
- character.lastY = character.y; // Update lastY immediately after jump initiation
- character.lastX = character.x; // Update lastX immediately after jump initiation
- tween(character, {
- y: character.y - 400
- }, {
- duration: 100,
- // Reduced duration to allow quicker second jump
- onFinish: function onFinish() {
- character.inAir = true; // Allow another jump
- tween(character, {
- y: 2732 / 2 - 250
- }, {
- duration: 800,
- onFinish: function onFinish() {
- character.inAir = false;
+ player.inAir = true;
+ player.doubleJump = false;
+ player.lastY = player.y; // Update lastY immediately after jump initiation
+ player.lastX = player.x; // Update lastX immediately after jump initiation
+ player.lastY = player.y; // Update lastY immediately after jump initiation
+ player.lastX = player.x; // Update lastX immediately after jump initiation
+ var initialJumpDuration = 100;
+ var initialJumpStartTime = Date.now();
+ var initialJumpInterval = LK.setInterval(function () {
+ var elapsed = Date.now() - initialJumpStartTime;
+ var progress = elapsed / initialJumpDuration;
+ if (progress >= 1) {
+ player.y = player.y - 400;
+ player.inAir = true;
+ LK.clearInterval(initialJumpInterval);
+ var fallDuration = 800;
+ var fallStartTime = Date.now();
+ var fallInterval = LK.setInterval(function () {
+ var fallElapsed = Date.now() - fallStartTime;
+ var fallProgress = fallElapsed / fallDuration;
+ if (fallProgress >= 1) {
+ player.y = 2732 / 2 - 250;
+ player.inAir = false;
+ LK.clearInterval(fallInterval);
+ } else {
+ player.y = player.y - 400 * (1 - fallProgress);
}
- });
+ }, 16);
+ } else {
+ player.y = player.y - 400 * progress;
}
- });
+ }, 16);
}
};
// Add up event to reset scale
self.up = function (x, y, obj) {
@@ -338,9 +354,9 @@
anchorY: 0.5
}));
vzriv.x = vzriv.width / 2 + 90; // Position Vzriv at the left center of the screen
vzriv.y = 2732 / 2 - 280; // Center Vzriv vertically
- game.setChildIndex(character, game.children.length - 1); // Move character to the top
+ game.setChildIndex(player, game.children.length - 1); // Move player to the top
game.setChildIndex(buttonBot, game.children.length - 1); // Ensure buttonBot is on top
game.setChildIndex(buttonTop, game.children.length - 1); // Ensure buttonTop is on top
// Remove Vzriv 2.1 seconds after the game starts
LK.setTimeout(function () {
@@ -414,15 +430,19 @@
domImage.rotation = Math.PI / 9; // Rotate image by 20 degrees clockwise
domImage.alpha = 0.2; // Set transparency to 50%
domImage.blendMode = BLEND_MODES.NORMAL; // Ensure transparency does not sum up
// Add a glow effect to the 'Dom' image
-tween(domImage, {
- alpha: 0.2
-}, {
- duration: 1000,
- yoyo: true,
- repeat: Infinity
-});
+var glowDuration = 1000;
+var glowDirection = 1;
+var glowStartTime = Date.now();
+var glowInterval = LK.setInterval(function () {
+ var elapsed = Date.now() - glowStartTime;
+ var progress = elapsed % glowDuration / glowDuration;
+ if (progress >= 1) {
+ glowDirection *= -1;
+ }
+ domImage.alpha = 0.2 + 0.8 * progress * glowDirection;
+}, 16);
// Add image 'niz' to the bottom of the screen
var niz = game.addChild(LK.getAsset('NIZ', {
anchorX: 0.5,
// Center horizontally
@@ -518,12 +538,12 @@
}
});
}, 1500);
game.down = function (x, y, obj) {};
-var character = game.addChild(new Player());
-character.x = character.width / 2 + 200; // Position character 200 units to the right of the center left of the screen
-character.y = 2732 / 2 - 250; // Move character 150 units down
-character.rotation = Math.PI / 12; // Set initial rotation to 15 degrees clockwise
+var player = game.addChild(new Player());
+player.x = player.width / 2 + 200; // Position player 200 units to the right of the center left of the screen
+player.y = 2732 / 2 - 250; // Move player 150 units down
+player.rotation = Math.PI / 12; // Set initial rotation to 15 degrees clockwise
// Add background to the game
var background = game.addChild(LK.getAsset('background_1', {
anchorX: 0.5,
anchorY: 0.5
@@ -592,17 +612,17 @@
return;
}
buttonTop.interactive = true;
buttonBot.interactive = true;
- // Update lastY and lastX for character
- character.lastY = character.y;
- character.lastX = character.x;
+ // Update lastY and lastX for player
+ player.lastY = player.y;
+ player.lastX = player.x;
game.children.forEach(function (child) {
- if (child !== character && child !== buttonTop && child !== buttonBot && child !== uskorenie) {
+ if (child !== player && child !== buttonTop && child !== buttonBot && child !== uskorenie) {
// Check for intersection with prep or prepf objects
- if ((prepImages.includes(child.assetId) || prepFImages.includes(child.assetId)) && character.intersects(child)) {
- LK.effects.flashScreen(0xff0000, 1000); // Flash screen red for 1 second
- LK.showGameOver(); // Trigger game over
+ if ((prepImages.includes(child.assetId) || prepFImages.includes(child.assetId)) && player.intersects(child)) {
+ LK.setScore(LK.getScore() + 1); // Increment score
+ scoreText.setText(LK.getScore().toString()); // Update score display
}
if (child === domImage) {
if (child.lastX === undefined) {
child.lastX = child.x;
@@ -630,21 +650,21 @@
// If the image is completely off the screen
child.destroy(); // Remove the image
}
}
- game.setChildIndex(character, game.children.length - 1); // Move character to the top
+ game.setChildIndex(player, game.children.length - 1); // Move player to the top
game.setChildIndex(buttonBot, game.children.length - 1); // Ensure buttonBot is on top
game.setChildIndex(buttonTop, game.children.length - 1); // Ensure buttonTop is on top
});
- // Add shaking effect to the character
+ // Add shaking effect to the player
if (gameStarted) {
if (LK.ticks < 130) {
// Strong shake for the first second (assuming 60 FPS)
- character.x = character.lastX + Math.sin(LK.ticks / 0.5) * 10;
- character.y = character.lastY + Math.cos(LK.ticks / 0.5) * 10;
+ player.x = player.lastX + Math.sin(LK.ticks / 0.5) * 10;
+ player.y = player.lastY + Math.cos(LK.ticks / 0.5) * 10;
} else {
- character.x = character.lastX + Math.sin(LK.ticks / 0.5) * 3;
- character.y = character.lastY + Math.cos(LK.ticks / 0.5) * 3;
+ player.x = player.lastX + Math.sin(LK.ticks / 0.5) * 3;
+ player.y = player.lastY + Math.cos(LK.ticks / 0.5) * 3;
}
if (vzriv && vzriv.parent) {
vzriv.destroy();
}
создать мультяшного сидячего персонажа. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
snowball. 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
Скелет дракона. Мультяшный. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Ufo (летающая тарелка). Мультяшная. 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
Человек летит на параплане. Мультяшный. 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
Рука белая. Иконка. 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
text: New Record! Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows