User prompt
add a class FragileNature like Detritus
Code edit (1 edits merged)
Please save this source code
User prompt
enhance the throw to bin anim by progressively reducing detritus size while approaching the target
Code edit (1 edits merged)
Please save this source code
User prompt
destroy taken detritus when they reach the target position
Code edit (1 edits merged)
Please save this source code
User prompt
when Detritus is taken, detach it from its parent and attach it to the game at the same position
Code edit (1 edits merged)
Please save this source code
User prompt
change the logic to make Detritus check for collision with Player and not Player check for colision with Detritus
Code edit (11 edits merged)
Please save this source code
User prompt
when taken, ignore current movement and animate the movment from thee detritus position to 150,1700 (recycle bin)
User prompt
when play intersects a Detritus, flag it as taken.
Code edit (5 edits merged)
Please save this source code
User prompt
add recyclebin to the game vertical center, on the left
Code edit (2 edits merged)
Please save this source code
User prompt
in DetritusFlying update, make rotation more chaotic
Code edit (1 edits merged)
Please save this source code
Code edit (23 edits merged)
Please save this source code
User prompt
Now add a new class DetritusFlying
Code edit (1 edits merged)
Please save this source code
Code edit (20 edits merged)
Please save this source code
User prompt
use Detritus class in road generateBackground, for that create a clone of attachAssetRadial that take an object insteade of an asset name but does the same thing
User prompt
use Detritus class in road generateBackground
User prompt
add a class for detritus
User prompt
Clone current system used to spanw Trees to spawn detritus
===================================================================
--- original.js
+++ change.js
@@ -152,8 +152,19 @@
scaleY: scale,
rotation: -Math.PI * 0.25 + Math.random() * Math.PI * 0.5,
flying: 1
});
+ } else if (Math.random() < ROAD_GEN_FRAGILE_NATURE_CHANCE) {
+ var fragileNature = new FragileNature();
+ var scale = 1; //0.9 + 0.2 * Math.random();
+ attachObjectRadial(background, fragileNature, {
+ anchorR: 0.1 + 0.8 * Math.random(),
+ anchorX: 0.5,
+ anchorY: 0.1,
+ scaleX: Math.random() < 0.5 ? -scale : scale,
+ scaleY: scale,
+ rotation: -Math.PI * 0.25 + Math.random() * Math.PI * 0.5
+ });
} 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();
@@ -352,8 +363,9 @@
anchorX: 0.5,
anchorY: 0.2,
tint: afterTint
});
+ self.torso = torso;
var legUpperLeft = self.addChild(new ConfigContainer({
x: pelvisOffsetX - legUpperOffsetX - 30
}));
var armUpperLeft = self.addChild(new ConfigContainer({
@@ -477,9 +489,9 @@
var nodeMulti = 0;
var body = self.addChild(new PlayerBody({
y: -370
}));
- ;
+ self.body = body;
self.update = update;
self.jumpStart = jumpStart;
self.jumpEnd = jumpEnd;
self.jumping = false;
@@ -589,8 +601,47 @@
}
;
body.pushAnimation(animationRun, PLAYER_POSE_TRANSITION);
});
+var FragileNature = ConfigContainer.expand(function (config) {
+ var self = ConfigContainer.call(this, config);
+ var fragileNatureIndex = Math.floor(Math.random() * ROAD_GEN_FRAGILE_NATURE_ASSETS);
+ var scale = 0.9 + 0.2 * Math.random();
+ self.attachAsset('fragileNature' + fragileNatureIndex, {
+ 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);
+ }
+ };
+ return self;
+});
var DetritusFlying = ConfigContainer.expand(function (config) {
var self = ConfigContainer.call(this, config);
var detritusFlyingIndex = Math.floor(Math.random() * ROAD_GEN_DETRITUS_FLYING_ASSETS);
var scale = 0.9 + 0.2 * Math.random();
@@ -601,25 +652,25 @@
scaleY: scale
});
self.update = function () {
if (self.taken) {
- var targetX = 150;
- var targetY = 1700;
+ 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.scaleX *= 0.98;
- self.scaleY *= 0.98;
+ self.scale.x *= 0.998;
+ self.scale.y *= 0.998;
} else {
self.x = targetX;
self.y = targetY;
self.destroy();
}
- } else if (!self.taken && player.intersects(self)) {
+ } 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);
@@ -643,25 +694,25 @@
});
self.taken = false;
self.update = function () {
if (self.taken) {
- var targetX = 150;
- var targetY = 1700;
+ 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.scaleX *= 0.98;
- self.scaleY *= 0.98;
+ self.scale.x *= 0.9975;
+ self.scale.y *= 0.9975;
} else {
self.x = targetX;
self.y = targetY;
self.destroy();
}
- } else if (!self.taken && player.intersects(self)) {
+ } 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);
@@ -819,8 +870,10 @@
var ROAD_GEN_DETRITUS_ASSETS = 2;
var ROAD_GEN_DETRITUS_CHANCE = 0.05;
var ROAD_GEN_DETRITUS_FLYING_ASSETS = 2;
var ROAD_GEN_DETRITUS_FLYING_CHANCE = 0.05;
+var ROAD_GEN_FRAGILE_NATURE_ASSETS = 1;
+var ROAD_GEN_FRAGILE_NATURE_CHANCE = 0.05;
;
// Player Constants
var PLAYER_SPACING = ROAD_SEGMENT_ANGLE / 8; // 1/8 of a segment
var PLAYER_POSE_TRANSITION = 0.1;
@@ -895,8 +948,9 @@
y: road.y + TEXT_DEFAULT_SIZE,
anchorX: 0.5,
anchorY: 0
}));
+multiplierText.visible = false;
var incrementText = game.addChild(new BorderedText('', {
x: road.x - 300,
y: road.y,
anchorX: 1,
@@ -913,11 +967,11 @@
;
var recycleBin = game.addChild(LK.getAsset('recycleBin', {
anchorX: 0.5,
anchorY: 0.5,
- x: 150,
+ x: 250,
//450,
- y: 1700
+ y: 1750
}));
;
//==============================================================================
// Global events
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.