User prompt
Kısa tiklamayla gear olusturma.
User prompt
Gear ekledigimde ona ait sesi surekli çal. Gear tek kısa tıklamayla silinsin ve sesi sussun.
User prompt
Herbir gear çeşidi icin bir ses ekle
User prompt
Sesler gear olduğu surece surekli tekrar etsin.
User prompt
Gearin üstüne cift tıklayinca gear silinsin ve ses sussun.
User prompt
5 farklı gear için 5 farkli ses ekle
User prompt
5 farklı gear için 5 farkli ses ekle
User prompt
Tümünü 2 kat büyüt.
User prompt
dişli dişi yerine sadece dişli ifadesini kullan tüm isimleri değiştir
User prompt
5 farklı dişli asset olsun.
User prompt
Üst üste gelmesinler dişli içini kaldır. Büyüklük dokunma süresiyle orantılı olsun.
User prompt
Dişliler her defasında farklı boyut olsun. 5 farklı dönme sesi ekle
Code edit (1 edits merged)
Please save this source code
User prompt
Dönen Dişliler
Initial prompt
Tıkladıkca dişli ekleyeyim. Oluşan dişli çevirdiğim tarafa sürekli dönsün.
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ // Gear class: represents a single gear that rotates in a given direction and speed var Gear = Container.expand(function () { var self = Container.call(this); // Attach a gear-shaped asset (ellipse for now, as custom shapes are not supported) // We'll use a box for the body and a slightly larger ellipse for a "tooth" effect // Main gear body var gearBody = self.attachAsset('gearBody', { anchorX: 0.5, anchorY: 0.5 }); // "Teeth" effect: a slightly larger ellipse, semi-transparent var gearTeeth = self.attachAsset('gearTeeth', { anchorX: 0.5, anchorY: 0.5, alpha: 0.3 }); // Set up default size and color for assets // (LK will create these assets automatically) // gearBody: box, 220x220, gray // gearTeeth: ellipse, 270x270, light gray gearBody.width = 220; gearBody.height = 220; gearBody.color = 0x888888; gearTeeth.width = 270; gearTeeth.height = 270; gearTeeth.color = 0xcccccc; // (Sizes will be overridden externally for randomization) // Rotation speed in radians per frame (set externally) self.rotationSpeed = 0; // Update method: rotates the gear self.update = function () { self.rotation += self.rotationSpeed; }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0xffffff // White background for clarity }); /**** * Game Code ****/ // We need tween for smooth rotation animations // List of all gears in the game var gears = []; // For drag direction detection var isDragging = false; var dragStart = null; // {x, y} var dragCurrent = null; // {x, y} // Helper: calculate angle between two points (in radians) function getAngle(x1, y1, x2, y2) { return Math.atan2(y2 - y1, x2 - x1); } // Helper: clamp rotation speed function clamp(val, min, max) { if (val < min) return min; if (val > max) return max; return val; } // Show a simple instruction at the top (not in topLeft) var infoTxt = new Text2('Ekrana basılı tut, çek ve bırak: Dişli ekle!', { size: 90, fill: 0x333333 }); infoTxt.anchor.set(0.5, 0); LK.gui.top.addChild(infoTxt); // Main game event handlers // On press down: start drag game.down = function (x, y, obj) { isDragging = true; dragStart = { x: x, y: y }; dragCurrent = { x: x, y: y }; }; // On move: update drag current position game.move = function (x, y, obj) { if (isDragging) { dragCurrent.x = x; dragCurrent.y = y; } }; // On release: create a new gear at dragStart, rotating in the direction of drag game.up = function (x, y, obj) { if (!isDragging || !dragStart) return; // Calculate drag vector var dx = dragCurrent.x - dragStart.x; var dy = dragCurrent.y - dragStart.y; var dist = Math.sqrt(dx * dx + dy * dy); // If drag is too short, set a default direction (upwards) var angle; if (dist < 30) { angle = -Math.PI / 2; // Upwards } else { angle = getAngle(dragStart.x, dragStart.y, dragCurrent.x, dragCurrent.y); } // Rotation speed: proportional to drag length, with min/max // 0.01 rad/frame (slow) to 0.07 rad/frame (fast) var speed = clamp(dist / 3000, 0.01, 0.07); // Direction: clockwise if drag is rightwards, counterclockwise if leftwards // We'll use the sign of dx to determine direction if (dx < 0) speed = -speed; // Create and position the gear var gear = new Gear(); // Randomly select a size for the gear (5 possible sizes) var gearSizes = [{ body: 120, teeth: 150 }, { body: 170, teeth: 210 }, { body: 220, teeth: 270 }, { body: 270, teeth: 330 }, { body: 320, teeth: 390 }]; var sizeIdx = Math.floor(Math.random() * gearSizes.length); gear.children[0].width = gearSizes[sizeIdx].body; gear.children[0].height = gearSizes[sizeIdx].body; gear.children[1].width = gearSizes[sizeIdx].teeth; gear.children[1].height = gearSizes[sizeIdx].teeth; // Place gear at drag start gear.x = dragStart.x; gear.y = dragStart.y; gear.rotationSpeed = speed; // Play a random gear rotation sound var soundIdx = Math.floor(Math.random() * 5) + 1; LK.getSound('gearRotate' + soundIdx).play(); // Add to game and to gears array game.addChild(gear); gears.push(gear); // Reset drag state isDragging = false; dragStart = null; dragCurrent = null; }; // Update loop: update all gears game.update = function () { for (var i = 0; i < gears.length; i++) { if (gears[i].update) gears[i].update(); } };
===================================================================
--- original.js
+++ change.js
@@ -31,8 +31,9 @@
gearBody.color = 0x888888;
gearTeeth.width = 270;
gearTeeth.height = 270;
gearTeeth.color = 0xcccccc;
+ // (Sizes will be overridden externally for randomization)
// Rotation speed in radians per frame (set externally)
self.rotationSpeed = 0;
// Update method: rotates the gear
self.update = function () {
@@ -116,11 +117,37 @@
// We'll use the sign of dx to determine direction
if (dx < 0) speed = -speed;
// Create and position the gear
var gear = new Gear();
+ // Randomly select a size for the gear (5 possible sizes)
+ var gearSizes = [{
+ body: 120,
+ teeth: 150
+ }, {
+ body: 170,
+ teeth: 210
+ }, {
+ body: 220,
+ teeth: 270
+ }, {
+ body: 270,
+ teeth: 330
+ }, {
+ body: 320,
+ teeth: 390
+ }];
+ var sizeIdx = Math.floor(Math.random() * gearSizes.length);
+ gear.children[0].width = gearSizes[sizeIdx].body;
+ gear.children[0].height = gearSizes[sizeIdx].body;
+ gear.children[1].width = gearSizes[sizeIdx].teeth;
+ gear.children[1].height = gearSizes[sizeIdx].teeth;
+ // Place gear at drag start
gear.x = dragStart.x;
gear.y = dragStart.y;
gear.rotationSpeed = speed;
+ // Play a random gear rotation sound
+ var soundIdx = Math.floor(Math.random() * 5) + 1;
+ LK.getSound('gearRotate' + soundIdx).play();
// Add to game and to gears array
game.addChild(gear);
gears.push(gear);
// Reset drag state
red gear top view tranparent. In-Game asset. 2d. High contrast. No shadows
yellow gear top view tranparent. In-Game asset. 2d. High contrast. No shadows
Green gear top view tranparent. In-Game asset. 2d. High contrast. No shadows
Mavi renk deniz manzarası. In-Game asset. 2d. High contrast. No shadows
Just a finger top view. In-Game asset. 2d. High contrast. No shadows