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
User prompt
now for jump action detect a swipe up using down and move events
Code edit (1 edits merged)
Please save this source code
Code edit (3 edits merged)
Please save this source code
User prompt
Add a new class BoilingLava that emits lava bubbles (circle asset)
User prompt
Play lose sound when touching river
User prompt
Play jump sound when jumping
Code edit (1 edits merged)
Please save this source code
User prompt
add a red flash if fall in the river
Code edit (8 edits merged)
Please save this source code
User prompt
if player fall in the river call gameover
Code edit (1 edits merged)
Please save this source code
Code edit (9 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: road is undefined' in or related to this line: 'if (Math.random() < ROAD_GEN_DETRITUS_CHANCE) {' Line Number: 183
User prompt
Please fix the bug: 'TypeError: road is undefined' in or related to this line: 'if (Math.random() < ROAD_GEN_DETRITUS_CHANCE) {' Line Number: 183
Code edit (1 edits merged)
Please save this source code
User prompt
play bgMusic in loop
Code edit (9 edits merged)
Please save this source code
User prompt
play collectDetritus when taking a detritus
Code edit (1 edits merged)
Please save this source code
===================================================================
--- original.js
+++ change.js
@@ -3,38 +3,39 @@
****/
var BoilingLava = Container.expand(function () {
var self = Container.call(this);
var lavaBubbles = [];
+ self.x = 400;
+ self.y = 400;
// Function to create a new lava bubble
function createLavaBubble() {
- var bubble = self.attachAsset('circle', {
+ var bubble = self.attachAsset('lavaBubble', {
anchorX: 0.5,
anchorY: 0.5,
- scaleX: 0.5,
- scaleY: 0.5
- //x: Math.random() * 200 - 100,
+ scaleX: 1,
+ scaleY: 1,
+ x: Math.random() * 200 - 100,
// Random x position within a range
- //y: Math.random() * 200 - 100 // Random y position within a range
+ y: Math.random() * 200 - 100 // Random y position within a range
});
lavaBubbles.push(bubble);
}
// Update function to animate the lava bubbles
self.update = function () {
- if (LK.ticks % 60 == 0) {
+ if (LK.ticks % 20 == 0) {
// Emit a bubble every second
createLavaBubble();
}
for (var i = lavaBubbles.length - 1; i >= 0; i--) {
var bubble = lavaBubbles[i];
- bubble.y -= 20; // Move bubble upwards
- bubble.alpha -= 0.002; // Fade out bubble
+ bubble.y -= 2; // Move bubble upwards
+ bubble.alpha -= 0.02; // Fade out bubble
if (bubble.alpha <= 0) {
bubble.destroy();
lavaBubbles.splice(i, 1);
}
}
};
- createLavaBubble();
return self;
});
/**
* config {
@@ -93,8 +94,9 @@
});
var RoadSegment = ConfigContainer.expand(function (config) {
var self = ConfigContainer.call(this, config);
var background = self.addChild(new Container());
+ self.background = background;
self.attachAsset('roadSegment', {
anchorX: 1,
anchorY: 1,
tint: 0x62C344
@@ -206,21 +208,14 @@
road.riverSegmentCount++;
self.previous.isRiver = true;
self.previous.segmentRiver.visible = true;
road.riverSegmentCount++;
- /*
- 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: 0,
- levitOffset: 125
+ attachObjectRadial(background, new BoilingLava(), {
+ anchorR: 0.1 + 0.8 * Math.random()
});
- */
+ attachObjectRadial(self.previous.background, new BoilingLava(), {
+ anchorR: 0.1 + 0.8 * Math.random()
+ });
} 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();
@@ -964,8 +959,9 @@
var winningTime = 0;
var gameOver = false;
var distanceRemaining = SCORE_TOTAL_DISTANCE;
;
+var startY = 0; // Variable to store the initial Y position for swipe detection
// Instances
var background = game.addChild(LK.getAsset('background', {
anchorX: 0.5,
anchorY: 0.5,
@@ -1032,18 +1028,30 @@
//450,
y: 1750
}));
;
-var boilingLava = game.addChild(new BoilingLava({
- x: 400,
- y: 400
-}));
+/*
+var boilingLava = game.addChild(new BoilingLava());
+boilingLava.x = 600;
+boilingLava.y = 600;
+*/
//==============================================================================
// Global events
//==============================================================================
;
-game.down = player.jumpStart;
-game.up = player.jumpEnd;
+var startY = 0;
+game.down = function (x, y, obj) {
+ startY = y;
+};
+game.move = function (x, y, obj) {
+ if (startY - y > 50) {
+ // Detect swipe up
+ player.jumpStart();
+ }
+};
+game.up = function (x, y, obj) {
+ player.jumpEnd();
+};
;
//==============================================================================
// Global functions
//==============================================================================
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.