User prompt
remove powerups, make the falling objects appear less frequency and in a continuous stream
User prompt
the bucket is now a mouth so i will be referring to it as a mouth going forwards - make the score increment every time the mouth touches an item
User prompt
Put the bucket on my head
User prompt
Implement facekit with a bucket on your head āŖš” Consider importing and using the following plugins: @upit/facekit.v1
Initial prompt
Bucket Head
/****
* Plugins
****/
var facekit = LK.import("@upit/facekit.v1");
/****
* Classes
****/
// Class for the Bucket (Player)
var Bucket = Container.expand(function () {
var self = Container.call(this);
var bucketGraphics = self.attachAsset('bucket', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
self.x = facekit.mouthCenter.x;
};
});
// Class for Falling Objects
var FallingObject = Container.expand(function () {
var self = Container.call(this);
var objectGraphics = self.attachAsset('fallingObject', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 5;
self.update = function () {
self.y += self.speed;
};
});
// Class for Power-ups
var PowerUp = Container.expand(function () {
var self = Container.call(this);
var powerUpGraphics = self.attachAsset('powerUp', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 3;
self.update = function () {
self.y += self.speed;
};
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000 //Init game with black background
});
/****
* Game Code
****/
//<Assets used in the game will automatically appear here>
// Initialize game elements
var bucket = game.addChild(new Bucket());
bucket.x = 2048 / 2;
bucket.y = 2500;
var fallingObjects = [];
var powerUps = [];
// Handle game move events
game.move = function (x, y, obj) {
bucket.x = x;
};
// Update game logic
game.update = function () {
// Update falling objects
for (var i = fallingObjects.length - 1; i >= 0; i--) {
var obj = fallingObjects[i];
obj.update();
if (obj.y > 2732) {
obj.destroy();
fallingObjects.splice(i, 1);
} else if (obj.intersects(bucket)) {
// Handle catching object
obj.destroy();
fallingObjects.splice(i, 1);
LK.setScore(LK.getScore() + 1);
}
}
// Update power-ups
for (var j = powerUps.length - 1; j >= 0; j--) {
var powerUp = powerUps[j];
powerUp.update();
if (powerUp.y > 2732) {
powerUp.destroy();
powerUps.splice(j, 1);
} else if (powerUp.intersects(bucket)) {
// Handle catching power-up
powerUp.destroy();
powerUps.splice(j, 1);
// Implement power-up effect
}
}
// Spawn new falling objects
if (facekit.volume > 0.3) {
var newObject = new FallingObject();
newObject.x = Math.random() * 2048;
newObject.y = 0;
fallingObjects.push(newObject);
game.addChild(newObject);
}
// Spawn new power-ups
if (LK.ticks % 300 == 0) {
var newPowerUp = new PowerUp();
newPowerUp.x = Math.random() * 2048;
newPowerUp.y = 0;
powerUps.push(newPowerUp);
game.addChild(newPowerUp);
}
};
// Display score
var scoreTxt = new Text2('0', {
size: 150,
fill: 0xFFFFFF
});
scoreTxt.setText(LK.getScore());
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt); ===================================================================
--- original.js
+++ change.js
@@ -1,116 +1,120 @@
-/****
+/****
+* Plugins
+****/
+var facekit = LK.import("@upit/facekit.v1");
+
+/****
* Classes
-****/
-//<Assets used in the game will automatically appear here>
-//<Write imports for supported plugins here>
+****/
// Class for the Bucket (Player)
var Bucket = Container.expand(function () {
- var self = Container.call(this);
- var bucketGraphics = self.attachAsset('bucket', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- self.update = function () {
- // Update logic for the bucket if needed
- };
+ var self = Container.call(this);
+ var bucketGraphics = self.attachAsset('bucket', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.update = function () {
+ self.x = facekit.mouthCenter.x;
+ };
});
// Class for Falling Objects
var FallingObject = Container.expand(function () {
- var self = Container.call(this);
- var objectGraphics = self.attachAsset('fallingObject', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- self.speed = 5;
- self.update = function () {
- self.y += self.speed;
- };
+ var self = Container.call(this);
+ var objectGraphics = self.attachAsset('fallingObject', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.speed = 5;
+ self.update = function () {
+ self.y += self.speed;
+ };
});
// Class for Power-ups
var PowerUp = Container.expand(function () {
- var self = Container.call(this);
- var powerUpGraphics = self.attachAsset('powerUp', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- self.speed = 3;
- self.update = function () {
- self.y += self.speed;
- };
+ var self = Container.call(this);
+ var powerUpGraphics = self.attachAsset('powerUp', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.speed = 3;
+ self.update = function () {
+ self.y += self.speed;
+ };
});
-/****
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000 //Init game with black background
+ backgroundColor: 0x000000 //Init game with black background
});
-/****
+/****
* Game Code
-****/
+****/
+//<Assets used in the game will automatically appear here>
// Initialize game elements
var bucket = game.addChild(new Bucket());
bucket.x = 2048 / 2;
bucket.y = 2500;
var fallingObjects = [];
var powerUps = [];
// Handle game move events
game.move = function (x, y, obj) {
- bucket.x = x;
+ bucket.x = x;
};
// Update game logic
game.update = function () {
- // Update falling objects
- for (var i = fallingObjects.length - 1; i >= 0; i--) {
- var obj = fallingObjects[i];
- obj.update();
- if (obj.y > 2732) {
- obj.destroy();
- fallingObjects.splice(i, 1);
- } else if (obj.intersects(bucket)) {
- // Handle catching object
- obj.destroy();
- fallingObjects.splice(i, 1);
- LK.setScore(LK.getScore() + 1);
- }
- }
- // Update power-ups
- for (var j = powerUps.length - 1; j >= 0; j--) {
- var powerUp = powerUps[j];
- powerUp.update();
- if (powerUp.y > 2732) {
- powerUp.destroy();
- powerUps.splice(j, 1);
- } else if (powerUp.intersects(bucket)) {
- // Handle catching power-up
- powerUp.destroy();
- powerUps.splice(j, 1);
- // Implement power-up effect
- }
- }
- // Spawn new falling objects
- if (LK.ticks % 60 == 0) {
- var newObject = new FallingObject();
- newObject.x = Math.random() * 2048;
- newObject.y = 0;
- fallingObjects.push(newObject);
- game.addChild(newObject);
- }
- // Spawn new power-ups
- if (LK.ticks % 300 == 0) {
- var newPowerUp = new PowerUp();
- newPowerUp.x = Math.random() * 2048;
- newPowerUp.y = 0;
- powerUps.push(newPowerUp);
- game.addChild(newPowerUp);
- }
+ // Update falling objects
+ for (var i = fallingObjects.length - 1; i >= 0; i--) {
+ var obj = fallingObjects[i];
+ obj.update();
+ if (obj.y > 2732) {
+ obj.destroy();
+ fallingObjects.splice(i, 1);
+ } else if (obj.intersects(bucket)) {
+ // Handle catching object
+ obj.destroy();
+ fallingObjects.splice(i, 1);
+ LK.setScore(LK.getScore() + 1);
+ }
+ }
+ // Update power-ups
+ for (var j = powerUps.length - 1; j >= 0; j--) {
+ var powerUp = powerUps[j];
+ powerUp.update();
+ if (powerUp.y > 2732) {
+ powerUp.destroy();
+ powerUps.splice(j, 1);
+ } else if (powerUp.intersects(bucket)) {
+ // Handle catching power-up
+ powerUp.destroy();
+ powerUps.splice(j, 1);
+ // Implement power-up effect
+ }
+ }
+ // Spawn new falling objects
+ if (facekit.volume > 0.3) {
+ var newObject = new FallingObject();
+ newObject.x = Math.random() * 2048;
+ newObject.y = 0;
+ fallingObjects.push(newObject);
+ game.addChild(newObject);
+ }
+ // Spawn new power-ups
+ if (LK.ticks % 300 == 0) {
+ var newPowerUp = new PowerUp();
+ newPowerUp.x = Math.random() * 2048;
+ newPowerUp.y = 0;
+ powerUps.push(newPowerUp);
+ game.addChild(newPowerUp);
+ }
};
// Display score
var scoreTxt = new Text2('0', {
- size: 150,
- fill: 0xFFFFFF
+ size: 150,
+ fill: 0xFFFFFF
});
scoreTxt.setText(LK.getScore());
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
\ No newline at end of file