User prompt
top potaya kadar zıplasın
User prompt
üstte pota olsun file
User prompt
top ekranın yukarısına kadar zıplasın dahada yukarıya kadar ve hareketi daha yavaş olsun
User prompt
yavaş zıplasın top ve yere inerken yer çekimi yavaş olsun ve baya yukarı zıplasın
User prompt
topumuz yukarıya yani yeşil yere zıplasın
Initial prompt
BASKET PLAY
/****
* Classes
****/
//<Assets used in the game will automatically appear here>
//<Write imports for supported plugins here>
// Define a Ball class for the basketball
var Ball = Container.expand(function () {
var self = Container.call(this);
var ballGraphics = self.attachAsset('ball', {
anchorX: 0.5,
anchorY: 0.5
});
self.speedX = 0;
self.speedY = 0;
self.update = function () {
self.x += self.speedX;
self.y += self.speedY;
self.speedY += 0.5; // Gravity effect
};
});
// Define a Hoop class for the basketball hoop
var Hoop = Container.expand(function () {
var self = Container.call(this);
var hoopGraphics = self.attachAsset('hoop', {
anchorX: 0.5,
anchorY: 0.5
});
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000 //Init game with black background
});
/****
* Game Code
****/
// Initialize game elements
var ball = new Ball();
ball.x = 1024; // Center horizontally
ball.y = 2400; // Near the bottom of the screen
game.addChild(ball);
var hoop = new Hoop();
hoop.x = 1024; // Center horizontally
hoop.y = 500; // Near the top of the screen
game.addChild(hoop);
var score = 0;
var scoreTxt = new Text2('Score: 0', {
size: 100,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
var isDragging = false;
var startX, startY;
// Handle touch/mouse down event
game.down = function (x, y, obj) {
if (ball.intersects(obj)) {
isDragging = true;
startX = x;
startY = y;
}
};
// Handle touch/mouse move event
game.move = function (x, y, obj) {
if (isDragging) {
ball.x = x;
ball.y = y;
}
};
// Handle touch/mouse up event
game.up = function (x, y, obj) {
if (isDragging) {
isDragging = false;
ball.speedX = (x - startX) / 10;
ball.speedY = (y - startY) / 10;
}
};
// Update game logic
game.update = function () {
ball.update();
// Check if the ball intersects with the hoop
if (ball.intersects(hoop)) {
score += 1;
scoreTxt.setText('Score: ' + score);
ball.x = 1024;
ball.y = 2400;
ball.speedX = 0;
ball.speedY = 0;
}
// Reset ball if it goes off screen
if (ball.y > 2732) {
ball.x = 1024;
ball.y = 2400;
ball.speedX = 0;
ball.speedY = 0;
}
};