User prompt
Now make it so it saves your progress, so everytime you refresh the page it saves your wave, and gold βͺπ‘ Consider importing and using the following plugins: @upit/storage.v1
User prompt
Make it so everytime you survive a wave you get + 10 gold
User prompt
Now make a gold currency. Make a text under the wave text and make it say gold
User prompt
Make the text bigger
User prompt
And put a text in the rate asset saying Rate 1s
User prompt
Move it a little down and to the right
User prompt
Now move it a lot to the left
User prompt
Move it more down
User prompt
Move the rate asset down
User prompt
Make the rate asset bigger
User prompt
Add the rate asset
User prompt
Make it so every wave, the cube's speed gles up by 0.5%
User prompt
Ok make the waves go up once every 10 seconds
User prompt
When the game starts only spawn 5 cube assets
User prompt
ONLY 5!
User prompt
No only 5 on wave 1
User prompt
Make the cubes spawn
User prompt
Now they do not spawn anymore
User prompt
Ok but not all at once, make them spawn in one by one with a 1 second cooldown βͺπ‘ Consider importing and using the following plugins: @upit/tween.v1
User prompt
Please fix the bug: 'undefined is not an object (evaluating 'cubestart.x')' in or related to this line: 'newCube.x = cubestart.x;' Line Number: 97
User prompt
When the game starts, spawn in 5 cube assets
User prompt
The cube assets arent spawning in wave 1
User prompt
When wave equals 1 spawn only 5 cube assets
User prompt
Now, when the game starts make the wave equal to 1
User prompt
Stop the cubes from spawning
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
// Create a new class for the cube asset
var Cube = Container.expand(function () {
var self = Container.call(this);
// Attach the cube asset to the Cube class
var cubeGraphics = self.attachAsset('Cube', {
anchorX: 0.5,
anchorY: 0.5
});
// Set the cube's speed
self.speed = 3;
// Increase cube's speed by 0.5% every wave
self.update = function () {
self.speed += self.speed * 0.005 * waveText.wave;
};
// Set the cube's health
self.health = 1;
// Set the cube's health
self.health = 1;
// Update the cube's position every game tick
self.update = function () {
// Calculate the distance between the cube and the slime
var dx = slime.x - self.x;
var dy = slime.y - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
// Normalize the direction vector (dx and dy)
dx /= distance;
dy /= distance;
// Move the cube towards the slime at a constant speed
self.x += dx * self.speed;
self.y += dy * self.speed;
};
});
// Create a new class for the shoot asset
var Shoot = Container.expand(function () {
var self = Container.call(this);
// Attach the shoot asset to the Shoot class
var shootGraphics = self.attachAsset('Shoot', {
anchorX: 0.5,
anchorY: 0.5
});
// Set the shoot's speed
self.speed = 5;
// Set the shoot's damage
self.damage = 1;
// Set the shoot's damage
self.damage = 1;
// Update the shoot's position every game tick
self.update = function () {
// Move the shoot to the right at a constant speed
self.x += self.speed;
};
});
// Create a new class for the wave text
var WaveText = Text2.expand(function () {
var self = Text2.call(this, 'Wave: 0', {
size: 100,
fill: 0xFFFFFF
});
self.anchor.set(0, 0);
self.x = 50;
self.y = 50;
self.wave = 0;
self.update = function () {
self.setText('Wave: ' + self.wave);
};
});
/****
* Initialize Game
****/
// Spawn the cube asset from the cubestart asset every 60 game ticks
//<Assets used in the game will automatically appear here>
var game = new LK.Game({
backgroundColor: 0x008000 //Init game with green background
});
/****
* Game Code
****/
// Add slime asset to the game screen, make it 2x bigger and move it to the left
// Spawn the cube asset from the cubestart asset every 60 game ticks
//<Assets used in the game will automatically appear here>
var slime = game.addChild(LK.getAsset('Slime', {
anchorX: 0.5,
anchorY: 0.5,
x: 200,
y: 1350,
// Adjusted y position to move the slime down a little
scaleX: 2,
scaleY: 2
}));
// Add menu asset to the game screen
var menu = game.addChild(LK.getAsset('Menu', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 2766,
scaleX: 25,
scaleY: 25
}));
// Add rate asset to the game screen and make it bigger
var rate = game.addChild(LK.getAsset('Rate', {
anchorX: 0.5,
anchorY: 0.5,
x: 250,
// Moved a little to the right
y: 1816,
// Moved a little down
scaleX: 4,
scaleY: 4
}));
// Add text to the rate asset
var rateText = new Text2('Rate 1s', {
size: 50,
fill: 0xFFFFFF
});
rateText.anchor.set(0.5, 0.5);
rateText.x = rate.x;
rateText.y = rate.y;
game.addChild(rateText);
// Add cubestart asset to the game screen
var cubestart = game.addChild(LK.getAsset('Cubesstart', {
anchorX: 0.5,
anchorY: 0.5,
x: 1800,
// Moved to the right by a lot
y: 1366,
scaleX: 2,
scaleY: 2
}));
// Add the wave text to the game screen
var waveText = game.addChild(new WaveText());
game.update = function () {
// Spawn the cube asset from the cubestart asset every 60 game ticks
if (LK.ticks % 60 == 0) {
var newCube = new Cube();
newCube.x = cubestart.x;
newCube.y = cubestart.y;
game.addChild(newCube);
}
// Update the wave text every 600 game ticks
if (LK.ticks % 600 == 0) {
waveText.wave++;
}
// Make the slime asset shoot out the shoot asset to the right once every second
if (LK.ticks % 60 == 0) {
var newShoot = new Shoot();
newShoot.x = slime.x;
newShoot.y = slime.y;
newShoot.update = function () {
// Move the shoot to the right at a constant speed
this.x += this.speed;
};
game.addChild(newShoot);
}
// Check for collisions between Cube and Shoot objects
for (var i = 0; i < game.children.length; i++) {
var obj1 = game.children[i];
if (obj1 instanceof Cube) {
for (var j = 0; j < game.children.length; j++) {
var obj2 = game.children[j];
if (obj2 instanceof Shoot && obj1.intersects(obj2)) {
// Destroy both objects on collision
obj1.destroy();
obj2.destroy();
break;
}
}
}
}
}; ===================================================================
--- original.js
+++ change.js
@@ -116,8 +116,17 @@
// Moved a little down
scaleX: 4,
scaleY: 4
}));
+// Add text to the rate asset
+var rateText = new Text2('Rate 1s', {
+ size: 50,
+ fill: 0xFFFFFF
+});
+rateText.anchor.set(0.5, 0.5);
+rateText.x = rate.x;
+rateText.y = rate.y;
+game.addChild(rateText);
// Add cubestart asset to the game screen
var cubestart = game.addChild(LK.getAsset('Cubesstart', {
anchorX: 0.5,
anchorY: 0.5,