User prompt
popçu kızlara çarptığımızda combomuzun değil canımızın azalması gerekiyor
User prompt
popçu kızlar 100ün katı skor aldığım zaman 0.5 kat hızlansınlar
User prompt
tüm popçu kızlar her 125 score da 0.65 hızlansın
User prompt
gelen popçuların hızı her 200 score da hız katsayısı 0.25 artsın.
User prompt
her 100 score da 1 health eklensin. kademeli olarak popçular hızlansın
User prompt
gelen popçular birbirlerine temas ettikleri zaman yok olsunlar. bize score kazandırsın
Code edit (1 edits merged)
Please save this source code
User prompt
Rapper's Revenge: Beat the Pop Stars
Initial prompt
rapçi ana karakter popçu oğlanları döven bir oyun
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var PopStar = Container.expand(function () {
var self = Container.call(this);
var popstarGraphics = self.attachAsset('popstar', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 2;
self.targetX = 0;
self.targetY = 0;
self.isDead = false;
self.hitWindow = 100; // pixels around popstar where tap is effective
self.setTarget = function (x, y) {
self.targetX = x;
self.targetY = y;
};
self.update = function () {
if (self.isDead) return;
// Move toward target (rapper)
var dx = self.targetX - self.x;
var dy = self.targetY - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance > 5) {
self.x += dx / distance * self.speed;
self.y += dy / distance * self.speed;
}
};
self.die = function () {
self.isDead = true;
// Create hit effect
var effect = game.addChild(LK.getAsset('hitEffect', {
anchorX: 0.5,
anchorY: 0.5
}));
effect.x = self.x;
effect.y = self.y;
// Animate effect
tween(effect, {
scaleX: 2,
scaleY: 2,
alpha: 0
}, {
duration: 300,
onFinish: function onFinish() {
effect.destroy();
}
});
};
return self;
});
var Rapper = Container.expand(function () {
var self = Container.call(this);
var rapperGraphics = self.attachAsset('rapper', {
anchorX: 0.5,
anchorY: 0.5
});
self.health = 3;
self.maxHealth = 3;
self.isInvulnerable = false;
self.takeDamage = function () {
if (self.isInvulnerable) return;
self.health--;
self.isInvulnerable = true;
// Flash effect when hit
LK.effects.flashObject(self, 0xFF0000, 500);
LK.getSound('damage').play();
// Invulnerability period
LK.setTimeout(function () {
self.isInvulnerable = false;
}, 1000);
if (self.health <= 0) {
LK.showGameOver();
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x1a1a2e
});
/****
* Game Code
****/
game.setBackgroundColor(0x16213e);
// Game variables
var rapper = null;
var popstars = [];
var dragNode = null;
var score = 0;
var combo = 0;
var maxCombo = 0;
var spawnTimer = 0;
var spawnDelay = 120; // frames between spawns
var difficultyTimer = 0;
// UI elements
var scoreTxt = new Text2('Score: 0', {
size: 60,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0, 0);
scoreTxt.x = 150;
scoreTxt.y = 50;
LK.gui.topLeft.addChild(scoreTxt);
var comboTxt = new Text2('Combo: 0', {
size: 50,
fill: 0xFFD700
});
comboTxt.anchor.set(0.5, 0);
comboTxt.x = 0;
comboTxt.y = 50;
LK.gui.top.addChild(comboTxt);
var healthTxt = new Text2('Health: 3', {
size: 50,
fill: 0xFF6B6B
});
healthTxt.anchor.set(1, 0);
healthTxt.x = -150;
healthTxt.y = 50;
LK.gui.topRight.addChild(healthTxt);
// Initialize rapper
rapper = game.addChild(new Rapper());
rapper.x = 1024;
rapper.y = 1366;
// Spawn popstar function
function spawnPopstar() {
var popstar = new PopStar();
// Random spawn position on edges
var side = Math.floor(Math.random() * 4);
switch (side) {
case 0:
// Top
popstar.x = Math.random() * 2048;
popstar.y = -50;
break;
case 1:
// Right
popstar.x = 2098;
popstar.y = Math.random() * 2732;
break;
case 2:
// Bottom
popstar.x = Math.random() * 2048;
popstar.y = 2782;
break;
case 3:
// Left
popstar.x = -50;
popstar.y = Math.random() * 2732;
break;
}
popstar.setTarget(rapper.x, rapper.y);
popstar.speed = 1.5 + Math.random() * 1.5;
popstars.push(popstar);
game.addChild(popstar);
}
// Handle touch input
function handleMove(x, y, obj) {
if (dragNode) {
// Keep rapper within bounds
dragNode.x = Math.max(60, Math.min(1988, x));
dragNode.y = Math.max(60, Math.min(2672, y));
// Update all popstar targets
for (var i = 0; i < popstars.length; i++) {
popstars[i].setTarget(dragNode.x, dragNode.y);
}
}
}
game.move = handleMove;
game.down = function (x, y, obj) {
// Check if tapping near any popstar
var hitAny = false;
for (var i = popstars.length - 1; i >= 0; i--) {
var popstar = popstars[i];
if (popstar.isDead) continue;
var dx = x - popstar.x;
var dy = y - popstar.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance <= popstar.hitWindow) {
// Hit popstar
popstar.die();
popstars.splice(i, 1);
popstar.destroy();
// Update score and combo
score += 10 + combo * 2;
combo++;
maxCombo = Math.max(maxCombo, combo);
// Play sound
if (combo > 1) {
LK.getSound('combo').play();
} else {
LK.getSound('hit').play();
}
hitAny = true;
break;
}
}
if (!hitAny) {
// Missed hit, reset combo
combo = 0;
}
// Start dragging rapper
dragNode = rapper;
handleMove(x, y, obj);
};
game.up = function (x, y, obj) {
dragNode = null;
};
// Main game loop
game.update = function () {
// Update UI
scoreTxt.setText('Score: ' + score);
comboTxt.setText('Combo: ' + combo);
healthTxt.setText('Health: ' + rapper.health);
// Spawn popstars
spawnTimer++;
if (spawnTimer >= spawnDelay) {
spawnPopstar();
spawnTimer = 0;
}
// Increase difficulty over time
difficultyTimer++;
if (difficultyTimer >= 600) {
// Every 10 seconds
spawnDelay = Math.max(60, spawnDelay - 5);
difficultyTimer = 0;
}
// Update popstars
for (var i = popstars.length - 1; i >= 0; i--) {
var popstar = popstars[i];
// Check collision with rapper
if (!popstar.isDead && rapper.intersects(popstar)) {
rapper.takeDamage();
combo = 0; // Reset combo on hit
popstar.die();
popstars.splice(i, 1);
popstar.destroy();
continue;
}
// Remove popstars that are too far off screen
if (popstar.x < -200 || popstar.x > 2248 || popstar.y < -200 || popstar.y > 2932) {
popstars.splice(i, 1);
popstar.destroy();
}
}
// Update score for survival
if (LK.ticks % 60 === 0) {
score += 1;
}
// Update LK score
LK.setScore(score);
};
// Start background music
LK.playMusic('bgmusic'); ===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,264 @@
-/****
+/****
+* Plugins
+****/
+var tween = LK.import("@upit/tween.v1");
+
+/****
+* Classes
+****/
+var PopStar = Container.expand(function () {
+ var self = Container.call(this);
+ var popstarGraphics = self.attachAsset('popstar', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.speed = 2;
+ self.targetX = 0;
+ self.targetY = 0;
+ self.isDead = false;
+ self.hitWindow = 100; // pixels around popstar where tap is effective
+ self.setTarget = function (x, y) {
+ self.targetX = x;
+ self.targetY = y;
+ };
+ self.update = function () {
+ if (self.isDead) return;
+ // Move toward target (rapper)
+ var dx = self.targetX - self.x;
+ var dy = self.targetY - self.y;
+ var distance = Math.sqrt(dx * dx + dy * dy);
+ if (distance > 5) {
+ self.x += dx / distance * self.speed;
+ self.y += dy / distance * self.speed;
+ }
+ };
+ self.die = function () {
+ self.isDead = true;
+ // Create hit effect
+ var effect = game.addChild(LK.getAsset('hitEffect', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ }));
+ effect.x = self.x;
+ effect.y = self.y;
+ // Animate effect
+ tween(effect, {
+ scaleX: 2,
+ scaleY: 2,
+ alpha: 0
+ }, {
+ duration: 300,
+ onFinish: function onFinish() {
+ effect.destroy();
+ }
+ });
+ };
+ return self;
+});
+var Rapper = Container.expand(function () {
+ var self = Container.call(this);
+ var rapperGraphics = self.attachAsset('rapper', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.health = 3;
+ self.maxHealth = 3;
+ self.isInvulnerable = false;
+ self.takeDamage = function () {
+ if (self.isInvulnerable) return;
+ self.health--;
+ self.isInvulnerable = true;
+ // Flash effect when hit
+ LK.effects.flashObject(self, 0xFF0000, 500);
+ LK.getSound('damage').play();
+ // Invulnerability period
+ LK.setTimeout(function () {
+ self.isInvulnerable = false;
+ }, 1000);
+ if (self.health <= 0) {
+ LK.showGameOver();
+ }
+ };
+ return self;
+});
+
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000
-});
\ No newline at end of file
+ backgroundColor: 0x1a1a2e
+});
+
+/****
+* Game Code
+****/
+game.setBackgroundColor(0x16213e);
+// Game variables
+var rapper = null;
+var popstars = [];
+var dragNode = null;
+var score = 0;
+var combo = 0;
+var maxCombo = 0;
+var spawnTimer = 0;
+var spawnDelay = 120; // frames between spawns
+var difficultyTimer = 0;
+// UI elements
+var scoreTxt = new Text2('Score: 0', {
+ size: 60,
+ fill: 0xFFFFFF
+});
+scoreTxt.anchor.set(0, 0);
+scoreTxt.x = 150;
+scoreTxt.y = 50;
+LK.gui.topLeft.addChild(scoreTxt);
+var comboTxt = new Text2('Combo: 0', {
+ size: 50,
+ fill: 0xFFD700
+});
+comboTxt.anchor.set(0.5, 0);
+comboTxt.x = 0;
+comboTxt.y = 50;
+LK.gui.top.addChild(comboTxt);
+var healthTxt = new Text2('Health: 3', {
+ size: 50,
+ fill: 0xFF6B6B
+});
+healthTxt.anchor.set(1, 0);
+healthTxt.x = -150;
+healthTxt.y = 50;
+LK.gui.topRight.addChild(healthTxt);
+// Initialize rapper
+rapper = game.addChild(new Rapper());
+rapper.x = 1024;
+rapper.y = 1366;
+// Spawn popstar function
+function spawnPopstar() {
+ var popstar = new PopStar();
+ // Random spawn position on edges
+ var side = Math.floor(Math.random() * 4);
+ switch (side) {
+ case 0:
+ // Top
+ popstar.x = Math.random() * 2048;
+ popstar.y = -50;
+ break;
+ case 1:
+ // Right
+ popstar.x = 2098;
+ popstar.y = Math.random() * 2732;
+ break;
+ case 2:
+ // Bottom
+ popstar.x = Math.random() * 2048;
+ popstar.y = 2782;
+ break;
+ case 3:
+ // Left
+ popstar.x = -50;
+ popstar.y = Math.random() * 2732;
+ break;
+ }
+ popstar.setTarget(rapper.x, rapper.y);
+ popstar.speed = 1.5 + Math.random() * 1.5;
+ popstars.push(popstar);
+ game.addChild(popstar);
+}
+// Handle touch input
+function handleMove(x, y, obj) {
+ if (dragNode) {
+ // Keep rapper within bounds
+ dragNode.x = Math.max(60, Math.min(1988, x));
+ dragNode.y = Math.max(60, Math.min(2672, y));
+ // Update all popstar targets
+ for (var i = 0; i < popstars.length; i++) {
+ popstars[i].setTarget(dragNode.x, dragNode.y);
+ }
+ }
+}
+game.move = handleMove;
+game.down = function (x, y, obj) {
+ // Check if tapping near any popstar
+ var hitAny = false;
+ for (var i = popstars.length - 1; i >= 0; i--) {
+ var popstar = popstars[i];
+ if (popstar.isDead) continue;
+ var dx = x - popstar.x;
+ var dy = y - popstar.y;
+ var distance = Math.sqrt(dx * dx + dy * dy);
+ if (distance <= popstar.hitWindow) {
+ // Hit popstar
+ popstar.die();
+ popstars.splice(i, 1);
+ popstar.destroy();
+ // Update score and combo
+ score += 10 + combo * 2;
+ combo++;
+ maxCombo = Math.max(maxCombo, combo);
+ // Play sound
+ if (combo > 1) {
+ LK.getSound('combo').play();
+ } else {
+ LK.getSound('hit').play();
+ }
+ hitAny = true;
+ break;
+ }
+ }
+ if (!hitAny) {
+ // Missed hit, reset combo
+ combo = 0;
+ }
+ // Start dragging rapper
+ dragNode = rapper;
+ handleMove(x, y, obj);
+};
+game.up = function (x, y, obj) {
+ dragNode = null;
+};
+// Main game loop
+game.update = function () {
+ // Update UI
+ scoreTxt.setText('Score: ' + score);
+ comboTxt.setText('Combo: ' + combo);
+ healthTxt.setText('Health: ' + rapper.health);
+ // Spawn popstars
+ spawnTimer++;
+ if (spawnTimer >= spawnDelay) {
+ spawnPopstar();
+ spawnTimer = 0;
+ }
+ // Increase difficulty over time
+ difficultyTimer++;
+ if (difficultyTimer >= 600) {
+ // Every 10 seconds
+ spawnDelay = Math.max(60, spawnDelay - 5);
+ difficultyTimer = 0;
+ }
+ // Update popstars
+ for (var i = popstars.length - 1; i >= 0; i--) {
+ var popstar = popstars[i];
+ // Check collision with rapper
+ if (!popstar.isDead && rapper.intersects(popstar)) {
+ rapper.takeDamage();
+ combo = 0; // Reset combo on hit
+ popstar.die();
+ popstars.splice(i, 1);
+ popstar.destroy();
+ continue;
+ }
+ // Remove popstars that are too far off screen
+ if (popstar.x < -200 || popstar.x > 2248 || popstar.y < -200 || popstar.y > 2932) {
+ popstars.splice(i, 1);
+ popstar.destroy();
+ }
+ }
+ // Update score for survival
+ if (LK.ticks % 60 === 0) {
+ score += 1;
+ }
+ // Update LK score
+ LK.setScore(score);
+};
+// Start background music
+LK.playMusic('bgmusic');
\ No newline at end of file