User prompt
Decrease velocity from bounce by 5x
User prompt
Add 20 degrees to the boot rotation always
User prompt
Make sure velocityX exists on ball
Code edit (4 edits merged)
Please save this source code
User prompt
Ball does not seem to bounce away from the boot in the x direction, fix this
Code edit (1 edits merged)
Please save this source code
User prompt
When calculating new velocity, subtract the current ball velocity rather than adding it
User prompt
In bounce reverse the impact of ball velocity
Code edit (1 edits merged)
Please save this source code
User prompt
When bouncing also factor in the balls current speed
User prompt
Set the devisor of rotation impact from 5 to 2
User prompt
Only use velocityY for boot rotation calculation
Code edit (2 edits merged)
Please save this source code
User prompt
Smoot the boot rotation
User prompt
reverse rotation impact
User prompt
Decrease the rotation impact by 5
User prompt
also call calculateVelocity in tick
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
User prompt
Make boot rotate based on boot yspeed
User prompt
Move up the location where ball spawns by 1/4 the hight of the screen
User prompt
Don't bounce ball on floor
Code edit (1 edits merged)
Please save this source code
User prompt
Decrease bounce impact with 10x
User prompt
Make ball loose momentum when bouncing on walls
var Boot = Container.expand(function () { var self = Container.call(this); var bootGraphics = self.createAsset('boot', 'Boot', .5, .5); self.velocityX = 0; self.velocityY = 0; self.previousX = 0; self.previousY = 0; self.calculateVelocity = function () { self.velocityX = self.x - self.previousX; self.velocityY = self.y - self.previousY; self.previousX = self.x; self.previousY = self.y; }; }); var Ball = Container.expand(function () { var self = Container.call(this); var ballGraphics = self.createAsset('ball', 'Soccer Ball', .5, .5); self.velocityY = 0; self.gravity = 0.5; self.bounceFactor = 0.7; self.move = function () { self.x += self.velocityX; self.y += self.velocityY; self.velocityY += self.gravity; if (self.x - self.width / 2 < 0) { self.velocityX *= -0.7; self.x = self.width / 2; } if (self.x + self.width / 2 > 2048) { self.velocityX *= -0.7; self.x = 2048 - self.width / 2; } }; self.bounce = function (boot) { var dx = self.x - boot.x; var dy = self.y - boot.y; var distance = Math.sqrt(dx * dx + dy * dy); var normalX = dx / distance; var normalY = dy / distance; var dotProduct = -normalX * boot.velocityX - normalY * boot.velocityY; self.velocityX = -2 * dotProduct * normalX + boot.velocityX; self.velocityY = -2 * dotProduct * normalY + boot.velocityY; var overlap = boot.width / 2 + self.width / 2 - distance; if (overlap > 0) { self.x += overlap * normalX; self.y += overlap * normalY; } }; }); var Game = Container.expand(function () { var self = Container.call(this); stage.on('move', function (obj) { var pos = obj.event.getLocalPosition(self); boot.x = pos.x; boot.y = pos.y; boot.calculateVelocity(); }); var ball = self.addChild(new Ball()); ball.x = 2048 / 2; ball.y = 2732 / 4; var boot = self.addChild(new Boot()); boot.visible = true; var scoreTxt = new Text2('0', { size: 150, fill: "#ffffff" }); scoreTxt.anchor.set(.5, 0); LK.gui.topCenter.addChild(scoreTxt); var isGameOver = false; var isGameStarted = false; stage.on('down', function (obj) { var pos = obj.event.getLocalPosition(self); boot.x = pos.x; boot.y = pos.y; boot.visible = true; }); LK.on('tick', function () { if (!isGameStarted) { var dx = boot.x - ball.x; var dy = boot.y - ball.y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance < boot.width / 2 + ball.width / 2) { ball.bounce(boot); isGameStarted = true; } } else { ball.move(); var dx = boot.x - ball.x; var dy = boot.y - ball.y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance < boot.width / 2 + ball.width / 2) { ball.bounce(boot); } } if (ball.y > 2732 - ball.height / 2) { isGameOver = true; } if (isGameOver) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); } }); });
===================================================================
--- original.js
+++ change.js
@@ -56,9 +56,9 @@
boot.calculateVelocity();
});
var ball = self.addChild(new Ball());
ball.x = 2048 / 2;
- ball.y = 2732 / 2;
+ ball.y = 2732 / 4;
var boot = self.addChild(new Boot());
boot.visible = true;
var scoreTxt = new Text2('0', {
size: 150,
Soccer ball. Single Cartoon Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Round soccer boot, cartoon style Single Cartoon Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Cartoon football stadium Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.