User prompt
farklı renklerde olsun ekrana bir kere tıklayınca rastgele büyük bir desen çıksın sonra sil yazısı ekle ona tıklayınca hepsi islinsin ingilizce
User prompt
renkler parlasın ışıltılar saçsın ve renkler bir araya gelip desenler oluştursun güzel resim gibi
Code edit (1 edits merged)
Please save this source code
User prompt
Pattern Pop: Tap to Reveal
Initial prompt
ekrana tıklandığında farklı desenler çıkan uygulama yap ingilizce profesyonel ol en iyisiniyap
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ // Pattern class: a container for a randomly generated pattern at a given position. var Pattern = Container.expand(function () { var self = Container.call(this); // Generate a random pattern on creation // Patterns: single shape, cluster, or overlay function randomColor() { // Return a random bright color var colors = [0xff5e5b, 0xffc857, 0x4ecdc4, 0x556270, 0x3a86ff, 0xffbe0b, 0xfb5607, 0x8338ec, 0xff006e, 0x06d6a0]; return colors[Math.floor(Math.random() * colors.length)]; } function randomShape() { // Return 'box' or 'ellipse' return Math.random() < 0.5 ? 'box' : 'ellipse'; } function randomSize() { // Return a size between 120 and 400 px return 120 + Math.floor(Math.random() * 280); } function randomRotation() { // Return a random rotation in radians return Math.random() * Math.PI * 2; } function randomAlpha() { // Return a random alpha between 0.7 and 1 return 0.7 + Math.random() * 0.3; } function randomPatternType() { // 0: single, 1: cluster, 2: overlay var r = Math.random(); if (r < 0.5) return 0; if (r < 0.8) return 1; return 2; } // Generate the pattern function generatePattern() { var type = randomPatternType(); if (type === 0) { // Single shape var w = randomSize(); var h = randomSize(); var shape = randomShape(); var color = randomColor(); var asset = self.attachAsset({ anchorX: 0.5, anchorY: 0.5 }, {}); asset.rotation = randomRotation(); asset.alpha = randomAlpha(); } else if (type === 1) { // Cluster: 3-6 shapes in a circle var count = 3 + Math.floor(Math.random() * 4); var radius = 80 + Math.random() * 120; for (var i = 0; i < count; i++) { var angle = Math.PI * 2 / count * i + Math.random() * 0.3; var w = randomSize() * (0.5 + Math.random() * 0.7); var h = randomSize() * (0.5 + Math.random() * 0.7); var shape = randomShape(); var color = randomColor(); var asset = self.attachAsset({ anchorX: 0.5, anchorY: 0.5 }, {}); asset.x = Math.cos(angle) * radius; asset.y = Math.sin(angle) * radius; asset.rotation = randomRotation(); asset.alpha = randomAlpha(); } } else { // Overlay: 2-3 shapes stacked with different rotations var overlays = 2 + Math.floor(Math.random() * 2); for (var j = 0; j < overlays; j++) { var w = randomSize() * (0.7 + Math.random() * 0.5); var h = randomSize() * (0.7 + Math.random() * 0.5); var shape = randomShape(); var color = randomColor(); var asset = self.attachAsset({ anchorX: 0.5, anchorY: 0.5 }, {}); asset.rotation = randomRotation(); asset.alpha = 0.5 + Math.random() * 0.5; } } } generatePattern(); // Pop-in animation self.scale.set(0.2, 0.2); tween(self.scale, { x: 1, y: 1 }, { duration: 350, easing: tween.elasticOut }); return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0xffffff // White background for a clean canvas }); /**** * Game Code ****/ // We'll use the tween plugin for simple pop-in animations. /* We will use only shapes for patterns, with random colors and sizes. No need to predefine assets, as LK will auto-create them as needed. */ // No score, no timer, no GUI overlays // Store all patterns for possible future management (e.g., clearing, layering) var patterns = []; // Helper: don't allow patterns in the top-left 100x100 px (menu area) function isInMenuArea(x, y) { return x < 100 && y < 100; } // On tap/click anywhere, create a new pattern at that location game.down = function (x, y, obj) { // Don't allow patterns in menu area if (isInMenuArea(x, y)) return; var pattern = new Pattern(); pattern.x = x; pattern.y = y; patterns.push(pattern); game.addChild(pattern); }; // Optional: allow dragging patterns (fun for creativity) // Only one pattern can be dragged at a time var dragPattern = null; var dragOffsetX = 0; var dragOffsetY = 0; // On down, check if a pattern is tapped (topmost first) game.down = function (x, y, obj) { if (isInMenuArea(x, y)) return; // Check for pattern under pointer, topmost first for (var i = patterns.length - 1; i >= 0; i--) { var p = patterns[i]; // Use bounding box for hit test var bounds = p.getBounds(); if (x >= p.x + bounds.x && x <= p.x + bounds.x + bounds.width && y >= p.y + bounds.y && y <= p.y + bounds.y + bounds.height) { dragPattern = p; dragOffsetX = p.x - x; dragOffsetY = p.y - y; // Bring to front game.removeChild(p); game.addChild(p); return; } } // If no pattern tapped, create a new one var pattern = new Pattern(); pattern.x = x; pattern.y = y; patterns.push(pattern); game.addChild(pattern); dragPattern = pattern; dragOffsetX = 0; dragOffsetY = 0; }; // On move, drag the selected pattern game.move = function (x, y, obj) { if (dragPattern) { dragPattern.x = x + dragOffsetX; dragPattern.y = y + dragOffsetY; } }; // On up, stop dragging game.up = function (x, y, obj) { dragPattern = null; }; // No update loop needed, as patterns are static after creation // That's it! Pattern Pop: tap to create, drag to arrange, endless fun.
===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,183 @@
-/****
+/****
+* Plugins
+****/
+var tween = LK.import("@upit/tween.v1");
+
+/****
+* Classes
+****/
+// Pattern class: a container for a randomly generated pattern at a given position.
+var Pattern = Container.expand(function () {
+ var self = Container.call(this);
+ // Generate a random pattern on creation
+ // Patterns: single shape, cluster, or overlay
+ function randomColor() {
+ // Return a random bright color
+ var colors = [0xff5e5b, 0xffc857, 0x4ecdc4, 0x556270, 0x3a86ff, 0xffbe0b, 0xfb5607, 0x8338ec, 0xff006e, 0x06d6a0];
+ return colors[Math.floor(Math.random() * colors.length)];
+ }
+ function randomShape() {
+ // Return 'box' or 'ellipse'
+ return Math.random() < 0.5 ? 'box' : 'ellipse';
+ }
+ function randomSize() {
+ // Return a size between 120 and 400 px
+ return 120 + Math.floor(Math.random() * 280);
+ }
+ function randomRotation() {
+ // Return a random rotation in radians
+ return Math.random() * Math.PI * 2;
+ }
+ function randomAlpha() {
+ // Return a random alpha between 0.7 and 1
+ return 0.7 + Math.random() * 0.3;
+ }
+ function randomPatternType() {
+ // 0: single, 1: cluster, 2: overlay
+ var r = Math.random();
+ if (r < 0.5) return 0;
+ if (r < 0.8) return 1;
+ return 2;
+ }
+ // Generate the pattern
+ function generatePattern() {
+ var type = randomPatternType();
+ if (type === 0) {
+ // Single shape
+ var w = randomSize();
+ var h = randomSize();
+ var shape = randomShape();
+ var color = randomColor();
+ var asset = self.attachAsset({
+ anchorX: 0.5,
+ anchorY: 0.5
+ }, {});
+ asset.rotation = randomRotation();
+ asset.alpha = randomAlpha();
+ } else if (type === 1) {
+ // Cluster: 3-6 shapes in a circle
+ var count = 3 + Math.floor(Math.random() * 4);
+ var radius = 80 + Math.random() * 120;
+ for (var i = 0; i < count; i++) {
+ var angle = Math.PI * 2 / count * i + Math.random() * 0.3;
+ var w = randomSize() * (0.5 + Math.random() * 0.7);
+ var h = randomSize() * (0.5 + Math.random() * 0.7);
+ var shape = randomShape();
+ var color = randomColor();
+ var asset = self.attachAsset({
+ anchorX: 0.5,
+ anchorY: 0.5
+ }, {});
+ asset.x = Math.cos(angle) * radius;
+ asset.y = Math.sin(angle) * radius;
+ asset.rotation = randomRotation();
+ asset.alpha = randomAlpha();
+ }
+ } else {
+ // Overlay: 2-3 shapes stacked with different rotations
+ var overlays = 2 + Math.floor(Math.random() * 2);
+ for (var j = 0; j < overlays; j++) {
+ var w = randomSize() * (0.7 + Math.random() * 0.5);
+ var h = randomSize() * (0.7 + Math.random() * 0.5);
+ var shape = randomShape();
+ var color = randomColor();
+ var asset = self.attachAsset({
+ anchorX: 0.5,
+ anchorY: 0.5
+ }, {});
+ asset.rotation = randomRotation();
+ asset.alpha = 0.5 + Math.random() * 0.5;
+ }
+ }
+ }
+ generatePattern();
+ // Pop-in animation
+ self.scale.set(0.2, 0.2);
+ tween(self.scale, {
+ x: 1,
+ y: 1
+ }, {
+ duration: 350,
+ easing: tween.elasticOut
+ });
+ return self;
+});
+
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000
-});
\ No newline at end of file
+ backgroundColor: 0xffffff // White background for a clean canvas
+});
+
+/****
+* Game Code
+****/
+// We'll use the tween plugin for simple pop-in animations.
+/*
+We will use only shapes for patterns, with random colors and sizes.
+No need to predefine assets, as LK will auto-create them as needed.
+*/
+// No score, no timer, no GUI overlays
+// Store all patterns for possible future management (e.g., clearing, layering)
+var patterns = [];
+// Helper: don't allow patterns in the top-left 100x100 px (menu area)
+function isInMenuArea(x, y) {
+ return x < 100 && y < 100;
+}
+// On tap/click anywhere, create a new pattern at that location
+game.down = function (x, y, obj) {
+ // Don't allow patterns in menu area
+ if (isInMenuArea(x, y)) return;
+ var pattern = new Pattern();
+ pattern.x = x;
+ pattern.y = y;
+ patterns.push(pattern);
+ game.addChild(pattern);
+};
+// Optional: allow dragging patterns (fun for creativity)
+// Only one pattern can be dragged at a time
+var dragPattern = null;
+var dragOffsetX = 0;
+var dragOffsetY = 0;
+// On down, check if a pattern is tapped (topmost first)
+game.down = function (x, y, obj) {
+ if (isInMenuArea(x, y)) return;
+ // Check for pattern under pointer, topmost first
+ for (var i = patterns.length - 1; i >= 0; i--) {
+ var p = patterns[i];
+ // Use bounding box for hit test
+ var bounds = p.getBounds();
+ if (x >= p.x + bounds.x && x <= p.x + bounds.x + bounds.width && y >= p.y + bounds.y && y <= p.y + bounds.y + bounds.height) {
+ dragPattern = p;
+ dragOffsetX = p.x - x;
+ dragOffsetY = p.y - y;
+ // Bring to front
+ game.removeChild(p);
+ game.addChild(p);
+ return;
+ }
+ }
+ // If no pattern tapped, create a new one
+ var pattern = new Pattern();
+ pattern.x = x;
+ pattern.y = y;
+ patterns.push(pattern);
+ game.addChild(pattern);
+ dragPattern = pattern;
+ dragOffsetX = 0;
+ dragOffsetY = 0;
+};
+// On move, drag the selected pattern
+game.move = function (x, y, obj) {
+ if (dragPattern) {
+ dragPattern.x = x + dragOffsetX;
+ dragPattern.y = y + dragOffsetY;
+ }
+};
+// On up, stop dragging
+game.up = function (x, y, obj) {
+ dragPattern = null;
+};
+// No update loop needed, as patterns are static after creation
+// That's it! Pattern Pop: tap to create, drag to arrange, endless fun.
\ No newline at end of file