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
User prompt
make jump and gravity increase proportionnaly to speed
Code edit (1 edits merged)
Please save this source code
Code edit (8 edits merged)
Please save this source code
User prompt
Analyse the code then adapt it to make player appear behind the road assets but WITHOUT changing any of the road or player movment logic
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: road is undefined' in or related to this line: 'var player = game.addChild(new Player({' Line Number: 1155
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: road is undefined' in or related to this line: 'var player = game.addChild(new Player({' Line Number: 1152
Code edit (2 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'parent.attachAsset(asset, {' Line Number: 214
User prompt
Please fix the bug: 'TypeError: parent is undefined' in or related to this line: 'parent.attachAsset(asset, {' Line Number: 214
User prompt
make clouds appear in front of player (z-index) but without altering their logic or movement
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: clone is not defined' in or related to this line: 'if (clone) {' Line Number: 254
Code edit (11 edits merged)
Please save this source code
===================================================================
--- original.js
+++ change.js
@@ -61,41 +61,26 @@
});
var Wall = ConfigContainer.expand(function (config) {
var self = ConfigContainer.call(this, config);
var wallIndex = Math.floor(Math.random() * ROAD_GEN_WALL_ASSETS);
- var scale = 0.9 + 0.2 * Math.random();
+ var scale = 1; //0.9 + 0.2 * Math.random();
self.attachAsset('wall' + wallIndex, {
anchorX: 0.5,
anchorY: 1,
- scaleX: Math.random() < 0.5 ? -scale : scale,
+ scaleX: scale,
+ //Math.random() < 0.5 ? -scale : scale,
scaleY: scale
});
self.taken = false;
self.update = function () {
- if (self.taken) {
- var targetX = recycleBin.x;
- var targetY = recycleBin.y;
- var speed = 10;
- var dx = targetX - self.x;
- var dy = targetY - self.y;
- var distance = Math.sqrt(dx * dx + dy * dy);
- if (distance > speed) {
- self.x += dx / distance * speed;
- self.y += dy / distance * speed;
- self.scale.x *= 0.9975;
- self.scale.y *= 0.9975;
- } else {
- self.x = targetX;
- self.y = targetY;
- self.destroy();
- }
- } else if (!self.taken && player.body.torso.intersects(self)) {
- self.taken = true;
- var globalPosition = self.parent.toGlobal(self.position);
- self.parent.removeChild(self);
- game.addChild(self);
- self.position = game.toLocal(globalPosition);
- LK.getSound('collectDetritus').play();
+ console.log("player.sliding:", player.sliding);
+ if (!player.sliding && player.body.torso.intersects(self)) {
+ 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
+ LK.getSound('lose').play();
+ callGameOver(true);
}
};
return self;
});
@@ -193,9 +178,9 @@
}
function attachObjectRadial(parent, object, obj) {
var offsetTotal = ROAD_SEGMENT_HEIGHT - (obj.offset || 10);
var rotation = -(1 - obj.anchorR) * ROAD_SEGMENT_ANGLE;
- object.x = Math.sin(rotation) * offsetTotal - (obj.levitOffset || 0); //125* (obj.levitOffset || 0) - 400 * (obj.flying || 0);
+ object.x = Math.sin(rotation) * offsetTotal - (obj.levitOffset && !obj.isOver || 0); //125* (obj.levitOffset || 0) - 400 * (obj.flying || 0);
object.y = Math.cos(rotation) * -offsetTotal - (obj.levitOffset || 0);
//object.width = obj.width;
//object.height = obj.height;
object.anchorX = obj.anchorX;
@@ -203,14 +188,8 @@
object.scaleX = obj.scaleX || 1;
object.scaleY = obj.scaleY || 1;
object.rotation = (obj.rotation || 0) + 0;
parent.addChild(object);
- var clone = obj.clone || 0;
- if (clone) {
- object.x = Math.sin(rotation) * offsetTotal - (obj.levitOffset || 0) - 200;
- object.y = Math.cos(rotation) * -offsetTotal - (obj.levitOffset || 0) - 200;
- parent.addChild(object);
- }
}
function generateBackground() {
console.log(self.distance);
background.removeChildren();
@@ -262,10 +241,11 @@
});
attachObjectRadial(self.previous.background, new BoilingLava(), {
anchorR: 0.1 + 0.8 * Math.random()
});
- } else if (Math.random() < ROAD_GEN_WALL_CHANCE) {
+ } else if (road && road.wallSegmentCount < ROAD_MAX_WALL_SEGMENTS && !self.isRiver && !self.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();
var anchorR = 0.5; // 0.4 + 0.2 * Math.random();
attachObjectRadial(background, new Wall(), {
@@ -282,17 +262,19 @@
anchorX: 0.5,
anchorY: 1,
scaleX: scale,
scaleY: scale,
- levitOffset: 250
+ levitOffset: 250,
+ isOver: true
});
attachObjectRadial(background, new Wall(), {
anchorR: anchorR,
anchorX: 0.5,
anchorY: 1,
scaleX: scale,
scaleY: scale,
- levitOffset: 500
+ levitOffset: 500,
+ isOver: true
});
}
} else {
if (Math.random() < ROAD_GEN_TREE_CHANCE) {
@@ -403,8 +385,9 @@
rotation: i * ROAD_SEGMENT_ANGLE
});
}
self.riverSegmentCount = 0;
+ self.wallSegmentCount = 0;
self.attachAsset('circle', {
width: 500,
height: 500,
anchorX: 0.5,
@@ -437,8 +420,12 @@
if (segments[destroyIndex].isRiver) {
self.riverSegmentCount--;
self.riverSegmentCount = Math.max(0, self.riverSegmentCount);
}
+ if (segments[destroyIndex].isWall) {
+ self.wallSegmentCount--;
+ self.wallSegmentCount = Math.max(0, self.wallSegmentCount);
+ }
segments[destroyIndex].fadeout = true;
}
if (newRegenerateIndex >= 0 && newRegenerateIndex !== regenerateIndex && segments[newRegenerateIndex].fadeout) {
regenerateIndex = newRegenerateIndex;
@@ -621,32 +608,32 @@
var step = ROAD_STEP_DEFAULT;
var nodeDistance = 0;
var nodeTicks = 0;
var nodeMulti = 0;
+ var slideTimer = 0;
+ var SLIDE_DURATION = 60; // Duration of slide in frames
var body = self.addChild(new PlayerBody({
y: -370
}));
self.body = body;
self.update = update;
self.jumpStart = jumpStart;
self.jumpEnd = jumpEnd;
self.jumping = false;
+ self.sliding = false;
self.slideStart = slideStart;
self.slideEnd = slideEnd;
self.intersects = function (obj) {
var bounds1 = self.getBounds();
var bounds2 = obj.getBounds();
- if (sliding) {
+ if (self.sliding) {
// When sliding, reduce height for collision check
return bounds1.x < bounds2.x + bounds2.width && bounds1.x + bounds1.width > bounds2.x && bounds1.y < bounds2.y + bounds2.height && bounds1.y + bounds1.height / 4 > bounds2.y;
} else {
return bounds1.x < bounds2.x + bounds2.width && bounds1.x + bounds1.width > bounds2.x && bounds1.y < bounds2.y + bounds2.height && bounds1.y + bounds1.height > bounds2.y;
}
};
;
- var sliding = false;
- var slideTimer = 0;
- var SLIDE_DURATION = 60; // Duration of slide in frames
self.update = update;
self.jumpStart = jumpStart;
self.jumpEnd = jumpEnd;
self.slideStart = slideStart;
@@ -711,9 +698,9 @@
falling = false;
aerialSpeed = 0;
body.pushAnimation(stopped ? animationStand : animationRun, PLAYER_POSE_TRANSITION);
}
- if (sliding) {
+ if (self.sliding) {
slideTimer++;
if (slideTimer >= SLIDE_DURATION) {
slideEnd();
}
@@ -732,9 +719,9 @@
nodeMulti += stopped ? SCORE_STOPPED_FACTOR : speedFactor;
nodeTicks++;
// Adjustments
var stepHeight = ROAD_STEP_HEIGHT_BASE + step * ROAD_STEP_HEIGHT_INCREMENT; // TODO: Better scaling
- if (!sliding) {
+ if (!self.sliding) {
self.y = baseY - stepHeight; // TODO: Better scaling
}
self.scale.set(PLAYER_SCALE_BASE * stepHeight / ROAD_SEGMENT_HEIGHT); // TODO: Better scaling
body.animate(PLAYER_ANIMATION_SPEED_BASE * speedFactor);
@@ -752,9 +739,9 @@
callGameOver(true);
}
}
function jumpStart() {
- if (!gameOver && !jumping && !falling && !sliding) {
+ if (!gameOver && !jumping && !falling && !self.sliding) {
LK.getSound('jump').play();
jumping = true;
jumpAction = true;
aerialSpeed = PLAYER_JUMP_STEP_INCREMENT;
@@ -764,10 +751,10 @@
function jumpEnd() {
jumpAction = false;
}
function slideStart() {
- if (!gameOver && !jumping && !falling && !sliding) {
- sliding = true;
+ if (!gameOver && !jumping && !falling && !self.sliding) {
+ self.sliding = true;
slideTimer = 0;
body.pushAnimation(animationSlide, PLAYER_POSE_TRANSITION);
body.rotation = -Math.PI / 2;
//body.scale.x *= -1;
@@ -781,10 +768,10 @@
*/
}
}
function slideEnd() {
- if (sliding) {
- sliding = false;
+ if (self.sliding) {
+ self.sliding = false;
slideTimer = 0;
body.pushAnimation(stopped ? animationStand : animationRun, PLAYER_POSE_TRANSITION);
// Restore body's original rotation and scale
body.rotation = 0;
@@ -1042,8 +1029,9 @@
var ROAD_SEGMENT_HEIGHT = 1000;
var ROAD_SEGMENT_DESTROY = -2;
var ROAD_SEGMENT_FADEOUT = 0.015;
var ROAD_MAX_RIVER_SEGMENTS = 1;
+var ROAD_MAX_WALL_SEGMENTS = 1;
var ROAD_FREE_RUN_COUNT = 5;
var ROAD_STEP_COUNT = 5;
var ROAD_STEP_DEFAULT = 10;
var ROAD_STEP_HEIGHT_BASE = 512;
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.