===================================================================
--- original.js
+++ change.js
@@ -1,7 +1,30 @@
/****
* Classes
****/
+// Face class representing the faces
+var Face = Container.expand(function () {
+ var self = Container.call(this);
+ var faceGraphics = self.attachAsset('face', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ // Set initial speed for the face
+ self.speedX = Math.random() * 10 - 5;
+ self.speedY = Math.random() * 10 - 5;
+ // Update function to move the face
+ self.update = function () {
+ self.x += self.speedX;
+ self.y += self.speedY;
+ // Check for collision with screen boundaries and reverse direction
+ if (self.x < 0 || self.x > 2048) {
+ self.speedX *= -1;
+ }
+ if (self.y < 0 || self.y > 2732) {
+ self.speedY *= -1;
+ }
+ };
+});
// MrBeastCommand class representing Mr. Beast's command phases
var MrBeastCommand = Container.expand(function () {
var self = Container.call(this);
});
@@ -72,15 +95,20 @@
}
});
});
}
-// Initialize some targets and MrBeastCommand instances
+// Initialize some targets, faces and MrBeastCommand instances
for (var i = 0; i < 5; i++) {
var target = new Target();
target.x = Math.random() * 2048;
target.y = Math.random() * 2732;
targets.push(target);
game.addChild(target);
+ // Create a new Face instance
+ var face = new Face();
+ face.x = Math.random() * 2048;
+ face.y = Math.random() * 2732;
+ game.addChild(face);
// Create a new MrBeastCommand instance
var command = new MrBeastCommand();
// Set the position and other properties of the command
// This is just a placeholder and should be replaced with actual code