/****
* Classes
****/
var Pota = Container.expand(function () {
var self = Container.call(this);
self.potaGraphics = self.attachAsset('pota', {
anchorX: 0.5,
anchorY: 0.5,
alpha: 0.5 // Make the pota semi-transparent to ensure visibility of the top
});
});
//<Assets used in the game will automatically appear here>
//<Write imports for supported plugins here>
var Top = Container.expand(function () {
var self = Container.call(this);
var topGraphics = self.attachAsset('top', {
anchorX: 0.5,
anchorY: 0.5
});
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000 //Init game with black background
});
/****
* Game Code
****/
// Removed the large blue square asset initialization
//{0.1}
var background = LK.getAsset('background', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2
});
game.addChild(background);
var top = new Top();
top.x = 2048 / 2;
top.y = 2732 / 2;
top.speedY = 0; // Initial vertical speed
top.gravity = 0.5; // Gravity effect
top.bounce = -0.7; // Bounce effect
game.addChild(top);
var pota = new Pota();
pota.x = 2048 / 2;
pota.y = 2732 / 4;
game.addChild(pota);
var igne = LK.getAsset('igne', {
anchorX: 0.5,
anchorY: 0.5,
x: pota.x,
y: pota.y - 150,
alpha: 0 // Make the 'igne' asset invisible
});
game.addChild(igne);
// Initialize score
var score = 0;
// Create a score display
var scoreTxt = new Text2('Score: 0', {
size: 150,
// Increased font size for better readability
fill: 0xFFFF00,
shadow: {
color: 0x000000,
blur: 10,
offsetX: 5,
offsetY: 5
} // Added shadow for better contrast
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
// Add event listeners for throwing the ball
game.down = function (x, y, obj) {
// Calculate the direction to throw the ball
var directionX = (x - top.x) * 0.1;
var directionY = (y - top.y) * 0.1;
// Set the ball's speed based on the direction
top.speedX = directionX;
top.speedY = directionY;
// Play 'gol' sound
LK.getSound('gol').play();
};
// Game update loop
game.update = function () {
// Update top's position
top.x += top.speedX;
top.speedY += top.gravity;
top.y += top.speedY;
// Check for collision with the left side of the screen
if (top.x - top.width / 2 < 0) {
top.x = top.width / 2;
top.speedX *= -1; // Reverse horizontal speed
}
// Check for collision with the right side of the screen
if (top.x + top.width / 2 > 2048) {
top.x = 2048 - top.width / 2;
top.speedX *= -1; // Reverse horizontal speed
}
// Check for collision with the top of the screen
if (top.y - top.height / 2 < 0) {
top.y = top.height / 2;
top.speedY *= top.bounce; // Reverse speed and apply bounce effect
}
// Check for collision with the bottom of the screen
if (top.y + top.height / 2 > 2732) {
top.y = 2732 - top.height / 2;
top.speedY = 0; // Stop the ball when it reaches the bottom
}
// Allow the top to pass through the pota without stopping
if (top.y - top.height / 2 < pota.y + pota.height / 2) {
// No action needed, the top can pass through
}
// Check if top touches the needle
if (top.intersects(igne) && top.speedY > 0) {
score += 1; // Increase score by 1
scoreTxt.setText('Score: ' + score); // Update score display
top.y = 2732 - top.height / 2; // Reset the ball's position to the bottom of the screen
top.speedY = 0; // Stop the ball's vertical movement
// Play 'alkos' sound
LK.getSound('alkos').play();
// Play applause sound
LK.getSound('applause').play();
}
}; /****
* Classes
****/
var Pota = Container.expand(function () {
var self = Container.call(this);
self.potaGraphics = self.attachAsset('pota', {
anchorX: 0.5,
anchorY: 0.5,
alpha: 0.5 // Make the pota semi-transparent to ensure visibility of the top
});
});
//<Assets used in the game will automatically appear here>
//<Write imports for supported plugins here>
var Top = Container.expand(function () {
var self = Container.call(this);
var topGraphics = self.attachAsset('top', {
anchorX: 0.5,
anchorY: 0.5
});
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000 //Init game with black background
});
/****
* Game Code
****/
// Removed the large blue square asset initialization
//{0.1}
var background = LK.getAsset('background', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2
});
game.addChild(background);
var top = new Top();
top.x = 2048 / 2;
top.y = 2732 / 2;
top.speedY = 0; // Initial vertical speed
top.gravity = 0.5; // Gravity effect
top.bounce = -0.7; // Bounce effect
game.addChild(top);
var pota = new Pota();
pota.x = 2048 / 2;
pota.y = 2732 / 4;
game.addChild(pota);
var igne = LK.getAsset('igne', {
anchorX: 0.5,
anchorY: 0.5,
x: pota.x,
y: pota.y - 150,
alpha: 0 // Make the 'igne' asset invisible
});
game.addChild(igne);
// Initialize score
var score = 0;
// Create a score display
var scoreTxt = new Text2('Score: 0', {
size: 150,
// Increased font size for better readability
fill: 0xFFFF00,
shadow: {
color: 0x000000,
blur: 10,
offsetX: 5,
offsetY: 5
} // Added shadow for better contrast
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
// Add event listeners for throwing the ball
game.down = function (x, y, obj) {
// Calculate the direction to throw the ball
var directionX = (x - top.x) * 0.1;
var directionY = (y - top.y) * 0.1;
// Set the ball's speed based on the direction
top.speedX = directionX;
top.speedY = directionY;
// Play 'gol' sound
LK.getSound('gol').play();
};
// Game update loop
game.update = function () {
// Update top's position
top.x += top.speedX;
top.speedY += top.gravity;
top.y += top.speedY;
// Check for collision with the left side of the screen
if (top.x - top.width / 2 < 0) {
top.x = top.width / 2;
top.speedX *= -1; // Reverse horizontal speed
}
// Check for collision with the right side of the screen
if (top.x + top.width / 2 > 2048) {
top.x = 2048 - top.width / 2;
top.speedX *= -1; // Reverse horizontal speed
}
// Check for collision with the top of the screen
if (top.y - top.height / 2 < 0) {
top.y = top.height / 2;
top.speedY *= top.bounce; // Reverse speed and apply bounce effect
}
// Check for collision with the bottom of the screen
if (top.y + top.height / 2 > 2732) {
top.y = 2732 - top.height / 2;
top.speedY = 0; // Stop the ball when it reaches the bottom
}
// Allow the top to pass through the pota without stopping
if (top.y - top.height / 2 < pota.y + pota.height / 2) {
// No action needed, the top can pass through
}
// Check if top touches the needle
if (top.intersects(igne) && top.speedY > 0) {
score += 1; // Increase score by 1
scoreTxt.setText('Score: ' + score); // Update score display
top.y = 2732 - top.height / 2; // Reset the ball's position to the bottom of the screen
top.speedY = 0; // Stop the ball's vertical movement
// Play 'alkos' sound
LK.getSound('alkos').play();
// Play applause sound
LK.getSound('applause').play();
}
};
turuncu bi top etrafında siyah dairesini taömlıyen basketboll topu. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
basketball hoop. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
basketball sahası. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
arka planı olmayan şefaf ruruncu bi kare. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.