User prompt
even with value 200 `Math.abs(self.parent.x + self.x - player.x) < 200 && Math.abs(self.parent.y + self.y - player.y) < 200 ` doesn't work. find another way to detect proximity
Code edit (1 edits merged)
Please save this source code
User prompt
`isBonusActive && Math.abs(self.x - player.x) < 150 && Math.abs(self.y - player.y) < 150 ||` I think self.x is relative it should take into acount parents position
Code edit (4 edits merged)
Please save this source code
User prompt
`isBonusActive && self.x === player.x && self.y === player.y ` is too restrictive, the detristus have just to pass near the player to be taken
User prompt
consition in `if (!self.taken && (isBonusActive || player.body.torso.intersects(self)))` is not enough because when isBonusActive still the detritus must reach player position (angle/ node) on the road
User prompt
while bonus is active, make detritus reaching the player position automatically taken without need of intersect
Code edit (3 edits merged)
Please save this source code
User prompt
in startBonusAnimation, call stopBouns() after BONUS_DURATION_SEC seconds
Code edit (9 edits merged)
Please save this source code
User prompt
in startBonusAnimation, when setting isBonusActive active stop bgMusic and play bonusMusic
Code edit (1 edits merged)
Please save this source code
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
===================================================================
--- original.js
+++ change.js
@@ -73,18 +73,22 @@
self.taken = false;
self.update = function () {
//log("player.sliding:", player.sliding);
if (!player.sliding && player.body.torso.intersects(self)) {
- player.hitWall = true;
- player.sliding = true; // Keep down
- player.isDead = true;
- tintPlayer(0x666666);
- log("Player hit a wall!");
- // Flash screen red for 1 second (1000ms) to show we are dead.
- LK.effects.flashScreen(0xff0000, 1000);
- // Play lose sound
- LK.getSound('lose').play();
- callGameOver(true);
+ if (!isBonusActive) {
+ player.hitWall = true;
+ player.sliding = true; // Keep down
+ player.isDead = true;
+ tintPlayer(0x666666);
+ log("Player hit a wall!");
+ // Flash screen red for 1 second (1000ms) to show we are dead.
+ LK.effects.flashScreen(0xff0000, 1000);
+ // Play lose sound
+ LK.getSound('lose').play();
+ callGameOver(true);
+ } else {
+ // TODO : what id hit wall while bonus active ?
+ }
}
};
return self;
});
@@ -667,8 +671,10 @@
self.jumpStart = jumpStart;
self.jumpEnd = jumpEnd;
self.slideStart = slideStart;
self.slideEnd = slideEnd;
+ self.enterBonusState = enterBonusState;
+ self.exitBonusState = exitBonusState;
;
function update() {
if (!isActive()) {
return;
@@ -686,9 +692,9 @@
} else if (nextNode.step > step && outputSpeed > distance) {
road.rotate(distance - PLAYER_SPACING);
speedFactor = PLAYER_SPEED_FACTOR_BASE;
stopped = true;
- if (currentNode.step <= step) {
+ if (!isBonusActive && currentNode.step <= step) {
body.pushAnimation(animationStand, PLAYER_POSE_TRANSITION);
}
}
if (!stopped) {
@@ -706,43 +712,51 @@
}
}
}
}
- // TOOD: Get new node if applicable
- // Update vertical movement
- if (jumping) {
- //log("speedFactor", speedFactor, "outputSpeed", outputSpeed);
- jumpStep += aerialSpeed * speedFactor;
- //log("jumpAction:", jumpAction, "jumpStep:", jumpStep, "PLAYER_JUMP_STEP_MIN:", PLAYER_JUMP_STEP_MIN, "PLAYER_JUMP_STEP_MAX:", PLAYER_JUMP_STEP_MAX);
- if (!jumpAction && jumpStep <= PLAYER_JUMP_STEP_MIN || jumpStep >= PLAYER_JUMP_STEP_MAX) {
+ if (isBonusActive) {
+ // Animate player tint using multiple flashy colors
+ var colors = [0xff0000, 0x00ff00, 0x0000ff, 0xffff00, 0xff00ff, 0x00ffff];
+ var colorIndex = Math.floor(LK.ticks / 5 % colors.length);
+ var tintColor = colors[colorIndex];
+ tintPlayer(tintColor);
+ } else {
+ // TOOD: Get new node if applicable
+ // Update vertical movement
+ if (jumping) {
+ //log("speedFactor", speedFactor, "outputSpeed", outputSpeed);
+ jumpStep += aerialSpeed * speedFactor;
+ //log("jumpAction:", jumpAction, "jumpStep:", jumpStep, "PLAYER_JUMP_STEP_MIN:", PLAYER_JUMP_STEP_MIN, "PLAYER_JUMP_STEP_MAX:", PLAYER_JUMP_STEP_MAX);
+ if (!jumpAction && jumpStep <= PLAYER_JUMP_STEP_MIN || jumpStep >= PLAYER_JUMP_STEP_MAX) {
+ falling = true;
+ jumping = false;
+ jumpAction = false;
+ jumpStep = 0;
+ }
+ } else if (falling) {
+ aerialSpeed -= PLAYER_GRAVITY * speedFactor;
+ } else if (step > currentNode.step) {
falling = true;
- jumping = false;
- jumpAction = false;
- jumpStep = 0;
+ body.pushAnimation(animationJump, PLAYER_POSE_TRANSITION);
}
- } else if (falling) {
- aerialSpeed -= PLAYER_GRAVITY * speedFactor;
- } else if (step > currentNode.step) {
- falling = true;
- body.pushAnimation(animationJump, PLAYER_POSE_TRANSITION);
- }
- step += aerialSpeed;
- //log("falling", falling, "step:", step, "currentNode.step:", currentNode.step);
- if (falling && step <= currentNode.step) {
- step = currentNode.step;
- falling = false;
- aerialSpeed = 0;
- body.pushAnimation(stopped ? animationStand : animationRun, PLAYER_POSE_TRANSITION);
- }
- if (self.sliding) {
- slideTimer += 1 * speedFactor;
- if (slideTimer >= SLIDE_DURATION) {
- slideEnd();
+ step += aerialSpeed;
+ //log("falling", falling, "step:", step, "currentNode.step:", currentNode.step);
+ if (falling && step <= currentNode.step) {
+ step = currentNode.step;
+ falling = false;
+ aerialSpeed = 0;
+ body.pushAnimation(stopped ? animationStand : animationRun, PLAYER_POSE_TRANSITION);
}
- // Adjust player's vertical position when sliding
- self.y = baseY - 500; //- stepHeight / 4; // Adjust to quarter height when sliding
- } else {
- self.y = baseY - stepHeight;
+ if (self.sliding) {
+ slideTimer += 1 * speedFactor;
+ if (slideTimer >= SLIDE_DURATION) {
+ slideEnd();
+ }
+ // Adjust player's vertical position when sliding
+ self.y = baseY - 500; //- stepHeight / 4; // Adjust to quarter height when sliding
+ } else {
+ self.y = baseY - stepHeight;
+ }
}
// Score calculations
if (!gameOver && currentNode.distance > nodeDistance) {
adjustScore(nodeMulti / nodeTicks);
@@ -762,9 +776,9 @@
//multiplierText.setText((stopped ? SCORE_STOPPED_FACTOR : speedFactor).toFixed(1) + 'x');
// Get the current road segment
var currentSegment = road.getNode(0);
// Check if the current segment is a river segment
- if (currentSegment.isRiver && !jumping && !falling && !jumpAction) {
+ if (!isBonusActive && currentSegment.isRiver && !jumping && !falling && !jumpAction) {
self.isDead = true;
tintPlayer(0xff0000);
// Player is above a river segment
log("Player fell in the river!");
@@ -773,15 +787,8 @@
// Play lose sound
LK.getSound('lose').play();
callGameOver(true);
}
- if (isBonusActive) {
- // Animate player tint using multiple flashy colors
- var colors = [0xff0000, 0x00ff00, 0x0000ff, 0xffff00, 0xff00ff, 0x00ffff];
- var colorIndex = Math.floor(LK.ticks / 5 % colors.length);
- var tintColor = colors[colorIndex];
- tintPlayer(tintColor);
- }
}
function jumpStart() {
if (!gameOver && !jumping && !falling && !self.sliding) {
LK.getSound('jump').play();
@@ -823,8 +830,11 @@
}
}
function enterBonusState() {
// ... other bonus state logic ...
+ if (self.sliding) {
+ slideEnd();
+ }
body.pushAnimation(animationBonus, PLAYER_POSE_TRANSITION);
}
function exitBonusState() {
// ... other exit bonus state logic ...
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.