User prompt
Paralar dahada hızlı düşsünler ve özelDoları toplayamayınca kaybedelim
User prompt
Paralar biraz daha hızlı düşsün
Code edit (1 edits merged)
Please save this source code
User prompt
Money Rain Collector
Initial prompt
Para toplama oyunu yapacaz üstden raskele sağdan soldan vb. düşecek rasgele şekilde paralar düşecekler.Bizde elimizdeki para çantasına bu paraları toplamaya çalışacaz paralar 10dolar şeklinde düşecek her topladığımız parada 10dolar skor yükselecek.Faremiz ile para çantasını yönlendireceğiz
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1"); /**** * Classes ****/ var Dollar = Container.expand(function (isSpecial) { var self = Container.call(this); var assetId = isSpecial ? 'specialDollar' : 'dollar'; var dollarGraphics = self.attachAsset(assetId, { anchorX: 0.5, anchorY: 0.5 }); // Create a $10 text on the bill var valueText = new Text2('$10', { size: 40, fill: isSpecial ? "#5D4037" : "#FFFFFF" }); valueText.anchor.set(0.5, 0.5); self.addChild(valueText); self.isSpecial = isSpecial || false; self.speed = Math.random() * 7 + 6; // Random speed between 6-13 self.value = isSpecial ? 30 : 10; self.update = function () { self.y += self.speed; }; return self; }); var MoneyBag = Container.expand(function () { var self = Container.call(this); var bagGraphics = self.attachAsset('moneyBag', { anchorX: 0.5, anchorY: 0.5, scaleX: 1.5, scaleY: 1.5 }); // Create a dollar sign on the bag var dollarSign = new Text2('$', { size: 80, fill: 0xFFD700 }); dollarSign.anchor.set(0.5, 0.5); self.addChild(dollarSign); return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0xd7ccc8 }); /**** * Game Code ****/ // Game variables var moneyBag; var dollars = []; var score = 0; var gameStarted = false; var dragNode = null; var gameSpeed = 1; var spawnRate = 100; // Lower numbers spawn more frequently var specialChance = 0.15; // 15% chance for special dollars // Create score text var scoreTxt = new Text2('Score: 0', { size: 80, fill: 0x5D4037 }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); // Create speed indicator var speedTxt = new Text2('Speed: 1x', { size: 60, fill: 0x5D4037 }); speedTxt.anchor.set(1, 0); speedTxt.x = -50; // Offset from right edge LK.gui.topRight.addChild(speedTxt); // Create game title var titleTxt = new Text2('Money Rain Collector', { size: 100, fill: 0x5D4037 }); titleTxt.anchor.set(0.5, 0.5); LK.gui.center.addChild(titleTxt); // Create start instruction var instructionTxt = new Text2('Tap to Start', { size: 80, fill: 0x43A047 }); instructionTxt.anchor.set(0.5, 0.5); instructionTxt.y = 150; LK.gui.center.addChild(instructionTxt); // Create money bag function createMoneyBag() { moneyBag = new MoneyBag(); moneyBag.x = 2048 / 2; moneyBag.y = 2732 - 150; game.addChild(moneyBag); } // Create a new dollar bill function createDollar() { var isSpecial = Math.random() < specialChance; var dollar = new Dollar(isSpecial); dollar.x = Math.random() * (2048 - 100) + 50; // Random position with margins dollar.y = -dollar.height; dollars.push(dollar); game.addChild(dollar); } // Start the game function startGame() { if (gameStarted) { return; } gameStarted = true; // Remove title and instruction tween(titleTxt, { alpha: 0 }, { duration: 500 }); tween(instructionTxt, { alpha: 0 }, { duration: 500 }); // Create money bag createMoneyBag(); // Reset game variables score = 0; gameSpeed = 1; spawnRate = 100; scoreTxt.setText('Score: ' + score); speedTxt.setText('Speed: ' + gameSpeed + 'x'); // Start game music LK.playMusic('gameMusic'); } // Handle moving the money bag function handleMove(x, y, obj) { if (!gameStarted) { return; } if (dragNode) { dragNode.x = x; } } // Mouse down event game.down = function (x, y, obj) { if (!gameStarted) { startGame(); return; } dragNode = moneyBag; handleMove(x, y, obj); }; // Mouse up event game.up = function (x, y, obj) { dragNode = null; }; // Mouse move event game.move = handleMove; // Game update function game.update = function () { if (!gameStarted) { return; } // Spawn new dollars based on spawn rate if (LK.ticks % Math.floor(spawnRate / gameSpeed) === 0) { createDollar(); } // Update dollars for (var i = dollars.length - 1; i >= 0; i--) { var dollar = dollars[i]; // Check if dollar is off screen if (dollar.y > 2732 + dollar.height) { // Game over if we miss a special dollar if (dollar.isSpecial) { LK.effects.flashScreen(0xff0000, 500); // Flash red for missing special dollar LK.showGameOver(); } dollar.destroy(); dollars.splice(i, 1); continue; } // Check collision with money bag if (dollar.intersects(moneyBag)) { // Add to score score += dollar.value; scoreTxt.setText('Score: ' + score); // Play collect sound if (dollar.isSpecial) { LK.getSound('specialCollect').play(); // Flash screen green for special dollar LK.effects.flashScreen(0x43a047, 300); } else { LK.getSound('collect').play(); } // Remove dollar dollar.destroy(); dollars.splice(i, 1); // Increase game speed at certain score thresholds if (score % 100 === 0 && gameSpeed < 3) { gameSpeed += 0.2; speedTxt.setText('Speed: ' + gameSpeed.toFixed(1) + 'x'); LK.effects.flashObject(speedTxt, 0x43a047, 500); } continue; } } // Check for game over (optional - can be triggered when reaching score threshold) if (score >= 500) { LK.showYouWin(); } };
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
var Dollar = Container.expand(function (isSpecial) {
var self = Container.call(this);
var assetId = isSpecial ? 'specialDollar' : 'dollar';
var dollarGraphics = self.attachAsset(assetId, {
anchorX: 0.5,
anchorY: 0.5
});
// Create a $10 text on the bill
var valueText = new Text2('$10', {
size: 40,
fill: isSpecial ? "#5D4037" : "#FFFFFF"
});
valueText.anchor.set(0.5, 0.5);
self.addChild(valueText);
self.isSpecial = isSpecial || false;
self.speed = Math.random() * 7 + 6; // Random speed between 6-13
self.value = isSpecial ? 30 : 10;
self.update = function () {
self.y += self.speed;
};
return self;
});
var MoneyBag = Container.expand(function () {
var self = Container.call(this);
var bagGraphics = self.attachAsset('moneyBag', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.5,
scaleY: 1.5
});
// Create a dollar sign on the bag
var dollarSign = new Text2('$', {
size: 80,
fill: 0xFFD700
});
dollarSign.anchor.set(0.5, 0.5);
self.addChild(dollarSign);
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0xd7ccc8
});
/****
* Game Code
****/
// Game variables
var moneyBag;
var dollars = [];
var score = 0;
var gameStarted = false;
var dragNode = null;
var gameSpeed = 1;
var spawnRate = 100; // Lower numbers spawn more frequently
var specialChance = 0.15; // 15% chance for special dollars
// Create score text
var scoreTxt = new Text2('Score: 0', {
size: 80,
fill: 0x5D4037
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
// Create speed indicator
var speedTxt = new Text2('Speed: 1x', {
size: 60,
fill: 0x5D4037
});
speedTxt.anchor.set(1, 0);
speedTxt.x = -50; // Offset from right edge
LK.gui.topRight.addChild(speedTxt);
// Create game title
var titleTxt = new Text2('Money Rain Collector', {
size: 100,
fill: 0x5D4037
});
titleTxt.anchor.set(0.5, 0.5);
LK.gui.center.addChild(titleTxt);
// Create start instruction
var instructionTxt = new Text2('Tap to Start', {
size: 80,
fill: 0x43A047
});
instructionTxt.anchor.set(0.5, 0.5);
instructionTxt.y = 150;
LK.gui.center.addChild(instructionTxt);
// Create money bag
function createMoneyBag() {
moneyBag = new MoneyBag();
moneyBag.x = 2048 / 2;
moneyBag.y = 2732 - 150;
game.addChild(moneyBag);
}
// Create a new dollar bill
function createDollar() {
var isSpecial = Math.random() < specialChance;
var dollar = new Dollar(isSpecial);
dollar.x = Math.random() * (2048 - 100) + 50; // Random position with margins
dollar.y = -dollar.height;
dollars.push(dollar);
game.addChild(dollar);
}
// Start the game
function startGame() {
if (gameStarted) {
return;
}
gameStarted = true;
// Remove title and instruction
tween(titleTxt, {
alpha: 0
}, {
duration: 500
});
tween(instructionTxt, {
alpha: 0
}, {
duration: 500
});
// Create money bag
createMoneyBag();
// Reset game variables
score = 0;
gameSpeed = 1;
spawnRate = 100;
scoreTxt.setText('Score: ' + score);
speedTxt.setText('Speed: ' + gameSpeed + 'x');
// Start game music
LK.playMusic('gameMusic');
}
// Handle moving the money bag
function handleMove(x, y, obj) {
if (!gameStarted) {
return;
}
if (dragNode) {
dragNode.x = x;
}
}
// Mouse down event
game.down = function (x, y, obj) {
if (!gameStarted) {
startGame();
return;
}
dragNode = moneyBag;
handleMove(x, y, obj);
};
// Mouse up event
game.up = function (x, y, obj) {
dragNode = null;
};
// Mouse move event
game.move = handleMove;
// Game update function
game.update = function () {
if (!gameStarted) {
return;
}
// Spawn new dollars based on spawn rate
if (LK.ticks % Math.floor(spawnRate / gameSpeed) === 0) {
createDollar();
}
// Update dollars
for (var i = dollars.length - 1; i >= 0; i--) {
var dollar = dollars[i];
// Check if dollar is off screen
if (dollar.y > 2732 + dollar.height) {
// Game over if we miss a special dollar
if (dollar.isSpecial) {
LK.effects.flashScreen(0xff0000, 500); // Flash red for missing special dollar
LK.showGameOver();
}
dollar.destroy();
dollars.splice(i, 1);
continue;
}
// Check collision with money bag
if (dollar.intersects(moneyBag)) {
// Add to score
score += dollar.value;
scoreTxt.setText('Score: ' + score);
// Play collect sound
if (dollar.isSpecial) {
LK.getSound('specialCollect').play();
// Flash screen green for special dollar
LK.effects.flashScreen(0x43a047, 300);
} else {
LK.getSound('collect').play();
}
// Remove dollar
dollar.destroy();
dollars.splice(i, 1);
// Increase game speed at certain score thresholds
if (score % 100 === 0 && gameSpeed < 3) {
gameSpeed += 0.2;
speedTxt.setText('Speed: ' + gameSpeed.toFixed(1) + 'x');
LK.effects.flashObject(speedTxt, 0x43a047, 500);
}
continue;
}
}
// Check for game over (optional - can be triggered when reaching score threshold)
if (score >= 500) {
LK.showYouWin();
}
};