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,5 +1,10 @@
/****
+* Plugins
+****/
+var tween = LK.import("@upit/tween.v1");
+
+/****
* Classes
****/
// test
var ButtonBot = Container.expand(function () {
@@ -20,43 +25,35 @@
self.scale.set(0.9); // Add press effect by scaling down
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;
+ tween(player, {
+ y: 2732 / 2 - 250
+ }, {
+ duration: 100,
+ onFinish: function onFinish() {
player.inAir = false;
player.doubleJump = false;
- LK.clearInterval(jumpInterval);
- } else {
- player.y = player.y - 200 * progress;
+ player.y = 2732 / 2 - 250;
}
- }, 16);
+ });
}
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
}
- var moveDuration = 100;
- var moveStartTime = Date.now();
- var moveInterval = LK.setInterval(function () {
- var elapsed = Date.now() - moveStartTime;
- var progress = elapsed / moveDuration;
- if (progress >= 1) {
- player.y = 2732 / 2 - 250;
+ tween(player, {
+ y: 2732 / 2 - 250
+ }, {
+ duration: 100,
+ onFinish: function onFinish() {
player.inAir = false;
player.doubleJump = false;
+ player.y = 2732 / 2 - 250;
player.hasRotated = false; // Reset rotation flag
- LK.clearInterval(moveInterval);
- } else {
- player.y = player.y - (player.y - (2732 / 2 - 250)) * progress;
}
- }, 16);
+ });
} else {
player.hasRotated = false; // Reset rotation flag if not in air or double jump
}
};
@@ -90,70 +87,53 @@
self.scale.set(0.9); // Add press effect by scaling down
if (!player.doubleJump || player.inAir && !player.doubleJump) {
if (player.inAir) {
player.doubleJump = true;
- var doubleJumpDuration = 100; // Reduced duration for lower double jump height
- 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 - 300;
- player.rotation -= Math.PI * 2;
- player.inAir = true;
- LK.clearInterval(doubleJumpInterval);
- var fallDuration = 400; // Reduced duration for quicker fall
- 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;
+ tween(player, {
+ y: player.y - 400,
+ rotation: player.rotation - Math.PI * 2
+ }, {
+ duration: 230,
+ easing: tween.easeInOut,
+ onFinish: function onFinish() {
+ player.inAir = true; // Allow another jump
+ tween(player, {
+ y: 2732 / 2 - 250
+ }, {
+ duration: 800,
+ onFinish: function onFinish() {
player.inAir = false;
player.doubleJump = false;
- LK.clearInterval(fallInterval);
- } else {
- player.y = player.y - 200 * (1 - fallProgress);
+ player.y = 2732 / 2 - 250;
}
- }, 16);
- } else {
- player.y = player.y - 300 * progress;
+ });
}
- }, 16);
+ });
return;
}
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 = 50; // Reduced duration for lower jump height
- 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 - 300;
- player.inAir = true;
- LK.clearInterval(initialJumpInterval);
- var fallDuration = 400; // Reduced duration for quicker fall after double jump
- 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;
+ tween(player, {
+ y: player.y - 400
+ }, {
+ duration: 100,
+ // Reduced duration to allow quicker second jump
+ onFinish: function onFinish() {
+ player.inAir = true; // Allow another jump
+ tween(player, {
+ y: 2732 / 2 - 250
+ }, {
+ duration: 800,
+ onFinish: function onFinish() {
player.inAir = false;
- LK.clearInterval(fallInterval);
- } else {
- player.y = player.y - 200 * (1 - fallProgress);
}
- }, 16);
- } else {
- player.y = player.y - 300 * progress;
+ });
}
- }, 16);
+ });
}
};
// Add up event to reset scale
self.up = function (x, y, obj) {
@@ -174,14 +154,8 @@
self.hasRotated = false; // Initialize rotation flag
// Initialize lastY and lastX for tracking changes
self.lastY = self.y;
self.lastX = self.x;
- // Add boundary check to prevent player from moving off the top of the screen
- self.update = function () {
- if (self.y < 0) {
- self.y = 0; // Prevent moving off the top
- }
- };
});
/****
* Initialize Game
@@ -440,19 +414,15 @@
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
-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);
+tween(domImage, {
+ alpha: 0.2
+}, {
+ duration: 1000,
+ yoyo: true,
+ repeat: Infinity
+});
// Add image 'niz' to the bottom of the screen
var niz = game.addChild(LK.getAsset('NIZ', {
anchorX: 0.5,
// Center horizontally
@@ -536,21 +506,18 @@
}));
ball.x = ball.width / 2 - 100; // Shift ball 100 pixels to the left
ball.y = 2732 / 2 - 300; // Center ball vertically
LK.setTimeout(function () {
- var moveDuration = 360;
- var moveStartTime = Date.now();
- var moveInterval = LK.setInterval(function () {
- var elapsed = Date.now() - moveStartTime;
- var progress = elapsed / moveDuration;
- if (progress >= 1) {
- ball.x += 400;
- ball.destroy(); // Remove the ball after it moves 400 pixels
- LK.clearInterval(moveInterval);
- } else {
- ball.x += 400 * progress;
+ tween(ball, {
+ x: ball.x + 400
+ }, {
+ duration: 360,
+ // Reduced duration to double the speed
+ easing: tween.linear,
+ onFinish: function onFinish() {
+ ball.destroy(); // Remove the ball after it moves 200 pixels
}
- }, 16);
+ });
}, 1500);
game.down = function (x, y, obj) {};
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
@@ -632,10 +599,14 @@
game.children.forEach(function (child) {
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)) && player.intersects(child)) {
- LK.setScore(LK.getScore() + 1); // Increment score
- scoreText.setText(LK.getScore().toString()); // Update score display
+ if (child.assetId === 'Prep1') {
+ LK.showGameOver(); // Trigger game over if player intersects with Prep1
+ } else {
+ 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;
создать мультяшного сидячего персонажа. 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