Code edit (1 edits merged)
Please save this source code
User prompt
I don't see gifts falling; I thing activesGifts are not atteched to the GiftRain instance in the GiftRain class
Code edit (1 edits merged)
Please save this source code
User prompt
I don't see gifts falling; I thing it misses and "attachement" to GiftRain
Code edit (1 edits merged)
Please save this source code
User prompt
add logs in GifRain and RainDrop
Code edit (6 edits merged)
Please save this source code
User prompt
for GiftRain, use RainDrop instances in the giftPool. and call upsateAsset() with the generator index
User prompt
create a class RainDrop with a list of non visible assets generator_N (with N from 0 to maxGenerators) . in This class add a update asset function that takes an index as argument and make the index asset visible.
User prompt
GiftRain should not use 'generatorButton' asset but 'generator_X' asset depending on the bought generators
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'addChild')' in or related to this line: 'middlegroundContainer.addChild(giftRain);' Line Number: 863
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'addChild')' in or related to this line: 'middlegroundContainer.addChild(giftRain);' Line Number: 863
User prompt
create a new class GiftRain. It will be responsible of making a continuous animation of falling gifts. The gifts will start to fall when player buys a generator. The gifts will use the same asset as the generators buttons. The more generators bought the more gifts will spawn. Gifts spawn at random x between 100 and 1948. Gifts spawn at random y between -100 and -300. The class will use a pool of objects and re-use gifts with y > 3000
Code edit (1 edits merged)
Please save this source code
Code edit (4 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Uncaught ReferenceError: isAnimating is not defined' in or related to this line: 'if (!isAnimating && dragNode === rightBoard) {' Line Number: 530
Code edit (2 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Uncaught TypeError: requestAnimationFrame is not a function' in or related to this line: 'requestAnimationFrame(self.applyMomentum);' Line Number: 726
User prompt
Please fix the bug: 'Uncaught TypeError: requestAnimationFrame is not a function' in or related to this line: 'requestAnimationFrame(self.applyMomentum);' Line Number: 726
Code edit (2 edits merged)
Please save this source code
User prompt
the dragNode update should be hangled globally because currently it is not updated when up event occurs out of rightBoard or buttons
User prompt
buttons drag/swipe isn't coherent when user touches only the rightBoard and when he touches buttons. repair that to make the movement coherent
User prompt
Please fix the bug: 'Uncaught ReferenceError: dragNode is not defined' in or related to this line: 'if (dragNode) {' Line Number: 671
User prompt
currently buttons always move with the cursor. they should move with the cursor only during the mouse down state
User prompt
currently buttons always move with the cursor. they should only move when user taps the screen
===================================================================
--- original.js
+++ change.js
@@ -356,9 +356,8 @@
// Event handler called when a press happens on the button
self.down = function (x, y, obj) {
log("Generator button pressed", y);
globalStartY = y;
- dragNode = rightBoard; // Set dragNode to rightBoard instead of the button
self.startTime = Date.now();
self.startX = x;
};
self.up = function (x, y, obj) {
@@ -536,22 +535,21 @@
self.lastY = 0;
self.velocity = 0;
self.isAnimating = false;
self.lastTime = Date.now();
+ self.lastDeltaY = 0;
+ self.moveCount = 0;
// Add momentum animation
self.applyMomentum = function () {
- if (Math.abs(self.velocity) < 0.1) {
+ if (Math.abs(self.velocity) < 1) {
self.velocity = 0;
self.isAnimating = false;
return;
}
- var currentTime = Date.now();
- var deltaTime = (currentTime - self.lastTime) / 16; // Normalize to ~60fps
- self.lastTime = currentTime;
// Apply friction
- self.velocity *= Math.pow(0.95, deltaTime);
+ self.velocity *= 0.95;
// Calculate movement with velocity
- var deltaY = self.velocity * deltaTime;
+ var deltaY = self.velocity;
// Check boundaries
var firstButtonNewY = self.y + self.generatorButtons[0].y + deltaY;
var lastButtonNewY = self.y + self.generatorButtons[self.generatorButtons.length - 1].y + deltaY;
// Bounce effect at boundaries
@@ -573,17 +571,13 @@
};
// Position the rightBoard at the right side of the screen
self.x = 1848;
self.y = 1366;
- self.buttonsOffsetX = 50;
- self.buttonsOffsetY = -300;
- self.generatorButtons = []; // Initialize an array to hold generator buttons
- // Create and position generator buttons
- for (var i = 0; i <= 9; i++) {
- // Todo : use maxGenerators
+ self.generatorButtons = [];
+ for (var i = 0; i < maxGenerators; i++) {
var generatorButton = new GeneratorButton(i);
- generatorButton.x = self.buttonsOffsetX; //0 * self.x + i * 100 - 100; // Position buttons with some spacing
- generatorButton.y = self.buttonsOffsetY + i * 300 + i * 300 * 0.1; //self.y;
+ generatorButton.x = 0;
+ generatorButton.y = i * 300;
self.generatorButtons.push(generatorButton);
self.addChild(generatorButton);
}
self.down = function (x, y, obj) {
@@ -594,16 +588,22 @@
self.isAnimating = false;
dragNode = self;
self.startTime = Date.now();
self.lastTime = Date.now();
+ self.moveCount = 0;
+ self.lastDeltaY = 0;
};
self.move = function (x, y, obj) {
if (dragNode === self || dragNode instanceof GeneratorButton) {
var deltaY = y - globalStartY;
var currentTime = Date.now();
- var deltaTime = (currentTime - self.lastTime) / 16; // Normalize to ~60fps
- // Calculate velocity based on movement and time
- self.velocity = (y - self.lastY) / deltaTime;
+ // Track movement for momentum
+ self.moveCount++;
+ var moveDeltaY = y - self.lastY;
+ self.lastDeltaY = moveDeltaY;
+ // Calculate velocity based on recent movement
+ // We'll use this for initial momentum when letting go
+ self.velocity = moveDeltaY * 1.2; // Amplify the velocity a bit
// Update tracking variables
self.lastY = y;
self.lastTime = currentTime;
// Calculate new positions for boundaries
@@ -612,15 +612,15 @@
// Adjust deltaY to prevent moving beyond boundaries
if (deltaY > 0) {
deltaY = Math.min(deltaY, 1000 - (self.y + self.generatorButtons[0].y));
if (firstButtonNewY > 1000) {
- self.velocity *= 0.5; // Reduce velocity when hitting boundary
+ self.velocity *= 0.5;
}
}
if (deltaY < 0) {
deltaY = Math.max(deltaY, 1366 - (self.y + self.generatorButtons[self.generatorButtons.length - 1].y));
if (lastButtonNewY < 1366) {
- self.velocity *= 0.5; // Reduce velocity when hitting boundary
+ self.velocity *= 0.5;
}
}
// Move all generator buttons vertically based on swipe direction
self.generatorButtons.forEach(function (button) {
@@ -635,10 +635,12 @@
var distance = Math.sqrt(Math.pow(x - self.startX, 2) + Math.pow(y - globalStartY, 2));
if (timeDiff < 200 && distance < 10) {
// Detected as a tap
log("Detected tap on RightBoard");
- } else {
- // Start momentum animation
+ } else if (self.moveCount > 2) {
+ // Only apply momentum if there was actual movement
+ // Use the last movement delta for initial momentum
+ self.velocity = self.lastDeltaY * 1.2; // Amplify the final velocity a bit
self.isAnimating = true;
LK.setTimeout(self.applyMomentum, 16);
}
dragNode = null;
a big lovely heart
a big stone heart
a big used copper heart
face view of a big bronze heart
face view of a big silver heart
Big shining gold heart verly slightly ornate. face view.
Big precious shiny porcelain heart slightly ornate. face view.
Large precious heart in mother-of-pearl, lightly ornate. Front view.
Large heart in precious ruby, very lightly decorated. Front view.
The most precious large heart in diamond, Front view.
clean pink enamel board witha very thin border