Code edit (1 edits merged)
Please save this source code
User prompt
in Player.update(), add other flashy colors to animate player tint when bonus is active and make them change fast
Code edit (1 edits merged)
Please save this source code
User prompt
in Player.update(), animate player tint using tintPlayer() from white to green and vice versa
Code edit (14 edits merged)
Please save this source code
User prompt
in player class while isBonusActive, animate player tint using tintPlayer() from white to green and vice versa
Code edit (1 edits merged)
Please save this source code
User prompt
when bonus reaches 1st target then it moves toward the player while decreasing width and height to 10
Code edit (1 edits merged)
Please save this source code
User prompt
Animate bonus : move to road x,y while increasing width and height to 1024
Code edit (7 edits merged)
Please save this source code
User prompt
in startBonusAnimation add a green screen flash
User prompt
play startButon audio when start button pressed
User prompt
replace this code ``` for (var i = 0; i < road.segments.length; i++) { var segment = road.segments[i]; for (var j = 0; j < segment.background.children.length; j++) { var child = segment.background.children[j]; log("child[".concat(i, "][").concat(j, "]"), child); if (child.taken) { log("IS TAKEN : ", child); child.children[0].alpha = 0; } } } ```` to search for taken property in game children because when taken objects are deteched from road to game
Code edit (2 edits merged)
Please save this source code
User prompt
fix : ``` for (var i = 0; i < roadContainer.children.length; i++) { var child = roadContainer.children[i]; if (child.taken) { child.alpha = 0; } } ``` becaus detritus are attached to background property of roadsegment that are in road.segments array
Code edit (1 edits merged)
Please save this source code
User prompt
in startBonusAnimation, set alpha of all taken detritus to 0
Code edit (4 edits merged)
Please save this source code
User prompt
in startBonusAnimation, play bonus start sound and create a bonus asset at the recycleBin position
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
User prompt
in Starfield add a property 'direction' to star, then use it to make star alpha change from 0 to 1 and vice versa
User prompt
update this : self.update = function () { for (var i = 0; i < self.children.length; i++) { var star = self.children[i]; if (Math.random() < 0.01) { // 1% chance to animate each star per frame star.alpha = 0.5 + 0.5 * Math.sin(LK.ticks / 30 + i); // Animate alpha from 0.5 to 1.0 } } }; to use this algotithm: Every 3 sec, select 10 stars randomly, then for this selected stars animate alpha from 0 to 1 and vice versa
Code edit (10 edits merged)
Please save this source code
===================================================================
--- original.js
+++ change.js
@@ -108,8 +108,12 @@
;
self.update = update;
;
function update() {
+ if (isBonusActive) {
+ var tintColor = LK.ticks % 60 < 30 ? 0x00ff00 : 0xffffff; // Alternate between green and white every 30 ticks
+ tintPlayer(tintColor);
+ }
if (LK.ticks % 30 == 0) {
for (var i = 0; i < self.children.length - 1; i++) {
var circle = self.children[i];
if (i % 2 !== 0) {
@@ -336,8 +340,11 @@
rescale();
}
function update() {
if (!isActive()) {
+ if (isBonusActive) {
+ tintPlayer(0xffffff); // Reset tint to white when bonus is not active
+ }
return;
}
if (self.fadeout && self.alpha > 0) {
if ((self.alpha -= ROAD_SEGMENT_FADEOUT) < 0) {
@@ -1388,9 +1395,8 @@
function startBonusAnimation() {
log('startBonusAnimation...');
nbCollectedBeforeBonus = 0;
isBonusStartAnim = true;
- isBonusActive = true;
// Set alpha of all taken detritus to 0
for (var i = 0; i < game.children.length; i++) {
var child = game.children[i];
if (child.taken) {
@@ -1415,10 +1421,12 @@
var targetX = road.x;
var targetY = road.y;
var targetWidth = 1024;
var targetHeight = 1024;
- var duration = 100; // Duration of the animation in milliseconds
+ var duration = 40; // Duration of the animation in milliseconds
+ var duration2 = 30; // Duration of the animation in milliseconds
var startTime = LK.ticks;
+ var startTime2 = LK.ticks;
bonus.update = function () {
var elapsed = LK.ticks - startTime;
var progress = Math.min(elapsed / duration, 1);
if (progress < 1) {
@@ -1426,26 +1434,33 @@
bonus.y = recycleBin.y + (targetY - recycleBin.y) * progress;
bonus.width = 100 + (targetWidth - 100) * progress;
bonus.height = 100 + (targetHeight - 100) * progress;
}
- if (progress >= 1) {
+ if (progress > 0.5) {
+ LK.getSound('bonusMove').play();
+ }
+ if (progress === 1 && elapsed > duration * 2) {
// Set new target to player position
targetX = player.x;
- targetY = player.y;
+ targetY = player.y - player.height / 2;
targetWidth = 10;
targetHeight = 10;
- startTime = LK.ticks; // Reset start time for the new animation phase
+ startTime2 = LK.ticks; // Reset start time for the new animation phase
bonus.update = function () {
- var elapsed = LK.ticks - startTime;
- var progress2 = Math.min(elapsed / duration, 1);
+ var elapsed2 = LK.ticks - startTime2;
+ var progress2 = Math.min(elapsed2 / duration2, 1);
+ if (progress2 > 0.5) {
+ LK.getSound('bonusMove').play();
+ }
if (progress2 < 1) {
bonus.x = road.x + (targetX - road.x) * progress2;
bonus.y = road.y + (targetY - road.y) * progress2;
bonus.width = 1024 + (targetWidth - 1024) * progress2;
bonus.height = 1024 + (targetHeight - 1024) * progress2;
}
- if (progress2 >= 1) {
+ if (progress2 === 1) {
bonus.destroy();
+ isBonusActive = true;
}
};
}
};
white
circle sliced into many pieces, flat image. 2d, white background, shadowless.
pixel art of a tall, tree. game asset, 2d, white background, shadowless.
pixel art cloud. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
dark space.
flying lava bubble. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a bonus crystal ball with the recycle symbol. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
top view A green round start button empty in the center like a ring.