Code edit (22 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: setTimeout is not a function' in or related to this line: 'setTimeout(function () {' Line Number: 123
User prompt
when the ball is thrown, make the character hop a little bit vertically
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (2 edits merged)
Please save this source code
User prompt
move character to the bottom left of the screen
User prompt
create character on screen
User prompt
move character to the top layer
User prompt
Please fix the bug: 'Uncaught Error: The supplied index is out of bounds' in or related to this line: 'game.setChildIndex(character, game.children.length);' Line Number: 91
User prompt
bring it to the utmost upper layer
User prompt
put character on the upper layer and move it to the bottom left of the screen
Code edit (1 edits merged)
Please save this source code
Code edit (20 edits merged)
Please save this source code
User prompt
move character to the bottom left of the playspace
User prompt
obstacle01 & touchdown alpha = 1
Code edit (1 edits merged)
Please save this source code
Code edit (10 edits merged)
Please save this source code
User prompt
create and show var character on screen
User prompt
show var character on screen
User prompt
var Character should be positionned at the bottom left of the screen
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'speedY')' in or related to this line: 'self.speedY += self.gravity;' Line Number: 65
User prompt
draw the character on screen and position it at the bottom left of the playspace
User prompt
obstacle01 & touchdown alpha = 0
Code edit (1 edits merged)
Please save this source code
/****
* Classes
****/
// Assets will be automatically generated based on usage in the code.
var Basketball = Container.expand(function () {
var self = Container.call(this);
self.ballGraphics = self.attachAsset('basketball', {
anchorX: 0.5,
anchorY: 0.5
});
self.speedY = 0;
self.gravity = 0.5;
self.isThrown = false;
self.scored = false; // Add a flag to track if the ball has scored
self["throw"] = function (power, angle, horizontalSpeed) {
self.speedY = -power / 2;
self.speedX = horizontalSpeed;
self.isThrown = true;
self.scored = false; // Reset the scored flag when the ball is thrown
};
self.update = function () {
if (self.isThrown) {
self.y += self.speedY;
self.x += self.speedX;
self.speedY += self.gravity;
self.ballGraphics.rotation -= 0.1;
}
};
});
var Hoop = Container.expand(function () {
var self = Container.call(this);
var hoopGraphics = self.attachAsset('hoop', {
anchorX: 0.5,
anchorY: 0.5
});
self.moveSpeed = 2;
self.update = function () {
self.x = touchdown.x;
self.y = touchdown.y;
};
self.parent = touchdown;
});
var Obstacle01 = Container.expand(function () {
var self = Container.call(this);
self.obstacleGraphics = self.attachAsset('Obstacle01', {
anchorX: 0.8,
anchorY: -0.75
});
self.parent = touchdown;
});
var Touchdown = Container.expand(function () {
var self = Container.call(this);
var touchdownGraphics = self.attachAsset('Touchdown', {
anchorX: 1.2,
anchorY: 0.1
});
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87CEEB // Light blue background to simulate sky
});
/****
* Game Code
****/
var basketball = game.addChild(new Basketball());
var hoop = game.addChild(new Hoop());
basketball.x = 300;
basketball.y = 2732 - 300; // Start near the bottom
hoop.x = 2048 / 2;
hoop.y = 2732 / 4; // Position the hoop in the upper part of the screen
var score = 0;
var scoreTxt = new Text2(score.toString(), {
size: 150,
fill: "#ffffff"
});
LK.gui.top.addChild(scoreTxt);
var touchdown = new Touchdown();
var obstacle01 = game.addChild(new Obstacle01());
obstacle01.x = 2048 / 2;
obstacle01.y = 2732 / 2;
touchdown.x = 2048 / 2;
touchdown.y = 2732 / 2;
game.addChild(touchdown);
game.on('down', function (obj) {
if (!basketball.isThrown) {
var event = obj.event;
var pos = event.getLocalPosition(game);
// Calculate the arc between the ball and the hoop
var dx = hoop.x - basketball.x;
var dy = hoop.y - basketball.y;
var distance = Math.sqrt(dx * dx + dy * dy);
var angle = Math.atan2(dy, dx) / 2; // Reduce the angle of the throw
var power = (2732 - pos.y) / 30;
var horizontalSpeed = Math.abs(basketball.x - pos.x) / 100; // Calculate the horizontal speed based on the distance from the click to the basketball
basketball["throw"](power, angle, horizontalSpeed);
}
});
LK.on('tick', function () {
game.setChildIndex(basketball, game.children.length - 1);
basketball.update();
hoop.update();
// Check for scoring
if (basketball.intersects(touchdown) && !basketball.scored) {
score += 3;
scoreTxt.setText(score.toString());
basketball.scored = true; // Set the scored flag to true
// Move basketball down slowly
basketball.speedY = 2;
basketball.speedX = 0;
basketball.gravity = 0;
// Fade out the ball progressively until it disappears
var fadeOutInterval = LK.setInterval(function () {
basketball.ballGraphics.alpha -= 0.05;
if (basketball.ballGraphics.alpha <= 0) {
LK.clearInterval(fadeOutInterval);
basketball.destroy();
basketball = game.addChild(new Basketball());
basketball.x = 300;
basketball.y = 2732 - 300;
basketball.isThrown = false;
basketball.ballGraphics.rotation = 0;
basketball.ballGraphics.alpha = 1.0;
}
}, 100);
// Stop the ball from moving down after 2 seconds
LK.setTimeout(function () {
basketball.speedY = 0;
}, 2000);
// Respawn touchdown
touchdown = new Touchdown();
touchdown.x = 2048 / 2;
touchdown.y = 2732 / 2;
game.addChild(touchdown);
}
// Reset basketball if it goes off-screen
if (basketball.y > 2732) {
basketball.x = 300;
basketball.y = 2732 - 300;
basketball.isThrown = false;
// Reset basketball rotation
basketball.ballGraphics.rotation = 0;
}
// Check for collision with Obstacle01 only if the basketball has not scored
if (!basketball.scored && basketball.intersects(obstacle01)) {
// Bounce the basketball in the opposite direction
basketball.speedY = -basketball.speedY;
basketball.speedX = -basketball.speedX;
}
});
2d basketball in the art style of final fantasy 9. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
2d basketball hoop net in the art style of final fantasy 9 , just the ring and the net. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Create a cartoon-style illustration of a back alley. The goal is to capture a lively and playful location. No skies.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Create a cartoon-style illustration of clouds. The goal is to capture a lively and playful location... Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Create a cartoon-style illustration of a yarn ball. The goal is to capture a lively and playful location. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Create a cartoon-style illustration of a Cat. The goal is to capture a lively and playful location. 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.
Create a cartoon-style illustration of the word ''Bonus''. The goal is to capture a lively and playful text. The letter "O" in Bonus should be a basketball. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
cartoon sideways claw swipe effect just the scratches in orange. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.