Code edit (1 edits merged)
Please save this source code
User prompt
in adjustScore replace scoreText.setText(String(score).padStart(6, '0')); by a the kgCollected with 2 digits
Code edit (4 edits merged)
Please save this source code
User prompt
when collecting a detritus add 0.01 to kgCollected
Code edit (9 edits merged)
Please save this source code
User prompt
extract this code : self.body.torso.tint = 0xff0000; // Tint the player's torso red self.body.legUpperLeft.children[0].tint = 0xff0000; // Tint the player's upper left leg red self.body.legUpperRight.children[0].tint = 0xff0000; // Tint the player's upper right leg red self.body.armUpperLeft.children[0].tint = 0xff0000; // Tint the player's upper left arm red self.body.armUpperRight.children[0].tint = 0xff0000; // Tint the player's upper right arm red self.body.armLowerLeft.tint = 0xff0000; self.body.armLowerRight.tint = 0xff0000; self.body.legLowerLeft.tint = 0xff0000; self.body.legLowerRight.tint = 0xff0000; self.body.pelvis.tint = 0xff0000; // Tint the player's pelvis red self.body.head.tint = 0xff0000; // Tint the player's head red self.body.footRight.tint = 0xff0000; self.body.footLeft.tint = 0xff0000; to a global function. user player global variable and make the color a parameter
Code edit (1 edits merged)
Please save this source code
User prompt
like for torso : self.body.torso.tint = 0xff0000; // Tint the player red Tint every other part in red when player fall in reiver
User prompt
in playerbody, like for torso, add a public property for each asset but dont replace existing local variables, just add new properties: example : var pelvis = ...; // Don't touch that self.pelvis = pelvis; // Add that
User prompt
Please fix the bug: 'ReferenceError: torso is not defined' in or related to this line: 'self.pelvis = self.attachAsset('pelvis', {' Line Number: 540
User prompt
in playerbody, like for torso, add a public property for each asset
Code edit (21 edits merged)
Please save this source code
User prompt
when player hits river, tint the player all in red
User prompt
when player hits river, tint it all in red
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (3 edits merged)
Please save this source code
User prompt
play slide sound when sliding
Code edit (7 edits merged)
Please save this source code
User prompt
in callGameOver wait 1sec befaore falling gameover
Code edit (1 edits merged)
Please save this source code
User prompt
adapt the speed of the jump and the speed of the fall to the player speed.
User prompt
make that at high speed player don't jump too far because of its speed
Code edit (2 edits merged)
Please save this source code
User prompt
adapt jump and gravity to speed so that at high speed player doesn't jump too far becaus of speed
===================================================================
--- original.js
+++ change.js
@@ -73,8 +73,10 @@
self.taken = false;
self.update = function () {
console.log("player.sliding:", player.sliding);
if (!player.sliding && player.body.torso.intersects(self)) {
+ player.hitWall = true;
+ player.sliding = true; // Keep down
console.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
@@ -228,9 +230,9 @@
rotation: -Math.PI * 0.25 + Math.random() * Math.PI * 0.5,
flying: 1,
levitOffset: 525
});
- } else if (road && road.riverSegmentCount < ROAD_MAX_RIVER_SEGMENTS && !self.isRiver && !self.isWall && !self.previous.isWall && (!self.previous.previous || !self.previous.previous.isWall) && (!self.previous.previous.previous || !self.previous.previous.previous.isWall) && Math.random() < ROAD_GEN_FRAGILE_NATURE_CHANCE) {
+ } else if (road && road.riverSegmentCount < ROAD_MAX_RIVER_SEGMENTS && !self.isRiver && !self.isWall && !self.previous.isWall && (!self.previous.previous || !self.previous.previous.isWall) && (!self.previous.previous.previous || !self.previous.previous.previous.isWall) && (!self.previous.previous.previous.previous || !self.previous.previous.previous.previous.isWall) && Math.random() < ROAD_GEN_FRAGILE_NATURE_CHANCE) {
self.isRiver = true;
self.segmentRiver.visible = true;
road.riverSegmentCount++;
self.previous.isRiver = true;
@@ -241,9 +243,9 @@
});
attachObjectRadial(self.previous.background, new BoilingLava(), {
anchorR: 0.1 + 0.8 * Math.random()
});
- } else if (road && road.wallSegmentCount < ROAD_MAX_WALL_SEGMENTS && !self.isWall && !self.isRiver && !self.previous.isRiver && (!self.previous.previous || !self.previous.previous.isRiver) && (!self.previous.previous.previous || !self.previous.previous.previous.isRiver) && Math.random() < ROAD_GEN_WALL_CHANCE) {
+ } else if (road && road.wallSegmentCount < ROAD_MAX_WALL_SEGMENTS && !self.isWall && !self.isRiver && !self.previous.isRiver && (!self.previous.previous || !self.previous.previous.isRiver) && (!self.previous.previous.previous || !self.previous.previous.previous.isRiver) && (!self.previous.previous.previous.previous || !self.previous.previous.previous.previous.isRiver) && Math.random() < ROAD_GEN_WALL_CHANCE) {
self.isWall = true;
road.wallSegmentCount++;
var wallIndex = Math.floor(Math.random() * ROAD_GEN_WALL_ASSETS);
var scale = 1; //0.9 + 0.2 * Math.random();
@@ -621,8 +623,9 @@
self.jumping = false;
self.sliding = false;
self.slideStart = slideStart;
self.slideEnd = slideEnd;
+ self.hitWall = false;
self.intersects = function (obj) {
var bounds1 = self.getBounds();
var bounds2 = obj.getBounds();
if (self.sliding) {
@@ -677,18 +680,18 @@
// TOOD: Get new node if applicable
// Update vertical movement
if (jumping) {
console.log("speedFactor", speedFactor, "outputSpeed", outputSpeed);
- jumpStep += aerialSpeed * outputSpeed;
+ jumpStep += aerialSpeed * speedFactor;
//console.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;
+ aerialSpeed -= PLAYER_GRAVITY * speedFactor;
} else if (step > currentNode.step) {
falling = true;
body.pushAnimation(animationJump, PLAYER_POSE_TRANSITION);
}
@@ -700,9 +703,9 @@
aerialSpeed = 0;
body.pushAnimation(stopped ? animationStand : animationRun, PLAYER_POSE_TRANSITION);
}
if (self.sliding) {
- slideTimer++;
+ slideTimer += 1 * speedFactor;
if (slideTimer >= SLIDE_DURATION) {
slideEnd();
}
// Adjust player's vertical position when sliding
@@ -769,9 +772,9 @@
*/
}
}
function slideEnd() {
- if (self.sliding) {
+ if (self.sliding && !self.hitWall) {
self.sliding = false;
slideTimer = 0;
body.pushAnimation(stopped ? animationStand : animationRun, PLAYER_POSE_TRANSITION);
// Restore body's original rotation and scale
@@ -1057,9 +1060,9 @@
// Player Constants
var PLAYER_SPACING = ROAD_SEGMENT_ANGLE / 8; // 1/8 of a segment
var PLAYER_POSE_TRANSITION = 0.1;
var PLAYER_GRAVITY = 0.02;
-var PLAYER_JUMP_STEP_MIN = 1.0; // 720; // 1.0;
+var PLAYER_JUMP_STEP_MIN = 1.5; // 720; // 1.0;
var PLAYER_JUMP_STEP_MAX = 2.0; //1500; //2.0;
var PLAYER_JUMP_STEP_INCREMENT = 0.75; //; 0.15;
var PLAYER_ANIMATION_SPEED_BASE = 0.02;
var PLAYER_SCALE_BASE = 1; //0.5;
@@ -1202,9 +1205,11 @@
winningText.setText(lost ? 'Oh no!' : 'Congratulations!');
// Check if winningTime is set and show game over screen after 60 ticks
game.update = function () {
if (lost || winningTime && LK.ticks >= winningTime + 120) {
- LK.showGameOver();
+ LK.setTimeout(function () {
+ LK.showGameOver();
+ }, 1000);
}
};
}
;
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.