User prompt
Make a good and realistic graphic game but good
User prompt
Make a realistic bike driving game ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Create a game like a free city and our character a man can explore the full city and drive every vehicle and trains in the game
User prompt
Create a game like minecraft
Code edit (1 edits merged)
Please save this source code
User prompt
Bubble Pop Frenzy
Initial prompt
Make a game
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Bubble = Container.expand(function (type) {
var self = Container.call(this);
self.bubbleType = type || 'blue';
self.pointValue = 10;
self.speed = 2;
self.isPowerUp = false;
var assetName = 'blueBubble';
if (self.bubbleType === 'red') {
assetName = 'redBubble';
self.pointValue = 15;
} else if (self.bubbleType === 'green') {
assetName = 'greenBubble';
self.pointValue = 20;
} else if (self.bubbleType === 'yellow') {
assetName = 'yellowBubble';
self.pointValue = 25;
} else if (self.bubbleType === 'purple') {
assetName = 'purpleBubble';
self.pointValue = 30;
} else if (self.bubbleType === 'power') {
assetName = 'powerBubble';
self.pointValue = 50;
self.isPowerUp = true;
}
var bubbleGraphics = self.attachAsset(assetName, {
anchorX: 0.5,
anchorY: 0.5
});
self.floating = true;
self.down = function (x, y, obj) {
if (self.floating) {
self.floating = false;
self.pop();
}
};
self.pop = function () {
if (self.isPowerUp) {
LK.getSound('powerup').play();
activatePowerUp();
} else {
LK.getSound('pop').play();
}
LK.setScore(LK.getScore() + self.pointValue);
scoreTxt.setText(LK.getScore());
// Pop animation
tween(self, {
scaleX: 1.5,
scaleY: 1.5,
alpha: 0
}, {
duration: 200,
easing: tween.easeOut,
onFinish: function onFinish() {
self.destroy();
var index = bubbles.indexOf(self);
if (index > -1) {
bubbles.splice(index, 1);
}
}
});
};
self.update = function () {
if (self.floating) {
self.y -= self.speed;
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87CEEB
});
/****
* Game Code
****/
var bubbles = [];
var lives = 3;
var spawnTimer = 0;
var spawnRate = 60; // Initial spawn rate (frames between spawns)
var bubbleSpeed = 2;
var powerUpActive = false;
var powerUpTimer = 0;
// UI Elements
var scoreTxt = new Text2('0', {
size: 80,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
var livesTxt = new Text2('Lives: 3', {
size: 60,
fill: 0xFFFFFF
});
livesTxt.anchor.set(1, 0);
livesTxt.x = -20;
livesTxt.y = 20;
LK.gui.topRight.addChild(livesTxt);
var powerUpTxt = new Text2('', {
size: 50,
fill: 0xFFFF00
});
powerUpTxt.anchor.set(0.5, 0);
powerUpTxt.y = 100;
LK.gui.top.addChild(powerUpTxt);
function spawnBubble() {
var bubbleTypes = ['blue', 'red', 'green', 'yellow', 'purple'];
var bubbleType = bubbleTypes[Math.floor(Math.random() * bubbleTypes.length)];
// 5% chance for power-up bubble
if (Math.random() < 0.05) {
bubbleType = 'power';
}
var bubble = new Bubble(bubbleType);
bubble.x = Math.random() * (2048 - 120) + 60;
bubble.y = 2732 + 60;
bubble.speed = bubbleSpeed + Math.random() * 2;
bubbles.push(bubble);
game.addChild(bubble);
// Gentle floating animation
bubble.scaleX = 0.8;
bubble.scaleY = 0.8;
tween(bubble, {
scaleX: 1,
scaleY: 1
}, {
duration: 500,
easing: tween.easeOut
});
}
function activatePowerUp() {
powerUpActive = true;
powerUpTimer = 300; // 5 seconds at 60fps
powerUpTxt.setText('SLOW TIME!');
// Slow down all bubbles
for (var i = 0; i < bubbles.length; i++) {
bubbles[i].speed *= 0.3;
}
}
function loseLife() {
lives--;
livesTxt.setText('Lives: ' + lives);
LK.getSound('lose').play();
LK.effects.flashScreen(0xff0000, 500);
if (lives <= 0) {
LK.showGameOver();
}
}
function updateDifficulty() {
var score = LK.getScore();
// Increase bubble speed every 500 points
bubbleSpeed = 2 + Math.floor(score / 500) * 0.5;
// Decrease spawn rate (more frequent spawning) every 200 points
spawnRate = Math.max(20, 60 - Math.floor(score / 200) * 5);
}
game.update = function () {
// Handle power-up timer
if (powerUpActive) {
powerUpTimer--;
if (powerUpTimer <= 0) {
powerUpActive = false;
powerUpTxt.setText('');
// Restore normal bubble speeds
for (var i = 0; i < bubbles.length; i++) {
bubbles[i].speed = bubbleSpeed + Math.random() * 2;
}
}
}
// Spawn bubbles
spawnTimer++;
if (spawnTimer >= spawnRate) {
spawnBubble();
spawnTimer = 0;
}
// Update bubbles and check for escaped bubbles
for (var i = bubbles.length - 1; i >= 0; i--) {
var bubble = bubbles[i];
// Check if bubble escaped (reached top of screen)
if (bubble.floating && bubble.y < -60) {
bubble.destroy();
bubbles.splice(i, 1);
loseLife();
}
}
// Update difficulty
updateDifficulty();
// Update score display
scoreTxt.setText(LK.getScore());
}; ===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,199 @@
-/****
+/****
+* Plugins
+****/
+var tween = LK.import("@upit/tween.v1");
+
+/****
+* Classes
+****/
+var Bubble = Container.expand(function (type) {
+ var self = Container.call(this);
+ self.bubbleType = type || 'blue';
+ self.pointValue = 10;
+ self.speed = 2;
+ self.isPowerUp = false;
+ var assetName = 'blueBubble';
+ if (self.bubbleType === 'red') {
+ assetName = 'redBubble';
+ self.pointValue = 15;
+ } else if (self.bubbleType === 'green') {
+ assetName = 'greenBubble';
+ self.pointValue = 20;
+ } else if (self.bubbleType === 'yellow') {
+ assetName = 'yellowBubble';
+ self.pointValue = 25;
+ } else if (self.bubbleType === 'purple') {
+ assetName = 'purpleBubble';
+ self.pointValue = 30;
+ } else if (self.bubbleType === 'power') {
+ assetName = 'powerBubble';
+ self.pointValue = 50;
+ self.isPowerUp = true;
+ }
+ var bubbleGraphics = self.attachAsset(assetName, {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.floating = true;
+ self.down = function (x, y, obj) {
+ if (self.floating) {
+ self.floating = false;
+ self.pop();
+ }
+ };
+ self.pop = function () {
+ if (self.isPowerUp) {
+ LK.getSound('powerup').play();
+ activatePowerUp();
+ } else {
+ LK.getSound('pop').play();
+ }
+ LK.setScore(LK.getScore() + self.pointValue);
+ scoreTxt.setText(LK.getScore());
+ // Pop animation
+ tween(self, {
+ scaleX: 1.5,
+ scaleY: 1.5,
+ alpha: 0
+ }, {
+ duration: 200,
+ easing: tween.easeOut,
+ onFinish: function onFinish() {
+ self.destroy();
+ var index = bubbles.indexOf(self);
+ if (index > -1) {
+ bubbles.splice(index, 1);
+ }
+ }
+ });
+ };
+ self.update = function () {
+ if (self.floating) {
+ self.y -= self.speed;
+ }
+ };
+ return self;
+});
+
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000
-});
\ No newline at end of file
+ backgroundColor: 0x87CEEB
+});
+
+/****
+* Game Code
+****/
+var bubbles = [];
+var lives = 3;
+var spawnTimer = 0;
+var spawnRate = 60; // Initial spawn rate (frames between spawns)
+var bubbleSpeed = 2;
+var powerUpActive = false;
+var powerUpTimer = 0;
+// UI Elements
+var scoreTxt = new Text2('0', {
+ size: 80,
+ fill: 0xFFFFFF
+});
+scoreTxt.anchor.set(0.5, 0);
+LK.gui.top.addChild(scoreTxt);
+var livesTxt = new Text2('Lives: 3', {
+ size: 60,
+ fill: 0xFFFFFF
+});
+livesTxt.anchor.set(1, 0);
+livesTxt.x = -20;
+livesTxt.y = 20;
+LK.gui.topRight.addChild(livesTxt);
+var powerUpTxt = new Text2('', {
+ size: 50,
+ fill: 0xFFFF00
+});
+powerUpTxt.anchor.set(0.5, 0);
+powerUpTxt.y = 100;
+LK.gui.top.addChild(powerUpTxt);
+function spawnBubble() {
+ var bubbleTypes = ['blue', 'red', 'green', 'yellow', 'purple'];
+ var bubbleType = bubbleTypes[Math.floor(Math.random() * bubbleTypes.length)];
+ // 5% chance for power-up bubble
+ if (Math.random() < 0.05) {
+ bubbleType = 'power';
+ }
+ var bubble = new Bubble(bubbleType);
+ bubble.x = Math.random() * (2048 - 120) + 60;
+ bubble.y = 2732 + 60;
+ bubble.speed = bubbleSpeed + Math.random() * 2;
+ bubbles.push(bubble);
+ game.addChild(bubble);
+ // Gentle floating animation
+ bubble.scaleX = 0.8;
+ bubble.scaleY = 0.8;
+ tween(bubble, {
+ scaleX: 1,
+ scaleY: 1
+ }, {
+ duration: 500,
+ easing: tween.easeOut
+ });
+}
+function activatePowerUp() {
+ powerUpActive = true;
+ powerUpTimer = 300; // 5 seconds at 60fps
+ powerUpTxt.setText('SLOW TIME!');
+ // Slow down all bubbles
+ for (var i = 0; i < bubbles.length; i++) {
+ bubbles[i].speed *= 0.3;
+ }
+}
+function loseLife() {
+ lives--;
+ livesTxt.setText('Lives: ' + lives);
+ LK.getSound('lose').play();
+ LK.effects.flashScreen(0xff0000, 500);
+ if (lives <= 0) {
+ LK.showGameOver();
+ }
+}
+function updateDifficulty() {
+ var score = LK.getScore();
+ // Increase bubble speed every 500 points
+ bubbleSpeed = 2 + Math.floor(score / 500) * 0.5;
+ // Decrease spawn rate (more frequent spawning) every 200 points
+ spawnRate = Math.max(20, 60 - Math.floor(score / 200) * 5);
+}
+game.update = function () {
+ // Handle power-up timer
+ if (powerUpActive) {
+ powerUpTimer--;
+ if (powerUpTimer <= 0) {
+ powerUpActive = false;
+ powerUpTxt.setText('');
+ // Restore normal bubble speeds
+ for (var i = 0; i < bubbles.length; i++) {
+ bubbles[i].speed = bubbleSpeed + Math.random() * 2;
+ }
+ }
+ }
+ // Spawn bubbles
+ spawnTimer++;
+ if (spawnTimer >= spawnRate) {
+ spawnBubble();
+ spawnTimer = 0;
+ }
+ // Update bubbles and check for escaped bubbles
+ for (var i = bubbles.length - 1; i >= 0; i--) {
+ var bubble = bubbles[i];
+ // Check if bubble escaped (reached top of screen)
+ if (bubble.floating && bubble.y < -60) {
+ bubble.destroy();
+ bubbles.splice(i, 1);
+ loseLife();
+ }
+ }
+ // Update difficulty
+ updateDifficulty();
+ // Update score display
+ scoreTxt.setText(LK.getScore());
+};
\ No newline at end of file