User prompt
Create a game named "Aloo Khaoge?" where potato is the main character of the game and the background of game has a gaussian blured picture of any youtube comment section and from all sides comments like "Subscribe or you will fail in exam" , "Thank you so much for so many likes" , "Mom I am famous" , "Thank you for 100 subscribers" are attacking the potato and the potato has to defend himself by using a gun which will kill these comments and with each kill the player will get 10 points.Game will only end when the any of the comment will touch the potato ↪💡 Consider importing and using the following plugins: @upit/tween.v1
Code edit (1 edits merged)
Please save this source code
User prompt
Aloo Khaoge?
Initial prompt
Create a game named "Aloo Khaoge?" where potato is the main character of the game and the background of game has a gaussian blured picture of any youtube comment section and from all sides comments like "Subscribe or you will fail in exam" , "Thank you so much for so many likes" , "Mom I am famous" , "Thank you for 100 subscribers" are attacking the potato and the potato has to defend himself by using a gun which will kill these comments and with each kill the player will get 10 points.Game will only end when the any of the comment will touch the potato
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Bullet = Container.expand(function () {
var self = Container.call(this);
var bulletGraphics = self.attachAsset('bullet', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 15;
self.targetX = 0;
self.targetY = 0;
self.directionX = 0;
self.directionY = 0;
self.update = function () {
self.x += self.directionX * self.speed;
self.y += self.directionY * self.speed;
};
return self;
});
var Comment = Container.expand(function () {
var self = Container.call(this);
var commentBox = self.attachAsset('comment', {
anchorX: 0.5,
anchorY: 0.5
});
var commentTexts = ["Subscribe or you will fail in exam", "Thank you for 100 subscribers", "Mom I am famous", "First!", "Like if you agree", "Who's watching in 2024?", "Am I the only one who...", "This comment will get 1000 likes", "Edit: Thanks for the likes!", "Nobody: Literally nobody:", "Can we get 50 likes?", "Your content is trash"];
var commentText = new Text2(commentTexts[Math.floor(Math.random() * commentTexts.length)], {
size: 24,
fill: 0x000000
});
commentText.anchor.set(0.5, 0.5);
self.addChild(commentText);
self.speed = 2 + Math.random() * 3;
self.targetX = 0;
self.targetY = 0;
self.directionX = 0;
self.directionY = 0;
self.update = function () {
self.x += self.directionX * self.speed;
self.y += self.directionY * self.speed;
};
return self;
});
var Potato = Container.expand(function () {
var self = Container.call(this);
var potatoGraphics = self.attachAsset('potato', {
anchorX: 0.5,
anchorY: 0.5
});
// Add simple eyes
var leftEye = LK.getAsset('bullet', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.3,
scaleY: 0.3
});
leftEye.tint = 0x000000;
leftEye.x = -20;
leftEye.y = -10;
self.addChild(leftEye);
var rightEye = LK.getAsset('bullet', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.3,
scaleY: 0.3
});
rightEye.tint = 0x000000;
rightEye.x = 20;
rightEye.y = -10;
self.addChild(rightEye);
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x2a2a2a
});
/****
* Game Code
****/
// Create blurred background
var background = game.addChild(LK.getAsset('background', {
anchorX: 0,
anchorY: 0,
alpha: 0.3
}));
// Create potato player
var potato = game.addChild(new Potato());
potato.x = 1024;
potato.y = 1800;
// Game arrays
var bullets = [];
var comments = [];
// Game variables
var commentSpawnTimer = 0;
var commentSpawnRate = 90; // Frames between spawns
var gameSpeed = 1;
// UI
var scoreTxt = new Text2('Score: 0', {
size: 80,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
// Shooting variables
var isShooting = false;
var shootCooldown = 0;
// Track last intersection states
var lastCommentIntersections = [];
function spawnComment() {
var comment = new Comment();
var side = Math.floor(Math.random() * 4); // 0=top, 1=right, 2=bottom, 3=left
switch (side) {
case 0:
// top
comment.x = Math.random() * 2048;
comment.y = -50;
break;
case 1:
// right
comment.x = 2098;
comment.y = Math.random() * 2732;
break;
case 2:
// bottom
comment.x = Math.random() * 2048;
comment.y = 2782;
break;
case 3:
// left
comment.x = -50;
comment.y = Math.random() * 2732;
break;
}
// Calculate direction toward potato
var dx = potato.x - comment.x;
var dy = potato.y - comment.y;
var distance = Math.sqrt(dx * dx + dy * dy);
comment.directionX = dx / distance;
comment.directionY = dy / distance;
comments.push(comment);
game.addChild(comment);
}
function shootBullet(targetX, targetY) {
if (shootCooldown > 0) return;
var bullet = new Bullet();
bullet.x = potato.x;
bullet.y = potato.y;
// Calculate direction
var dx = targetX - bullet.x;
var dy = targetY - bullet.y;
var distance = Math.sqrt(dx * dx + dy * dy);
bullet.directionX = dx / distance;
bullet.directionY = dy / distance;
bullets.push(bullet);
game.addChild(bullet);
LK.getSound('shoot').play();
shootCooldown = 10;
}
// Game controls
var dragTarget = null;
game.down = function (x, y, obj) {
dragTarget = potato;
shootBullet(x, y);
};
game.move = function (x, y, obj) {
if (dragTarget) {
dragTarget.x = Math.max(60, Math.min(1988, x));
dragTarget.y = Math.max(60, Math.min(2672, y));
}
};
game.up = function (x, y, obj) {
dragTarget = null;
};
game.update = function () {
// Update shoot cooldown
if (shootCooldown > 0) {
shootCooldown--;
}
// Spawn comments
commentSpawnTimer++;
if (commentSpawnTimer >= commentSpawnRate) {
spawnComment();
commentSpawnTimer = 0;
// Gradually increase difficulty
if (commentSpawnRate > 30) {
commentSpawnRate -= 0.5;
}
}
// Update bullets
for (var i = bullets.length - 1; i >= 0; i--) {
var bullet = bullets[i];
// Check if bullet is off screen
if (bullet.x < -50 || bullet.x > 2098 || bullet.y < -50 || bullet.y > 2782) {
bullet.destroy();
bullets.splice(i, 1);
continue;
}
// Check bullet-comment collisions
var bulletHit = false;
for (var j = comments.length - 1; j >= 0; j--) {
var comment = comments[j];
if (bullet.intersects(comment)) {
// Hit!
LK.getSound('hit').play();
LK.setScore(LK.getScore() + 10);
scoreTxt.setText('Score: ' + LK.getScore());
// Flash effect
tween(comment, {
alpha: 0
}, {
duration: 200
});
// Remove both bullet and comment
bullet.destroy();
bullets.splice(i, 1);
comment.destroy();
comments.splice(j, 1);
bulletHit = true;
break;
}
}
if (bulletHit) continue;
}
// Update comments and check potato collisions
for (var k = comments.length - 1; k >= 0; k--) {
var comment = comments[k];
// Initialize last intersection state if needed
if (lastCommentIntersections[k] === undefined) {
lastCommentIntersections[k] = false;
}
// Check potato collision
var currentIntersecting = comment.intersects(potato);
if (!lastCommentIntersections[k] && currentIntersecting) {
// Game over!
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
return;
}
lastCommentIntersections[k] = currentIntersecting;
// Remove comments that are too far off screen
if (comment.x < -200 || comment.x > 2248 || comment.y < -200 || comment.y > 2932) {
comment.destroy();
comments.splice(k, 1);
lastCommentIntersections.splice(k, 1);
}
}
// Update score display
scoreTxt.setText('Score: ' + LK.getScore());
}; ===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,259 @@
-/****
+/****
+* Plugins
+****/
+var tween = LK.import("@upit/tween.v1");
+
+/****
+* Classes
+****/
+var Bullet = Container.expand(function () {
+ var self = Container.call(this);
+ var bulletGraphics = self.attachAsset('bullet', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.speed = 15;
+ self.targetX = 0;
+ self.targetY = 0;
+ self.directionX = 0;
+ self.directionY = 0;
+ self.update = function () {
+ self.x += self.directionX * self.speed;
+ self.y += self.directionY * self.speed;
+ };
+ return self;
+});
+var Comment = Container.expand(function () {
+ var self = Container.call(this);
+ var commentBox = self.attachAsset('comment', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ var commentTexts = ["Subscribe or you will fail in exam", "Thank you for 100 subscribers", "Mom I am famous", "First!", "Like if you agree", "Who's watching in 2024?", "Am I the only one who...", "This comment will get 1000 likes", "Edit: Thanks for the likes!", "Nobody: Literally nobody:", "Can we get 50 likes?", "Your content is trash"];
+ var commentText = new Text2(commentTexts[Math.floor(Math.random() * commentTexts.length)], {
+ size: 24,
+ fill: 0x000000
+ });
+ commentText.anchor.set(0.5, 0.5);
+ self.addChild(commentText);
+ self.speed = 2 + Math.random() * 3;
+ self.targetX = 0;
+ self.targetY = 0;
+ self.directionX = 0;
+ self.directionY = 0;
+ self.update = function () {
+ self.x += self.directionX * self.speed;
+ self.y += self.directionY * self.speed;
+ };
+ return self;
+});
+var Potato = Container.expand(function () {
+ var self = Container.call(this);
+ var potatoGraphics = self.attachAsset('potato', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ // Add simple eyes
+ var leftEye = LK.getAsset('bullet', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 0.3,
+ scaleY: 0.3
+ });
+ leftEye.tint = 0x000000;
+ leftEye.x = -20;
+ leftEye.y = -10;
+ self.addChild(leftEye);
+ var rightEye = LK.getAsset('bullet', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 0.3,
+ scaleY: 0.3
+ });
+ rightEye.tint = 0x000000;
+ rightEye.x = 20;
+ rightEye.y = -10;
+ self.addChild(rightEye);
+ return self;
+});
+
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000
-});
\ No newline at end of file
+ backgroundColor: 0x2a2a2a
+});
+
+/****
+* Game Code
+****/
+// Create blurred background
+var background = game.addChild(LK.getAsset('background', {
+ anchorX: 0,
+ anchorY: 0,
+ alpha: 0.3
+}));
+// Create potato player
+var potato = game.addChild(new Potato());
+potato.x = 1024;
+potato.y = 1800;
+// Game arrays
+var bullets = [];
+var comments = [];
+// Game variables
+var commentSpawnTimer = 0;
+var commentSpawnRate = 90; // Frames between spawns
+var gameSpeed = 1;
+// UI
+var scoreTxt = new Text2('Score: 0', {
+ size: 80,
+ fill: 0xFFFFFF
+});
+scoreTxt.anchor.set(0.5, 0);
+LK.gui.top.addChild(scoreTxt);
+// Shooting variables
+var isShooting = false;
+var shootCooldown = 0;
+// Track last intersection states
+var lastCommentIntersections = [];
+function spawnComment() {
+ var comment = new Comment();
+ var side = Math.floor(Math.random() * 4); // 0=top, 1=right, 2=bottom, 3=left
+ switch (side) {
+ case 0:
+ // top
+ comment.x = Math.random() * 2048;
+ comment.y = -50;
+ break;
+ case 1:
+ // right
+ comment.x = 2098;
+ comment.y = Math.random() * 2732;
+ break;
+ case 2:
+ // bottom
+ comment.x = Math.random() * 2048;
+ comment.y = 2782;
+ break;
+ case 3:
+ // left
+ comment.x = -50;
+ comment.y = Math.random() * 2732;
+ break;
+ }
+ // Calculate direction toward potato
+ var dx = potato.x - comment.x;
+ var dy = potato.y - comment.y;
+ var distance = Math.sqrt(dx * dx + dy * dy);
+ comment.directionX = dx / distance;
+ comment.directionY = dy / distance;
+ comments.push(comment);
+ game.addChild(comment);
+}
+function shootBullet(targetX, targetY) {
+ if (shootCooldown > 0) return;
+ var bullet = new Bullet();
+ bullet.x = potato.x;
+ bullet.y = potato.y;
+ // Calculate direction
+ var dx = targetX - bullet.x;
+ var dy = targetY - bullet.y;
+ var distance = Math.sqrt(dx * dx + dy * dy);
+ bullet.directionX = dx / distance;
+ bullet.directionY = dy / distance;
+ bullets.push(bullet);
+ game.addChild(bullet);
+ LK.getSound('shoot').play();
+ shootCooldown = 10;
+}
+// Game controls
+var dragTarget = null;
+game.down = function (x, y, obj) {
+ dragTarget = potato;
+ shootBullet(x, y);
+};
+game.move = function (x, y, obj) {
+ if (dragTarget) {
+ dragTarget.x = Math.max(60, Math.min(1988, x));
+ dragTarget.y = Math.max(60, Math.min(2672, y));
+ }
+};
+game.up = function (x, y, obj) {
+ dragTarget = null;
+};
+game.update = function () {
+ // Update shoot cooldown
+ if (shootCooldown > 0) {
+ shootCooldown--;
+ }
+ // Spawn comments
+ commentSpawnTimer++;
+ if (commentSpawnTimer >= commentSpawnRate) {
+ spawnComment();
+ commentSpawnTimer = 0;
+ // Gradually increase difficulty
+ if (commentSpawnRate > 30) {
+ commentSpawnRate -= 0.5;
+ }
+ }
+ // Update bullets
+ for (var i = bullets.length - 1; i >= 0; i--) {
+ var bullet = bullets[i];
+ // Check if bullet is off screen
+ if (bullet.x < -50 || bullet.x > 2098 || bullet.y < -50 || bullet.y > 2782) {
+ bullet.destroy();
+ bullets.splice(i, 1);
+ continue;
+ }
+ // Check bullet-comment collisions
+ var bulletHit = false;
+ for (var j = comments.length - 1; j >= 0; j--) {
+ var comment = comments[j];
+ if (bullet.intersects(comment)) {
+ // Hit!
+ LK.getSound('hit').play();
+ LK.setScore(LK.getScore() + 10);
+ scoreTxt.setText('Score: ' + LK.getScore());
+ // Flash effect
+ tween(comment, {
+ alpha: 0
+ }, {
+ duration: 200
+ });
+ // Remove both bullet and comment
+ bullet.destroy();
+ bullets.splice(i, 1);
+ comment.destroy();
+ comments.splice(j, 1);
+ bulletHit = true;
+ break;
+ }
+ }
+ if (bulletHit) continue;
+ }
+ // Update comments and check potato collisions
+ for (var k = comments.length - 1; k >= 0; k--) {
+ var comment = comments[k];
+ // Initialize last intersection state if needed
+ if (lastCommentIntersections[k] === undefined) {
+ lastCommentIntersections[k] = false;
+ }
+ // Check potato collision
+ var currentIntersecting = comment.intersects(potato);
+ if (!lastCommentIntersections[k] && currentIntersecting) {
+ // Game over!
+ LK.effects.flashScreen(0xff0000, 1000);
+ LK.showGameOver();
+ return;
+ }
+ lastCommentIntersections[k] = currentIntersecting;
+ // Remove comments that are too far off screen
+ if (comment.x < -200 || comment.x > 2248 || comment.y < -200 || comment.y > 2932) {
+ comment.destroy();
+ comments.splice(k, 1);
+ lastCommentIntersections.splice(k, 1);
+ }
+ }
+ // Update score display
+ scoreTxt.setText('Score: ' + LK.getScore());
+};
\ No newline at end of file