Code edit (3 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'addEventListener')' in or related to this line: 'document.addEventListener("keydown", function (e) {' Line Number: 114
Code edit (1 edits merged)
Please save this source code
User prompt
sağ ve sola kaydırma hareketi ekran ortasına göre değil bulunduğumuz konuma göre olsun
User prompt
mantarlar ve tabela platformun üzerinde olsunlar. yerde olmaları şart değil ama her biri yüksek yada alçak platform üzerinde olsunlar
User prompt
Zıplama temizle tekrar ele al doğal değil
User prompt
Biraz daha ay yüzeyi gibi havadan hizla düşmesin
User prompt
Ziplayınca hemen hizlica düsmesin
User prompt
Oyuncu hem sol sag hemde ziplama aynı anda yapabilsin
User prompt
Hem saga hem zıplama ayni anda calissin
User prompt
Zıplama daha doğal olsun havadayken ikinci bir zıplamaya izin ver 3 olmasın
User prompt
Oyuncu ekrandan çıkmasın
User prompt
Zıplama fizik düzelt
User prompt
Zıplama 45 derecelik açiyla olsun ve biraz daha azalt
User prompt
Zıplama ivmeli olsun
User prompt
Düsman spawn olsun
User prompt
Ölünce ses çal
User prompt
Please fix the bug: 'TypeError: Cannot read properties of null (reading 'y')' in or related to this line: 'if (player.y > 2300) {' Line Number: 282
User prompt
Please fix the bug: 'TypeError: Cannot read properties of null (reading 'update')' in or related to this line: 'player.update();' Line Number: 264
User prompt
Please fix the bug: 'TypeError: Cannot read properties of null (reading 'y')' in or related to this line: 'player.y += player.vy;' Line Number: 260
User prompt
Please fix the bug: 'TypeError: Cannot read properties of null (reading 'y')' in or related to this line: 'if (player.y >= 2300) {' Line Number: 250
User prompt
Please fix the bug: 'TypeError: Cannot read properties of null (reading 'vy')' in or related to this line: 'player.vy += gravity;' Line Number: 235
User prompt
Please fix the bug: 'TypeError: Cannot set properties of null (setting 'vx')' in or related to this line: 'player.vx = 0;' Line Number: 232
User prompt
Oyunu başlat diye bir menü ekle
User prompt
Dene müziği çalsın oyun başlangıcında
/**** * Classes ****/ /**** * Sınıflar ****/ var Enemy = Container.expand(function () { var self = Container.call(this); self.attachAsset('enemy_dino', { anchorX: 0.5, anchorY: 1 }); self.vx = -2; self.update = function () { self.x += self.vx; }; return self; }); var LevelGate = Container.expand(function () { var self = Container.call(this); self.attachAsset('level_gate', { anchorX: 0.5, anchorY: 1 }); self.active = false; return self; }); var Meteor = Container.expand(function () { var self = Container.call(this); self.attachAsset('meteor', { anchorX: 0.5, anchorY: 0.5 }); self.vy = 8; self.update = function () { self.y += self.vy; }; return self; }); var Mushroom = Container.expand(function () { var self = Container.call(this); self.attachAsset('mushroom', { anchorX: 0.5, anchorY: 1 }); self.collected = false; return self; }); var Platform = Container.expand(function () { var self = Container.call(this); self.attachAsset('platform', { anchorX: 0.5, anchorY: 0.5 }); return self; }); var Player = Container.expand(function () { var self = Container.call(this); self.attachAsset('dino_player', { anchorX: 0.5, anchorY: 1 }); self.vx = 0; self.vy = 0; self.isJumping = false; self.update = function () {}; return self; }); /**** * Initialize Game ****/ /**** * Oyunu Başlat ****/ var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ /**** * Varlıklar ****/ LK.playMusic('musicId'); var player = new Player(); player.x = 300; player.y = 2200; var platforms = [], mushrooms = [], enemies = [], meteors = []; var score = 0, mushroomsToNextLevel = 10, canLevelUp = false; var levelGate = null; var platformAsset = LK.getAsset('platform', { anchorX: 0.5, anchorY: 0.5 }); var platformWidth = platformAsset.width; for (var px = 0; px < 2048; px += platformWidth) { var plat = new Platform(); plat.x = px + platformWidth / 2; plat.y = 2300; game.addChild(plat); platforms.push(plat); } game.addChild(player); for (var i = 0; i < mushroomsToNextLevel; i++) { var mush = new Mushroom(); mush.x = 400 + i * 150; mush.y = 2200 - i % 3 * 200; game.addChild(mush); mushrooms.push(mush); } var enemy1 = new Enemy(); enemy1.x = 1200; enemy1.y = 2300; game.addChild(enemy1); enemies.push(enemy1); /**** * Dokunmatik Kontroller ****/ var jumpQueued = false; var isTouching = false; var swipeStartY = null; game.down = function (x, y) { isTouching = true; game.lastTouchX = x; swipeStartY = y; }; game.up = function (x, y) { isTouching = false; game.lastTouchX = undefined; if (typeof swipeStartY === "number" && swipeStartY - y > 80) jumpQueued = true; swipeStartY = null; }; /**** * Ana Oyun Döngüsü ****/ game.update = function () { var speed = 16; var gravity = 7.5; var jumpPower = -110; var maxFallSpeed = 60; if (isTouching && typeof game.lastTouchX === "number") { player.vx = game.lastTouchX < 1024 ? -speed : speed; } else { player.vx = 0; } player.x += player.vx; var playerHalfWidth = player.width ? player.width / 2 : 50; if (player.x - playerHalfWidth < 0) player.x = playerHalfWidth; if (player.x + playerHalfWidth > 2048) player.x = 2048 - playerHalfWidth; if (typeof player.jumpCount === "undefined") player.jumpCount = 0; if (typeof player.isJumping === "undefined") player.isJumping = false; var onPlatform = false, onGround = false, platformY = null; for (var i = 0; i < platforms.length; i++) { var plat = platforms[i]; var platTop = plat.y - plat.height / 2; var feetLast = player.y + 10; if (player.lastY + 10 <= platTop && feetLast >= platTop && player.x > plat.x - plat.width / 2 && player.x < plat.x + plat.width / 2 && player.vy >= 0) { onPlatform = true; platformY = platTop - 10; break; } } if (player.lastY < 2300 && player.y >= 2300) onGround = true; if ((onPlatform || onGround) && player.vy >= 0) { player.jumpCount = 0; player.isJumping = false; } if (jumpQueued && player.jumpCount < 2) { player.vy = jumpPower; player.isJumping = true; player.jumpCount++; jumpQueued = false; } if (!isTouching && player.vy < 0) player.vy += gravity * 1.2; if (player.vy < 0) player.vy += gravity * 0.18;else player.vy += gravity; if (player.vy > maxFallSpeed) player.vy = maxFallSpeed; player.y += player.vy; if (onPlatform) { player.y = platformY; player.vy = 0; player.isJumping = false; player.jumpCount = 0; } if (player.y > 2300) { player.y = 2300; player.vy = 0; player.isJumping = false; player.jumpCount = 0; } player.update(); for (var i = 0; i < mushrooms.length; i++) { var mush = mushrooms[i]; if (!mush.collected && player.intersects(mush)) { mush.collected = true; mush.visible = false; score += 1; if (score >= mushroomsToNextLevel) { canLevelUp = true; if (levelGate) levelGate.active = true; } } } for (var i = 0; i < enemies.length; i++) { var enemy = enemies[i]; enemy.update(); if (player.intersects(enemy)) { LK.getSound('warn').play(); LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); return; } } if (LK.ticks % 120 === 0) { var meteor = new Meteor(); meteor.x = 400 + Math.floor(Math.random() * 1200); meteor.y = -100; game.addChild(meteor); meteors.push(meteor); } for (var i = meteors.length - 1; i >= 0; i--) { var meteor = meteors[i]; meteor.update(); if (player.intersects(meteor)) { LK.getSound('warn').play(); LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); return; } if (meteor.y > 2800) { meteor.destroy(); meteors.splice(i, 1); } } if (!levelGate) { levelGate = new LevelGate(); levelGate.x = 1800; levelGate.y = 1700; game.addChild(levelGate); } if (player.intersects(levelGate)) { if (canLevelUp) LK.showYouWin();else LK.getSound('warn').play(); } }; /**** * Skor ****/ var scoreTxt = new Text2('0', { size: 120, fill: "#fff" }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); var oldGameUpdate = game.update; game.update = function () { scoreTxt.setText(score); oldGameUpdate(); };
===================================================================
--- original.js
+++ change.js
@@ -1,290 +1,215 @@
/****
* Classes
****/
-// Enemy class
+/****
+* Sınıflar
+****/
var Enemy = Container.expand(function () {
var self = Container.call(this);
- var gfx = self.attachAsset('enemy_dino', {
+ self.attachAsset('enemy_dino', {
anchorX: 0.5,
anchorY: 1
});
self.vx = -2;
- self.lastX = 0;
- self.lastY = 0;
self.update = function () {
- self.lastX = self.x;
- self.lastY = self.y;
- // Simple left-right movement
self.x += self.vx;
};
return self;
});
-// LevelGate class
var LevelGate = Container.expand(function () {
var self = Container.call(this);
- var gfx = self.attachAsset('level_gate', {
+ self.attachAsset('level_gate', {
anchorX: 0.5,
anchorY: 1
});
self.active = false;
return self;
});
-// Initialize player
-// Meteor class
var Meteor = Container.expand(function () {
var self = Container.call(this);
- var gfx = self.attachAsset('meteor', {
+ self.attachAsset('meteor', {
anchorX: 0.5,
anchorY: 0.5
});
self.vy = 8;
- self.lastY = 0;
self.update = function () {
- self.lastY = self.y;
self.y += self.vy;
};
return self;
});
-// Mushroom class
var Mushroom = Container.expand(function () {
var self = Container.call(this);
- var gfx = self.attachAsset('mushroom', {
+ self.attachAsset('mushroom', {
anchorX: 0.5,
anchorY: 1
});
self.collected = false;
return self;
});
-// Platform class
var Platform = Container.expand(function () {
var self = Container.call(this);
- var gfx = self.attachAsset('platform', {
+ self.attachAsset('platform', {
anchorX: 0.5,
anchorY: 0.5
});
return self;
});
-// Player class
var Player = Container.expand(function () {
var self = Container.call(this);
- var gfx = self.attachAsset('dino_player', {
+ self.attachAsset('dino_player', {
anchorX: 0.5,
anchorY: 1
});
self.vx = 0;
self.vy = 0;
self.isJumping = false;
- self.lastX = 0;
- self.lastY = 0;
- self.update = function () {
- self.lastX = self.x;
- self.lastY = self.y;
- // Movement and gravity will be handled in game.update
- // Player position is updated in game.update, so nothing to do here
- };
+ self.update = function () {};
return self;
});
/****
* Initialize Game
****/
-// === Klavye kontrolü ===
+/****
+* Oyunu Başlat
+****/
var game = new LK.Game({
backgroundColor: 0x000000
});
/****
* Game Code
****/
-// === Klavye kontrolü ===
-// Play background music at game start
+/****
+* Varlıklar
+****/
LK.playMusic('musicId');
-// Global game objects and state
-var player = null;
-var platforms = [];
-var mushrooms = [];
-var enemies = [];
-var meteors = [];
-var levelGate = null;
-var score = 0;
-var mushroomsToNextLevel = 10;
-var canLevelUp = false;
-// Initialize player
-player = new Player();
+var player = new Player();
player.x = 300;
player.y = 2200;
-// Create a seamless row of platforms spanning the screen horizontally
+var platforms = [],
+ mushrooms = [],
+ enemies = [],
+ meteors = [];
+var score = 0,
+ mushroomsToNextLevel = 10,
+ canLevelUp = false;
+var levelGate = null;
var platformAsset = LK.getAsset('platform', {
anchorX: 0.5,
anchorY: 0.5
});
var platformWidth = platformAsset.width;
-var yBase = 2300;
for (var px = 0; px < 2048; px += platformWidth) {
var plat = new Platform();
plat.x = px + platformWidth / 2;
- plat.y = yBase;
+ plat.y = 2300;
game.addChild(plat);
platforms.push(plat);
}
-// Add player after platforms so player is in front of platforms
game.addChild(player);
-// Example mushrooms
for (var i = 0; i < mushroomsToNextLevel; i++) {
var mush = new Mushroom();
mush.x = 400 + i * 150;
mush.y = 2200 - i % 3 * 200;
game.addChild(mush);
mushrooms.push(mush);
}
-// Example enemy
var enemy1 = new Enemy();
enemy1.x = 1200;
enemy1.y = 2300;
-// Add enemy after player so enemy is in front of player
game.addChild(enemy1);
enemies.push(enemy1);
-// Example meteor (will be dropped randomly in game.update)
-// Touch controls
+/****
+* Dokunmatik Kontroller
+****/
var jumpQueued = false;
var isTouching = false;
var swipeStartY = null;
-// Track both horizontal touch and swipe for jump independently
-game.down = function (x, y, obj) {
+game.down = function (x, y) {
isTouching = true;
game.lastTouchX = x;
swipeStartY = y;
};
-game.up = function (x, y, obj) {
+game.up = function (x, y) {
isTouching = false;
game.lastTouchX = undefined;
- if (typeof swipeStartY === "number" && swipeStartY - y > 80) {
- // Detected upward swipe
- jumpQueued = true;
- }
+ if (typeof swipeStartY === "number" && swipeStartY - y > 80) jumpQueued = true;
swipeStartY = null;
};
+/****
+* Ana Oyun Döngüsü
+****/
game.update = function () {
- // Player movement
var speed = 16;
- var gravity = 7.5; // Softer gravity for more natural jump arc
- var jumpPower = -110; // Jump power
- var maxFallSpeed = 60; // Terminal velocity
- // Horizontal movement: move right if touch is on right half, left if on left half
- // Allow jump and horizontal movement to be triggered simultaneously
+ var gravity = 7.5;
+ var jumpPower = -110;
+ var maxFallSpeed = 60;
if (isTouching && typeof game.lastTouchX === "number") {
- if (game.lastTouchX < 1024) {
- player.vx = -speed;
- } else {
- player.vx = speed;
- }
+ player.vx = game.lastTouchX < 1024 ? -speed : speed;
} else {
player.vx = 0;
}
player.x += player.vx;
- // Prevent player from moving outside the left and right screen boundaries
var playerHalfWidth = player.width ? player.width / 2 : 50;
- if (player.x - playerHalfWidth < 0) {
- player.x = playerHalfWidth;
- }
- if (player.x + playerHalfWidth > 2048) {
- player.x = 2048 - playerHalfWidth;
- }
- // --- Clean, Natural Jump Physics ---
- // Track jump state
- if (typeof player.jumpCount === "undefined") {
- player.jumpCount = 0;
- }
- if (typeof player.isJumping === "undefined") {
- player.isJumping = false;
- }
- if (typeof player.wasOnGround === "undefined") {
- player.wasOnGround = false;
- }
- if (typeof player.wasOnPlatform === "undefined") {
- player.wasOnPlatform = false;
- }
- // Detect platform and ground contact (for landing)
- var onPlatform = false;
- var onGround = false;
- var platformY = null;
+ if (player.x - playerHalfWidth < 0) player.x = playerHalfWidth;
+ if (player.x + playerHalfWidth > 2048) player.x = 2048 - playerHalfWidth;
+ if (typeof player.jumpCount === "undefined") player.jumpCount = 0;
+ if (typeof player.isJumping === "undefined") player.isJumping = false;
+ var onPlatform = false,
+ onGround = false,
+ platformY = null;
for (var i = 0; i < platforms.length; i++) {
var plat = platforms[i];
- // Check if player feet cross platform top (falling)
var platTop = plat.y - plat.height / 2;
- var playerFeetLast = player.lastY + 10;
- var playerFeetNow = player.y + 10;
- if (playerFeetLast <= platTop && playerFeetNow >= platTop && player.x > plat.x - plat.width / 2 && player.x < plat.x + plat.width / 2 && player.vy >= 0) {
+ var feetLast = player.y + 10;
+ if (player.lastY + 10 <= platTop && feetLast >= platTop && player.x > plat.x - plat.width / 2 && player.x < plat.x + plat.width / 2 && player.vy >= 0) {
onPlatform = true;
platformY = platTop - 10;
break;
}
}
- if (player.lastY < 2300 && player.y >= 2300) {
- onGround = true;
- }
- // Reset jump count and state if landed
+ if (player.lastY < 2300 && player.y >= 2300) onGround = true;
if ((onPlatform || onGround) && player.vy >= 0) {
player.jumpCount = 0;
player.isJumping = false;
}
- // Allow jump if jumpQueued and jumpCount < 2
if (jumpQueued && player.jumpCount < 2) {
player.vy = jumpPower;
player.isJumping = true;
player.jumpCount++;
jumpQueued = false;
}
- // Variable jump height: if player releases touch while rising, cut jump short
- if (!isTouching && player.vy < 0) {
- player.vy += gravity * 1.2; // Slightly faster fall if jump released early
- }
- // Gravity: smooth, natural arc
- if (player.vy < 0) {
- // Rising: gentle gravity for floaty apex
- player.vy += gravity * 0.18;
- } else {
- // Falling: normal gravity
- player.vy += gravity;
- }
- if (player.vy > maxFallSpeed) {
- player.vy = maxFallSpeed;
- }
- // Apply vertical movement
+ if (!isTouching && player.vy < 0) player.vy += gravity * 1.2;
+ if (player.vy < 0) player.vy += gravity * 0.18;else player.vy += gravity;
+ if (player.vy > maxFallSpeed) player.vy = maxFallSpeed;
player.y += player.vy;
- // Snap to platform if landed
if (onPlatform) {
player.y = platformY;
player.vy = 0;
player.isJumping = false;
player.jumpCount = 0;
}
- // Snap to ground if landed
if (player.y > 2300) {
player.y = 2300;
player.vy = 0;
player.isJumping = false;
player.jumpCount = 0;
}
- // Update player lastX/lastY for event logic
player.update();
- // Mushroom collection
for (var i = 0; i < mushrooms.length; i++) {
var mush = mushrooms[i];
if (!mush.collected && player.intersects(mush)) {
mush.collected = true;
mush.visible = false;
score += 1;
if (score >= mushroomsToNextLevel) {
canLevelUp = true;
- if (levelGate) {
- levelGate.active = true;
- }
+ if (levelGate) levelGate.active = true;
}
}
}
- // Enemy collision
for (var i = 0; i < enemies.length; i++) {
var enemy = enemies[i];
enemy.update();
if (player.intersects(enemy)) {
@@ -293,17 +218,15 @@
LK.showGameOver();
return;
}
}
- // Meteor drop (randomly every 120 ticks)
if (LK.ticks % 120 === 0) {
var meteor = new Meteor();
meteor.x = 400 + Math.floor(Math.random() * 1200);
meteor.y = -100;
game.addChild(meteor);
meteors.push(meteor);
}
- // Meteor update and collision
for (var i = meteors.length - 1; i >= 0; i--) {
var meteor = meteors[i];
meteor.update();
if (player.intersects(meteor)) {
@@ -316,32 +239,27 @@
meteor.destroy();
meteors.splice(i, 1);
}
}
- // Level gate logic
if (!levelGate) {
levelGate = new LevelGate();
levelGate.x = 1800;
levelGate.y = 1700;
game.addChild(levelGate);
}
if (player.intersects(levelGate)) {
- if (canLevelUp) {
- LK.showYouWin();
- } else {
- // Play warning sound
- LK.getSound('warn').play();
- }
+ if (canLevelUp) LK.showYouWin();else LK.getSound('warn').play();
}
};
-// Score display
+/****
+* Skor
+****/
var scoreTxt = new Text2('0', {
size: 120,
fill: "#fff"
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
-// Update score display in game.update
var oldGameUpdate = game.update;
game.update = function () {
scoreTxt.setText(score);
oldGameUpdate();
Fullscreen modern App Store landscape banner, 16:9, high definition, for a game titled "Dino Mantar Macerası" and with the description "Sevimli bir dinozorla platformlarda zıplayıp mantar topla, düşmanlardan ve meteorlardan kaç, 10 mantar sonrası tabeladan yeni seviyeye geç!". No text on banner!
yukardan aşağıya olsun açısı
sevimli bir dinazor olsun ancak açık kırmızı ve dişleri olan azcık da kızgın olsun. High contrast. No shadows
mantarın yüzü olmasın altı da düz olsun platforma gelecek
Üzerine EXIT yazalım.
sağ ve sol kenar keskin olsun
Kalp. In-Game asset. 2d