Code edit (11 edits merged)
Please save this source code
User prompt
even more
User prompt
even more before
User prompt
turn 180 degree tree and turn mirrored tree 0 degree
User prompt
spawn tree and tube before it enters screen
User prompt
increase gap between mirrored tube and mirrored tree with unmirrored versions
Code edit (1 edits merged)
Please save this source code
User prompt
i want you to spawn tree when tube comes little bit right of the middle of the screen
Code edit (1 edits merged)
Please save this source code
User prompt
spawn tube faster not velocity i want tube spawn earlier
Code edit (12 edits merged)
Please save this source code
User prompt
vaz geçtim ekranın ortasının biraz sağına gelince tree spawn olsun
User prompt
tree tube ekranın tam ortasına geldiğinde değilde biraz soluna geldiğinde spawn olsun azıcık ekranın ortasının soluna gelince
Code edit (3 edits merged)
Please save this source code
User prompt
make them 1.2 time faster
User prompt
make them 1.5 time faster
Code edit (2 edits merged)
Please save this source code
User prompt
tube ve tree nin velocitysini eşit düzeyde arttır
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
User prompt
spawn 1 tree after 1 second tube spawned
User prompt
create only 1 tree
User prompt
the gap between two trees are 2.1 second
User prompt
and make another tree spawn 2 second later
User prompt
spawn tree 1 second after tube spawned
/**** * Classes ****/ // Character: Dokunulduğunda zıplar. var Character = Container.expand(function () { var self = Container.call(this); self.attachAsset('character', { anchorX: 0.5, anchorY: 0.5 }); self.zIndex = 100; self.velocityY = 0; self.gravity = 0.3; self.jumpStrength = -12; self.update = function () { if (gameStarted) { self.velocityY += self.gravity; self.y += self.velocityY; if (self.y > groundY - 100) { self.y = groundY - 100; self.velocityY = 0; } } }; self.jump = function () { self.velocityY = self.jumpStrength; }; }); // Tree: Tube ile aynı mantık; ancak asset olarak tree kullanılıyor. var Tree = Container.expand(function () { var self = Container.call(this); var bottomUnit = Math.floor(Math.random() * 8) + 1; var topUnit = 9 - bottomUnit; var unitSize = groundY / totalUnits; var bottomHeight = bottomUnit * unitSize; var topHeight = topUnit * unitSize; self.y = groundY; self.bottomTree = self.attachAsset('tree', { anchorX: 0.5, anchorY: 1, width: 300, height: bottomHeight, flipY: 0 }); self.topTree = self.attachAsset('tree', { anchorX: 0.5, anchorY: 0, width: 300, height: topHeight, flipY: 1 }); self.topTree.y = -groundY - 50; // Increase gap by moving the mirrored tree further up self.zIndex = 10; self.x = 2048 + 50; self.velocityX = -3.6; self.spawned = false; self.prevX = self.x; self.update = function () { if (gameStarted) { self.x += self.velocityX; if (!self.spawned && self.prevX > centerX && self.x <= centerX) { self.spawned = true; var newTube = new Tube(); newTube.x = 2048 + 50; game.addChild(newTube); lastSpawner = newTube; } self.prevX = self.x; } }; }); // Tube: Obstacle container – alt parça (tube) yere değiyor, üst parça (tube, flipY) tavana değiyor. var Tube = Container.expand(function () { var self = Container.call(this); // Rastgele: Alt birim 1-8, üst birim = 9 - alt. var bottomUnit = Math.floor(Math.random() * 8) + 1; var topUnit = 9 - bottomUnit; var unitSize = groundY / totalUnits; // Örneğin: groundY/10 var bottomHeight = bottomUnit * unitSize; var topHeight = topUnit * unitSize; // Container'ın y değeri sabit: groundY – böylece container'ın altı (0 yerel koordinat) global groundY'ye denk gelir. self.y = groundY; // Alt parça: anchorY = 1; yerel y = 0 → global y = groundY. self.bottomTube = self.attachAsset('tube', { anchorX: 0.5, anchorY: 1, width: 300, height: bottomHeight, flipY: 0 }); self.topTube = self.attachAsset('tube', { anchorX: 0.5, anchorY: 0, width: 300, height: topHeight, flipY: 1 }); self.topTube.y = -groundY - 50; // Increase gap by moving the mirrored tube further up self.zIndex = 10; self.x = 2048 + 50; // Başlangıçta ekranın çok sağında spawn edilsin. self.velocityX = -3.6; self.spawned = false; // Spawn kontrolü self.prevX = self.x; self.update = function () { if (gameStarted) { self.x += self.velocityX; // Eğer obstacle, centerX’i ilk kez geçiyorsa spawn et. if (!self.spawned && self.prevX > centerX && self.x <= centerX) { self.spawned = true; var newTree = new Tree(); newTree.x = 2048 + 50; // Yeni obstacle ekranın en sağından // newTree.y otomatik olarak container içinde ayarlanıyor (y = groundY). game.addChild(newTree); lastSpawner = newTree; } self.prevX = self.x; } }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ // Sky: En arka katman. /**** * Global Variables ****/ var gameStarted = false; var centerX = 2048 / 2; // Ekranın yatay ortası var groundY = 2732; // Ground'ın (aynı zamanda oyun yüksekliğinin) y konumu var totalUnits = 10; // Ekranı 10 birim kabul ediyoruz var lastSpawner = null; var sky = LK.getAsset('sky', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: groundY / 2, tint: 0x000000 }); sky.zIndex = 0; game.addChild(sky); // Background: Sky'ın üzerinde. var background = LK.getAsset('background', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: groundY / 2 }); background.zIndex = 1; game.addChild(background); // Ground: Obstacle’ların altında kalmaması için ground'un zIndex’ini uygun ayarlayın. var groundAsset = LK.getAsset('ground', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: groundY - 5 }); groundAsset.zIndex = 5; game.addChild(groundAsset); // Character: Ekranın ortasında başlar. var character = game.addChild(new Character()); character.x = 2048 / 2; character.y = groundY / 2; // Dokunma olayı: Ekrana dokununca oyun başlar ve başlangıçta sadece en sağdan bir Tube spawn edilir. game.down = function (x, y, obj) { if (!gameStarted) { gameStarted = true; var initialTube = new Tube(); // initialTube.x = 2048 + 50; // Zaten Tube constructor’da ayarlandı. game.addChild(initialTube); lastSpawner = initialTube; } character.jump(); character.rotation = 0.1; LK.setTimeout(function () { character.rotation = 0; }, 200); }; // Oyun döngüsü. game.update = function () { game.children.forEach(function (child) { if (child.update) { child.update(); } }); game.children.sort(function (a, b) { return (a.zIndex || 0) - (b.zIndex || 0); }); };
===================================================================
--- original.js
+++ change.js
@@ -1,89 +1,120 @@
/****
* Classes
****/
-// Ekranın ortası
-// Character: Dokunulduğunda zıplar, yerçekimi devreye girer.
+// Character: Dokunulduğunda zıplar.
var Character = Container.expand(function () {
var self = Container.call(this);
- var characterGraphics = self.attachAsset('character', {
+ self.attachAsset('character', {
anchorX: 0.5,
anchorY: 0.5
});
- self.zIndex = 99;
+ self.zIndex = 100;
self.velocityY = 0;
self.gravity = 0.3;
self.jumpStrength = -12;
self.update = function () {
if (gameStarted) {
self.velocityY += self.gravity;
self.y += self.velocityY;
- if (self.y > 2732 - 100) {
- // Zemine çarpmayı engelle
- self.y = 2732 - 100;
+ if (self.y > groundY - 100) {
+ self.y = groundY - 100;
self.velocityY = 0;
}
}
};
self.jump = function () {
self.velocityY = self.jumpStrength;
};
});
-// Tree: Sadece hareket eder; tube spawn etme işlevi kaldırıldı.
+// Tree: Tube ile aynı mantık; ancak asset olarak tree kullanılıyor.
var Tree = Container.expand(function () {
var self = Container.call(this);
- var treeGraphics = self.attachAsset('tree', {
+ var bottomUnit = Math.floor(Math.random() * 8) + 1;
+ var topUnit = 9 - bottomUnit;
+ var unitSize = groundY / totalUnits;
+ var bottomHeight = bottomUnit * unitSize;
+ var topHeight = topUnit * unitSize;
+ self.y = groundY;
+ self.bottomTree = self.attachAsset('tree', {
anchorX: 0.5,
- anchorY: 0.5,
+ anchorY: 1,
width: 300,
- height: Math.floor(Math.random() * (4200 - 400 + 1)) + 400
+ height: bottomHeight,
+ flipY: 0
});
- self.zIndex = 5;
+ self.topTree = self.attachAsset('tree', {
+ anchorX: 0.5,
+ anchorY: 0,
+ width: 300,
+ height: topHeight,
+ flipY: 1
+ });
+ self.topTree.y = -groundY - 50; // Increase gap by moving the mirrored tree further up
+ self.zIndex = 10;
+ self.x = 2048 + 50;
self.velocityX = -3.6;
- // Artık spawn için kullanılacak flag ve prevX tanımı opsiyonel, sadece reset için bırakıldı.
- self.prevX = self.x || 2048 + 50;
+ self.spawned = false;
+ self.prevX = self.x;
self.update = function () {
if (gameStarted) {
self.x += self.velocityX;
- self.prevX = self.x;
- if (self.x < -300) {
- self.x = 2048 + 100;
- treeGraphics.height = Math.floor(Math.random() * (3900 - 600 + 1)) + 600;
+ if (!self.spawned && self.prevX > centerX && self.x <= centerX) {
+ self.spawned = true;
+ var newTube = new Tube();
+ newTube.x = 2048 + 50;
+ game.addChild(newTube);
+ lastSpawner = newTube;
}
+ self.prevX = self.x;
}
};
});
-// Tube: Sağdan spawn olur; ekranın ortasına geçerken zincirin lideriyse bir Tree spawn eder.
+// Tube: Obstacle container – alt parça (tube) yere değiyor, üst parça (tube, flipY) tavana değiyor.
var Tube = Container.expand(function () {
var self = Container.call(this);
- var tubeGraphics = self.attachAsset('tube', {
+ // Rastgele: Alt birim 1-8, üst birim = 9 - alt.
+ var bottomUnit = Math.floor(Math.random() * 8) + 1;
+ var topUnit = 9 - bottomUnit;
+ var unitSize = groundY / totalUnits; // Örneğin: groundY/10
+ var bottomHeight = bottomUnit * unitSize;
+ var topHeight = topUnit * unitSize;
+ // Container'ın y değeri sabit: groundY – böylece container'ın altı (0 yerel koordinat) global groundY'ye denk gelir.
+ self.y = groundY;
+ // Alt parça: anchorY = 1; yerel y = 0 → global y = groundY.
+ self.bottomTube = self.attachAsset('tube', {
anchorX: 0.5,
- anchorY: 0.5,
+ anchorY: 1,
width: 300,
- height: Math.floor(Math.random() * (4200 - 400 + 1)) + 400
+ height: bottomHeight,
+ flipY: 0
});
- self.zIndex = 5;
+ self.topTube = self.attachAsset('tube', {
+ anchorX: 0.5,
+ anchorY: 0,
+ width: 300,
+ height: topHeight,
+ flipY: 1
+ });
+ self.topTube.y = -groundY - 50; // Increase gap by moving the mirrored tube further up
+ self.zIndex = 10;
+ self.x = 2048 + 50; // Başlangıçta ekranın çok sağında spawn edilsin.
self.velocityX = -3.6;
- self.spawned = false; // Bu nesne spawn yapıp yapmadığını kontrol eder.
- self.prevX = self.x || 2048 + 50; // Önceki x konumunu tutar.
+ self.spawned = false; // Spawn kontrolü
+ self.prevX = self.x;
self.update = function () {
if (gameStarted) {
self.x += self.velocityX;
- // Zincirin lideri ve henüz spawn yapmamışsa; geçiş anı (önce center'ın sağında, sonra solunda) tespit ediliyor.
- if (self === lastSpawner && !self.spawned && self.prevX > centerX && self.x <= centerX) {
+ // Eğer obstacle, centerX’i ilk kez geçiyorsa spawn et.
+ if (!self.spawned && self.prevX > centerX && self.x <= centerX) {
self.spawned = true;
var newTree = new Tree();
- newTree.x = 2048 + 50; // Sağdan spawn
- newTree.y = 2732 - 150;
+ newTree.x = 2048 + 50; // Yeni obstacle ekranın en sağından
+ // newTree.y otomatik olarak container içinde ayarlanıyor (y = groundY).
game.addChild(newTree);
- lastSpawner = newTree; // Zincirin yeni lideri
+ lastSpawner = newTree;
}
self.prevX = self.x;
- // Ekranın solundan çıktığında resetle.
- if (self.x < -300) {
- self.x = 2048 + 100;
- tubeGraphics.height = Math.floor(Math.random() * (3900 - 600 + 1)) + 600;
- }
}
};
});
@@ -96,66 +127,64 @@
/****
* Game Code
****/
+// Sky: En arka katman.
/****
-* Global Değişkenler
+* Global Variables
****/
-/****
-* Game Kodları
-****/
-// Sky: En arka katman
-var lastSpawner = null; // Zincirin spawn yapacak son nesnesi
var gameStarted = false;
-var centerX = 2048 / 2;
+var centerX = 2048 / 2; // Ekranın yatay ortası
+var groundY = 2732; // Ground'ın (aynı zamanda oyun yüksekliğinin) y konumu
+var totalUnits = 10; // Ekranı 10 birim kabul ediyoruz
+var lastSpawner = null;
var sky = LK.getAsset('sky', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
- y: 2732 / 2,
+ y: groundY / 2,
tint: 0x000000
});
sky.zIndex = 0;
game.addChild(sky);
-// Background: Sky'ın hemen üzerinde
+// Background: Sky'ın üzerinde.
var background = LK.getAsset('background', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
- y: 2732 / 2
+ y: groundY / 2
});
background.zIndex = 1;
game.addChild(background);
-// Ground: Tube ve Tree'den daha yüksek z-index
-var ground = LK.getAsset('ground', {
+// Ground: Obstacle’ların altında kalmaması için ground'un zIndex’ini uygun ayarlayın.
+var groundAsset = LK.getAsset('ground', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
- y: 2732 - 5
+ y: groundY - 5
});
-ground.zIndex = 7;
-game.addChild(ground);
-// Character: Ekranın tam ortasında başlar
+groundAsset.zIndex = 5;
+game.addChild(groundAsset);
+// Character: Ekranın ortasında başlar.
var character = game.addChild(new Character());
character.x = 2048 / 2;
-character.y = 2732 / 2;
-// Dokunma olayı: Ekrana tıklayınca tube spawn edilir ve oyun başlar.
+character.y = groundY / 2;
+// Dokunma olayı: Ekrana dokununca oyun başlar ve başlangıçta sadece en sağdan bir Tube spawn edilir.
game.down = function (x, y, obj) {
if (!gameStarted) {
gameStarted = true;
var initialTube = new Tube();
- initialTube.x = 2048 + 50;
- initialTube.y = 2732 - 150;
+ // initialTube.x = 2048 + 50; // Zaten Tube constructor’da ayarlandı.
game.addChild(initialTube);
- lastSpawner = initialTube; // Zincirin ilk elemanı
+ lastSpawner = initialTube;
}
character.jump();
character.rotation = 0.1;
LK.setTimeout(function () {
character.rotation = 0;
}, 200);
};
-// Oyun döngüsü: Her frame update fonksiyonlarını çağırır ve z-index sıralaması yapar.
+// Oyun döngüsü.
game.update = function () {
game.children.forEach(function (child) {
if (child.update) {
child.update();
green theme forest by green tones to the sky , not to much detail just simple tree shadows trees has no details just shadowed green and shadowless places, beautiful view. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
hyper realistic nature too reallistic proffational blue sky white clouds yellow sun an over realistic mountain view with full of trees and sun and clouds view a forest of a mountain challangeing mountain road. No background.cool background. view background. No shadows. 2d. In-Game asset. flat