User prompt
topu yonlendirmek zor gibi daha iyi yap
User prompt
1 kere deliğe girdikten sonra top yavaşliyo
User prompt
topu bizim hareket ettireceğimiz cubuğa yaklaşirken hizlandirinca içinden geçiyo bug oldu sanirim düzelt
User prompt
topu hizlandirip birakinca bazen yon değiştiriyor bug oldu sanirim düzelt
User prompt
bu sol tuşa hizlanma durumu sadece topa basinca olmasin ekranin her yerinde olsun ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
sol tarafa top değince hizlanmasin lütfen sadece oyun dursun ve ekrana kaybettin yazsin ve ekranda tekrar başla butonu olsun
User prompt
sol tıka bastığımda top bastiğim süre boyunca 3 kat hizlansin ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
daha hizli
User prompt
topun şuan hizini arttirir misin çok yavaş
User prompt
top 4 kat daha hizli olsun
User prompt
top sol kenara değerse oyunu kaybedelim
User prompt
top sola değerse yanalim top 4 kat daha hizli olsun delik yuvarlak değil duvarla en olarak ayni olsun dikdortgen olsun ↪💡 Consider importing and using the following plugins: @upit/tween.v1
Code edit (1 edits merged)
Please save this source code
User prompt
Wall Pong Challenge
Initial prompt
bir pong oyunu istiyorum ama rakip yerine sağ tarafta kocaman bir duvar olsun ve ufak bir delik olsun her deliğe topu attiğimizda deliğin yeri değişsin ve puan artsin
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Ball = Container.expand(function () {
var self = Container.call(this);
var ballGraphics = self.attachAsset('ball', {
anchorX: 0.5,
anchorY: 0.5
});
self.velocityX = 8;
self.velocityY = 4;
self.baseSpeed = 8;
self.reset = function () {
self.x = 200;
self.y = 2732 / 2;
self.velocityX = self.baseSpeed;
self.velocityY = (Math.random() - 0.5) * 6;
};
self.update = function () {
self.x += self.velocityX;
self.y += self.velocityY;
// Bounce off top and bottom walls
if (self.y <= 15 || self.y >= 2732 - 15) {
self.velocityY = -self.velocityY;
LK.getSound('bounce').play();
}
// Bounce off left wall
if (self.x <= 15) {
self.velocityX = Math.abs(self.velocityX);
LK.getSound('bounce').play();
}
// Check paddle collision
if (self.intersects(paddle) && self.velocityX < 0) {
self.velocityX = -self.velocityX;
// Add some angle based on where it hits the paddle
var paddleCenter = paddle.y;
var ballCenter = self.y;
var diff = ballCenter - paddleCenter;
self.velocityY += diff * 0.05;
LK.getSound('bounce').play();
}
// Reset if ball goes off right side
if (self.x > 2048 + 50) {
self.reset();
}
};
return self;
});
var Paddle = Container.expand(function () {
var self = Container.call(this);
var paddleGraphics = self.attachAsset('paddle', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 12;
self.targetY = 2732 / 2;
self.update = function () {
var diff = self.targetY - self.y;
if (Math.abs(diff) > 2) {
self.y += diff * 0.15;
}
};
return self;
});
var Wall = Container.expand(function () {
var self = Container.call(this);
var wallGraphics = self.attachAsset('wall', {
anchorX: 0,
anchorY: 0
});
var holeGraphics = self.attachAsset('hole', {
anchorX: 0.5,
anchorY: 0.5
});
self.holeY = 2732 / 2;
holeGraphics.y = self.holeY;
self.moveHole = function () {
var minY = 100;
var maxY = 2732 - 100;
self.holeY = minY + Math.random() * (maxY - minY);
tween(holeGraphics, {
y: self.holeY
}, {
duration: 500,
easing: tween.easeOut
});
};
self.checkBallThrough = function (ball) {
var holeX = self.x;
var holeY = self.holeY;
var ballX = ball.x;
var ballY = ball.y;
// Check if ball is in the hole area
var distance = Math.sqrt((ballX - holeX) * (ballX - holeX) + (ballY - holeY) * (ballY - holeY));
return distance < 45 && ballX > holeX - 20 && ballX < holeX + 60;
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x001122
});
/****
* Game Code
****/
var paddle = game.addChild(new Paddle());
paddle.x = 100;
paddle.y = 2732 / 2;
var ball = game.addChild(new Ball());
ball.reset();
var wall = game.addChild(new Wall());
wall.x = 2048 - 40;
wall.y = 0;
var scoreTxt = new Text2('0', {
size: 100,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
scoreTxt.y = 50;
var lastBallX = ball.x;
var ballThroughHole = false;
game.move = function (x, y, obj) {
paddle.targetY = y;
};
game.down = function (x, y, obj) {
paddle.targetY = y;
};
game.update = function () {
// Track ball movement for hole detection
var currentBallX = ball.x;
// Check if ball passed through hole
if (!ballThroughHole && lastBallX < wall.x && currentBallX >= wall.x) {
if (wall.checkBallThrough(ball)) {
// Score!
ballThroughHole = true;
LK.setScore(LK.getScore() + 1);
scoreTxt.setText(LK.getScore());
LK.getSound('score').play();
// Move hole to new position
wall.moveHole();
// Increase ball speed slightly
ball.baseSpeed += 0.5;
if (ball.velocityX > 0) {
ball.velocityX = ball.baseSpeed;
} else {
ball.velocityX = -ball.baseSpeed;
}
} else {
// Ball hit the wall, bounce back
ball.velocityX = -ball.velocityX;
LK.getSound('bounce').play();
}
}
// Reset ball through hole flag when ball moves away
if (currentBallX < wall.x - 100) {
ballThroughHole = false;
}
lastBallX = currentBallX;
}; ===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,169 @@
-/****
+/****
+* Plugins
+****/
+var tween = LK.import("@upit/tween.v1");
+
+/****
+* Classes
+****/
+var Ball = Container.expand(function () {
+ var self = Container.call(this);
+ var ballGraphics = self.attachAsset('ball', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.velocityX = 8;
+ self.velocityY = 4;
+ self.baseSpeed = 8;
+ self.reset = function () {
+ self.x = 200;
+ self.y = 2732 / 2;
+ self.velocityX = self.baseSpeed;
+ self.velocityY = (Math.random() - 0.5) * 6;
+ };
+ self.update = function () {
+ self.x += self.velocityX;
+ self.y += self.velocityY;
+ // Bounce off top and bottom walls
+ if (self.y <= 15 || self.y >= 2732 - 15) {
+ self.velocityY = -self.velocityY;
+ LK.getSound('bounce').play();
+ }
+ // Bounce off left wall
+ if (self.x <= 15) {
+ self.velocityX = Math.abs(self.velocityX);
+ LK.getSound('bounce').play();
+ }
+ // Check paddle collision
+ if (self.intersects(paddle) && self.velocityX < 0) {
+ self.velocityX = -self.velocityX;
+ // Add some angle based on where it hits the paddle
+ var paddleCenter = paddle.y;
+ var ballCenter = self.y;
+ var diff = ballCenter - paddleCenter;
+ self.velocityY += diff * 0.05;
+ LK.getSound('bounce').play();
+ }
+ // Reset if ball goes off right side
+ if (self.x > 2048 + 50) {
+ self.reset();
+ }
+ };
+ return self;
+});
+var Paddle = Container.expand(function () {
+ var self = Container.call(this);
+ var paddleGraphics = self.attachAsset('paddle', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.speed = 12;
+ self.targetY = 2732 / 2;
+ self.update = function () {
+ var diff = self.targetY - self.y;
+ if (Math.abs(diff) > 2) {
+ self.y += diff * 0.15;
+ }
+ };
+ return self;
+});
+var Wall = Container.expand(function () {
+ var self = Container.call(this);
+ var wallGraphics = self.attachAsset('wall', {
+ anchorX: 0,
+ anchorY: 0
+ });
+ var holeGraphics = self.attachAsset('hole', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.holeY = 2732 / 2;
+ holeGraphics.y = self.holeY;
+ self.moveHole = function () {
+ var minY = 100;
+ var maxY = 2732 - 100;
+ self.holeY = minY + Math.random() * (maxY - minY);
+ tween(holeGraphics, {
+ y: self.holeY
+ }, {
+ duration: 500,
+ easing: tween.easeOut
+ });
+ };
+ self.checkBallThrough = function (ball) {
+ var holeX = self.x;
+ var holeY = self.holeY;
+ var ballX = ball.x;
+ var ballY = ball.y;
+ // Check if ball is in the hole area
+ var distance = Math.sqrt((ballX - holeX) * (ballX - holeX) + (ballY - holeY) * (ballY - holeY));
+ return distance < 45 && ballX > holeX - 20 && ballX < holeX + 60;
+ };
+ return self;
+});
+
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000
-});
\ No newline at end of file
+ backgroundColor: 0x001122
+});
+
+/****
+* Game Code
+****/
+var paddle = game.addChild(new Paddle());
+paddle.x = 100;
+paddle.y = 2732 / 2;
+var ball = game.addChild(new Ball());
+ball.reset();
+var wall = game.addChild(new Wall());
+wall.x = 2048 - 40;
+wall.y = 0;
+var scoreTxt = new Text2('0', {
+ size: 100,
+ fill: 0xFFFFFF
+});
+scoreTxt.anchor.set(0.5, 0);
+LK.gui.top.addChild(scoreTxt);
+scoreTxt.y = 50;
+var lastBallX = ball.x;
+var ballThroughHole = false;
+game.move = function (x, y, obj) {
+ paddle.targetY = y;
+};
+game.down = function (x, y, obj) {
+ paddle.targetY = y;
+};
+game.update = function () {
+ // Track ball movement for hole detection
+ var currentBallX = ball.x;
+ // Check if ball passed through hole
+ if (!ballThroughHole && lastBallX < wall.x && currentBallX >= wall.x) {
+ if (wall.checkBallThrough(ball)) {
+ // Score!
+ ballThroughHole = true;
+ LK.setScore(LK.getScore() + 1);
+ scoreTxt.setText(LK.getScore());
+ LK.getSound('score').play();
+ // Move hole to new position
+ wall.moveHole();
+ // Increase ball speed slightly
+ ball.baseSpeed += 0.5;
+ if (ball.velocityX > 0) {
+ ball.velocityX = ball.baseSpeed;
+ } else {
+ ball.velocityX = -ball.baseSpeed;
+ }
+ } else {
+ // Ball hit the wall, bounce back
+ ball.velocityX = -ball.velocityX;
+ LK.getSound('bounce').play();
+ }
+ }
+ // Reset ball through hole flag when ball moves away
+ if (currentBallX < wall.x - 100) {
+ ballThroughHole = false;
+ }
+ lastBallX = currentBallX;
+};
\ No newline at end of file