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
User prompt
now use attachObjectRadial instead of attachAssetRadial for walls
User prompt
Add a new class for Wall similar to Detritus
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (2 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: player.slideStart is not a function' in or related to this line: 'player.slideStart();' Line Number: 1109
Code edit (1 edits merged)
Please save this source code
User prompt
add a flag to start detecting swipe only after tap
Code edit (15 edits merged)
Please save this source code
User prompt
don't forget to reset startY
===================================================================
--- original.js
+++ change.js
@@ -58,8 +58,48 @@
}
;
return self;
});
+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();
+ self.attachAsset('wall' + wallIndex, {
+ anchorX: 0.5,
+ anchorY: 1,
+ scaleX: 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();
+ }
+ };
+ return self;
+});
var Sun = ConfigContainer.expand(function (config) {
var self = ConfigContainer.call(this, config);
for (var i = 0; i < 5; i++) {
self.attachAsset('circle', {
@@ -133,8 +173,9 @@
self.step = config.step;
self.stepChance = config.stepChance;
self.previous = config.previous;
self.isRiver = false;
+ self.isWall = false;
;
function attachAssetRadial(parent, asset, obj) {
var offsetTotal = ROAD_SEGMENT_HEIGHT - (obj.offset || 10);
var rotation = -(1 - obj.anchorR) * ROAD_SEGMENT_ANGLE;
@@ -167,8 +208,9 @@
function generateBackground() {
console.log(self.distance);
background.removeChildren();
self.isRiver = false;
+ self.isWall = false;
self.segmentRiver.visible = false;
var plantCount = Math.floor(Math.random() * (ROAD_GEN_PLANT_MAX + 1));
if (self.distance === SCORE_TOTAL_DISTANCE) {
attachAssetRadial(background, 'flag', {
@@ -214,8 +256,19 @@
});
attachObjectRadial(self.previous.background, new BoilingLava(), {
anchorR: 0.1 + 0.8 * Math.random()
});
+ } else if (Math.random() < ROAD_GEN_WALL_CHANCE) {
+ self.isWall = true;
+ var wallIndex = Math.floor(Math.random() * ROAD_GEN_WALL_ASSETS);
+ var scale = 1; //0.9 + 0.2 * Math.random();
+ attachAssetRadial(background, 'wall' + wallIndex, {
+ anchorR: 0.4 + 0.2 * Math.random(),
+ anchorX: 0.5,
+ anchorY: 1,
+ scaleX: scale,
+ scaleY: scale
+ });
} else {
if (Math.random() < ROAD_GEN_TREE_CHANCE) {
var treeIndex = Math.floor(Math.random() * ROAD_GEN_TREE_ASSETS);
var scale = 0.9 + 0.2 * Math.random();
@@ -673,9 +726,9 @@
callGameOver(true);
}
}
function jumpStart() {
- if (!gameOver && !jumping && !falling) {
+ if (!gameOver && !jumping && !falling && !sliding) {
LK.getSound('jump').play();
jumping = true;
jumpAction = true;
aerialSpeed = PLAYER_JUMP_STEP_INCREMENT;
@@ -982,8 +1035,10 @@
var ROAD_GEN_DETRITUS_FLYING_ASSETS = 2;
var ROAD_GEN_DETRITUS_FLYING_CHANCE = 0.05;
var ROAD_GEN_FRAGILE_NATURE_ASSETS = 2;
var ROAD_GEN_FRAGILE_NATURE_CHANCE = 0.1;
+var ROAD_GEN_WALL_ASSETS = 1;
+var ROAD_GEN_WALL_CHANCE = 0.2;
;
// Player Constants
var PLAYER_SPACING = ROAD_SEGMENT_ANGLE / 8; // 1/8 of a segment
var PLAYER_POSE_TRANSITION = 0.1;
@@ -1192,39 +1247,14 @@
FOOT_RIGHT_ROTATION: -sharedAngle - 1.5 * offsetAngle,
FOOT_LEFT_ROTATION: -sharedAngle + 1.5 * offsetAngle
};
}
-/*
-function animationSlide(alpha) {
- return {
- BODY_OFFSET: -150,
- // Lower the body significantly more
- HEAD_ROTATION: -Math.PI / 3,
- // Tilt head down more
- ARM_UPPER_RIGHT_ROTATION: Math.PI * 3 / 4,
- // Arms more back and up
- ARM_UPPER_LEFT_ROTATION: Math.PI * 3 / 4,
- ARM_LOWER_RIGHT_ROTATION: -Math.PI / 4,
- // Slightly bend arms
- ARM_LOWER_LEFT_ROTATION: -Math.PI / 4,
- LEG_UPPER_RIGHT_ROTATION: -Math.PI / 2,
- // Legs more horizontal
- LEG_UPPER_LEFT_ROTATION: -Math.PI / 2,
- LEG_LOWER_RIGHT_ROTATION: Math.PI / 4,
- // Slight bend in knees
- LEG_LOWER_LEFT_ROTATION: Math.PI / 4,
- FOOT_RIGHT_ROTATION: Math.PI / 6,
- // Feet angled slightly
- FOOT_LEFT_ROTATION: Math.PI / 6
- };
-}
-*/
// On belly head front
function animationSlide(alpha) {
return {
- BODY_ROTATION: Math.PI / 4,
+ BODY_ROTATION: Math.PI / 2,
// Rotate body 90 degrees
- BODY_OFFSET: -50,
+ BODY_OFFSET: -30,
// Adjust body position to align with ground
HEAD_ROTATION: Math.PI / 4,
// Arm Right
ARM_UPPER_RIGHT_ROTATION: Math.PI / 4,
@@ -1240,57 +1270,5 @@
LEG_LOWER_LEFT_ROTATION: Math.PI / 6,
FOOT_RIGHT_ROTATION: 0,
FOOT_LEFT_ROTATION: 0
};
-}
-/* // super man head back but on belly
-function animationSlide(alpha) {
- return {
- BODY_ROTATION: Math.PI / 2,
- // Rotate body 90 degrees
- BODY_OFFSET: -20,
- // Adjust body position to align with ground
- HEAD_ROTATION: Math.PI / 6,
- // Tilt head up slightly
- ARM_UPPER_RIGHT_ROTATION: -Math.PI * 3 / 4,
- // Arms stretched forward
- ARM_UPPER_LEFT_ROTATION: -Math.PI * 3 / 4,
- ARM_LOWER_RIGHT_ROTATION: 0,
- // Arms straight
- ARM_LOWER_LEFT_ROTATION: 0,
- LEG_UPPER_RIGHT_ROTATION: Math.PI / 8,
- // Legs slightly raised
- LEG_UPPER_LEFT_ROTATION: Math.PI / 8,
- LEG_LOWER_RIGHT_ROTATION: Math.PI / 6,
- // Knees slightly bent
- LEG_LOWER_LEFT_ROTATION: Math.PI / 6,
- FOOT_RIGHT_ROTATION: 0,
- FOOT_LEFT_ROTATION: 0
- };
-}
-*/
-/* // Head ok but Belly & Flying
-function animationSlide(alpha) {
- return {
- BODY_ROTATION: -Math.PI / 2,
- // Rotate body -90 degrees (feet first)
- BODY_OFFSET: -20,
- // Adjust body position to align with ground
- HEAD_ROTATION: -Math.PI / 6,
- // Tilt head back slightly
- ARM_UPPER_RIGHT_ROTATION: Math.PI / 4,
- // Arms slightly raised
- ARM_UPPER_LEFT_ROTATION: Math.PI / 4,
- ARM_LOWER_RIGHT_ROTATION: Math.PI / 6,
- // Elbows slightly bent
- ARM_LOWER_LEFT_ROTATION: Math.PI / 6,
- LEG_UPPER_RIGHT_ROTATION: -Math.PI / 8,
- // Legs slightly raised
- LEG_UPPER_LEFT_ROTATION: -Math.PI / 8,
- LEG_LOWER_RIGHT_ROTATION: Math.PI / 6,
- // Knees slightly bent
- LEG_LOWER_LEFT_ROTATION: Math.PI / 6,
- FOOT_RIGHT_ROTATION: 0,
- FOOT_LEFT_ROTATION: 0
- };
-}
-*/
\ No newline at end of file
+}
\ No newline at end of file
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.