Code edit (18 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Uncaught ReferenceError: sel is not defined' in or related to this line: 'self.x = sel.x;' Line Number: 24
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: 'ReferenceError: particleGraphics is not defined' in or related to this line: 'if (particleGraphics.alpha <= 0) {' Line Number: 247
Code edit (1 edits merged)
Please save this source code
Code edit (5 edits merged)
Please save this source code
User prompt
please implement it that way
Code edit (5 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: movetype is not defined' in or related to this line: 'if (movetype == 0) {' Line Number: 119
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 (12 edits merged)
Please save this source code
User prompt
use LK to increment score
User prompt
INcrement player score by 1 where it says '//TODO: Increment score.'
Code edit (1 edits merged)
Please save this source code
Code edit (23 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'tint')' in or related to this line: 'if (this.starGraphics.tint == currentPalette[currentRightColor]) {' Line Number: 118
Code edit (1 edits merged)
Please save this source code
Code edit (10 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Uncaught ReferenceError: Square is not defined' in or related to this line: 'var square = new Square(j);' Line Number: 187
Code edit (1 edits merged)
Please save this source code
===================================================================
--- original.js
+++ change.js
@@ -1,20 +1,23 @@
/****
* Classes
****/
// Square class
-var Square = Container.expand(function (index) {
+var Square = Container.expand(function () {
var self = Container.call(this);
var squareGraphics = self.attachAsset('square', {
- anchorX: 0.5,
- anchorY: 0.5,
- tint: currentPalette[Math.floor(Math.random() * currentPalette.length)]
+ anchorX: 0,
+ anchorY: 0
+ //tint: currentPalette[Math.floor(Math.random() * currentPalette.length)]
});
self.init = function (index) {
- self.x = index * 24 + 12;
- self.y = game.height - 24;
+ self.width = game.width / (currentPalette.length - 1);
+ self.height = 200;
+ self.x = index * self.width;
+ self.y = game.height - 200;
+ squareGraphics.tint = currentPalette[index];
};
- self.init();
+ //self.init();
});
// Star class
var Star = Container.expand(function () {
var self = Container.call(this);
@@ -25,9 +28,9 @@
//tint: colorArray[colorArrayCounter++ % colorArray.length]
//tint: rainbowColors[Math.floor(Math.random() * rainbowColors.length - 1)]
//tint: customColorsVibin[Math.floor(Math.random() * customColorsVibin.length - 1)]
//tint: galacticGreen[Math.floor(Math.random() * galacticGreen.length)]
- tint: currentPalette[Math.floor(Math.random() * currentPalette.length)]
+ tint: currentPalette[Math.floor(Math.random() * (currentPalette.length - 1))]
});
self.init = function () {
//console.log(self.tint);
// Initialize star position closer to the center for a 3D effect
@@ -146,9 +149,9 @@
}();
var customColorsVibin = ["0xeffbf9", "0x0b152e", "0x194471", "0x1b7eb4", "0x11bbd9", "0x0f5434", "0x127d2c", "0x1a9f25", "0x60d12b", "0x162a2e", "0x2d4747", "0x3b6058", "0x577d6f", "0x13353b", "0x205858", "0x2d7d75", "0x57ab96", "0x67978c", "0x83b09c", "0xa9d5bb", "0xdbf2df", "0xbc5132", "0xd97840", "0xe29e3f", "0xfbca6b", "0xb03502", "0xcd6d07", "0xea9b06", "0xf2cc2c", "0x60212b", "0x8a331d", "0xb46d23", "0xd9a744", "0x64112a", "0x961b2d", "0xc02038", "0xf23a3a", "0x301d32", "0x6f1771", "0xbc1a8d", "0xf23e9a", "0x433933", "0x585047", "0x7d705c", "0x9b9172", "0x003a5c", "0x03668e", "0x0d8cb0", "0x18abc4", "0xd138a0", "0xea5699", "0xf78c9d", "0xfbb495", "0xa76372", "0xc98a9c", "0xe6acc1", "0xf2bed1", "0x16111d"];
var galacticGreen = ["0xe8f1a6", "0xcad670", "0xa3c255", "0x6fa341", "0x498f45", "0x387450", "0x2d5c56", "0x1f3741", "0x1e2029", "0x16161c"];
var berryNebula = ["0x6ceded", "0x6cb9c9", "0x6d85a5", "0x6e5181", "0x6f1d5c", "0x4f1446", "0x2e0a30", "0x0d001a"];
-var currentPalette = customColorsVibin;
+var currentPalette = berryNebula;
game.setBackgroundColor(currentPalette[currentPalette.length - 1]);
/*
// Create a text label with a warning message
var warningTxt = new Text2('Captain?! Please confirm order to keep accelerating!?\nWe are approaching very dangerous speeds!\nAnd where the HELL are we actually going?', {
@@ -174,8 +177,9 @@
var pos = obj.event.getLocalPosition(game);
targetX = pos.x;
targetY = pos.y;
tweenProgress = 0;
+ currentPalette = galacticGreen;
});
LK.on('tick', function () {
if (tweenProgress < tweenDuration) {
centerX += (targetX - centerX) / (tweenDuration - tweenProgress);
@@ -190,10 +194,11 @@
stars.push(star);
game.addChild(star);
}
var squares = [];
-for (var j = 0; j < currentPalette.length; j++) {
- var square = new Square(j);
+for (var j = 0; j < currentPalette.length - 1; j++) {
+ var square = new Square();
+ square.init(j);
squares.push(square);
game.addChild(square);
}
var score = 0;
@@ -206,50 +211,8 @@
LK.gui.top.addChild(scoreTxt);
// Drag character
// Game tick
LK.on('tick', function () {
- // Spawn obstacles and stars
- // Update tick counter for background color change
- /*
- colorChangeTick++;
- if (colorChangeTick >= colorChangeInterval) {
- // Adjust color components based on direction
- // Randomize each color channel separately
- bgColor.r = Math.floor(Math.random() * 256);
- bgColor.g = Math.floor(Math.random() * 256);
- bgColor.b = Math.floor(Math.random() * 256);
- // Function to convert RGB to hexadecimal format
- var newBgColor = rgbToHex(bgColor.r, bgColor.g, bgColor.b);
- // Apply the new background color
- game.setBackgroundColor(newBgColor);
- // Reset tick counter
- colorChangeTick = 0;
- }*/
- //centerX += Math.cos(colorChangeTick % 2000) * 3;
- //centerY += Math.sin(colorChangeTick % 2000) * 3;
stars.forEach(function (star, index) {
- /*
- // Calculate the direction vector from the center to the star
- var dx = star.x - centerX;
- var dy = star.y - centerY;
- // Normalize the direction vector
- var length = Math.sqrt(dx * dx + dy * dy);
- dx /= length;
- dy /= length;
- */
- // Set the star's velocity to the direction vector
- // Incorporate deltaTime to ensure frame-rate independent movement
- // Remove deltaTime calculation and directly update star position
star.move();
- //star.move();
- // R'eset star position and properties when it moves offscreen
- // Correctly use star instead of self for resetting star properties
- /*
- if (star.z <= 0 || star.x < -game.width || star.x > game.width * 2 || star.y < -game.height || star.y > game.height * 2) {
- star.z = Math.random() * 1900 + 100; // Ensure stars start further away
- star.x = (Math.random() - 0.5) * game.width * 2;
- star.y = (Math.random() - 0.5) * game.height * 2;
- star.speed = Math.min(20 + Math.random() * 10, 30); // Adjust speed for a more dynamic effect
- }
- */
});
});
\ No newline at end of file
A white triangle pointing down.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A colorful rectangular button with the text "Play Again" with each letter in a different color picked from a nice palette.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.