User prompt
mushroom spawn hem yatayda hem de dikey de aralıklı olsun. Düşman dah az sıklıkla spawn olsun. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Mantarlar 3 seviye yükseklikte spawn olsun. En alt seviye oyuncunun boyundan yüksek ve her bir seviye arası oyuncu boyu kadar olsun
User prompt
İlk düşman ve sonrasında yeni düsmanlar ekranın gözükmeyen sag tarafından spawn olsun
User prompt
Soldan bir düşman sorunlu spawn olup gözüküyor. Bunu düzeltir misin
User prompt
İlk düşman da ekranın sagindan spawn olup gelsin.
User prompt
Düşman sağdan gelsin soldan kaybolan tüm nesneler hafızadan ve ekrandan silinsin ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Düşman spawn iyileştir.
User prompt
Düşman da arada bir spawn olup gelsin.
User prompt
increase jump horizontal velocity
User prompt
Dokununca zıplama 2 kat olsun ve yöne göre hafif sağ yada sola gitsin
User prompt
mushroom collect sesi collect asset çalsın ve efekti degistir. Tüm ekran beyaz parlasın ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
mushroom collect efekti 3 kez tekrar etsin. Yanıp sönsün yani. Ayrica elma ısırma sesi çiksin ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Mushroom collect efekti daha hızlı başlasın geç bitsin ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Mantar collect anında biraz bekle
User prompt
Please fix the bug: 'TypeError: tween.create is not a function' in or related to this line: 'tween.create(player).to({' Line Number: 350 ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'then')' in or related to this line: 'tween(player, {' Line Number: 350
User prompt
Mantar toplama efekti biraz daha belirgin olsun titreme gibi
User prompt
Please fix the bug: 'TypeError: tween.create is not a function' in or related to this line: 'tween.create(player).to({' Line Number: 349 ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Please fix the bug: 'TypeError: tween.to is not a function' in or related to this line: 'tween.to(player, {' Line Number: 349
User prompt
Please fix the bug: 'ReferenceError: tween is not defined' in or related to this line: 'tween.to(player, {' Line Number: 343 ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Mantarlar 2 kat küçük olsun. Aralarında enaz 1, 2 yada 3 mantar boyu katlarda yükseklik farkı olsun ve aralikli gelsin. Oyuncu mantari yiyince yeşil renk ışıma yapsın ve titresin. Mantar yiyince ses çiksın
User prompt
Jump height 2 kat olsun. Havada 0.35 sn kalsın.
User prompt
Oyuncu zıplama 2 kat yüksek olsun. Sola saga dokunma ile gitnesin.
User prompt
Walk asset kaldır. Mantarları ve tabelayı 2 kat büyut. Mantar spawn yerlerini zıplamaya göre düzenle. oyuncu dokunmayla değil swipe ile hareket etsin. Oyuncu zıplaması swipe ve dokunma ile olsun.
User prompt
Platformu yavaşlat. Mantarlar ve tabela içinde spawn oluştur. Tabela yerde spawn olsun, mantarlar degisik yuksekliklerde
/**** * Classes ****/ // Enemy class var Enemy = Container.expand(function () { var self = Container.call(this); var gfx = self.attachAsset('enemy_dino', { anchorX: 0.5, anchorY: 1, scaleX: 2, scaleY: 2 }); 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', { 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', { 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', { 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', { 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', { anchorX: 0.5, anchorY: 1, scaleX: 2, scaleY: 2 }); 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; // Rotate player to face direction of movement if (self.vx > 0) { // Face right if (gfx.scaleX < 0) { gfx.scaleX = Math.abs(gfx.scaleX); } } else if (self.vx < 0) { // Face left (flip horizontally) if (gfx.scaleX > 0) { gfx.scaleX = -Math.abs(gfx.scaleX); } } // Movement and gravity will be handled in game.update // Player position is updated in game.update, so nothing to do here }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ // Play background music at game start 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(); player.x = 300; player.y = 2200; // Create a seamless row of platforms spanning the screen horizontally 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; game.addChild(plat); platforms.push(plat); } // Add player after platforms so player is in front of platforms game.addChild(player); // Mushrooms will now spawn dynamically with platforms // 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 var jumpQueued = false; var isTouching = false; var swipeStartY = null; var swipeActive = false; var swipeDetected = false; var swipeThreshold = 80; // Track both horizontal touch and swipe for jump independently game.down = function (x, y, obj) { isTouching = true; game.lastTouchX = x; swipeStartY = y; swipeActive = true; swipeDetected = false; // Determine intended direction based on touch position relative to player if (player && typeof player.x === "number") { if (x > player.x) { game.touchDirection = 1; // right } else if (x < player.x) { game.touchDirection = -1; // left } else { game.touchDirection = 0; } } else { game.touchDirection = 0; } }; game.move = function (x, y, obj) { // Detect upward swipe for jump, but allow horizontal movement at the same time // Only allow one jump per upward swipe gesture if (swipeActive && typeof swipeStartY === "number" && swipeStartY - y > swipeThreshold && !swipeDetected && player.jumpCount < 0.5) { jumpQueued = true; swipeDetected = true; // Reduce jump power by half for swipe jump player._swipeJump = true; } // Always update lastTouchX for horizontal movement if (isTouching) { game.lastTouchX = x; // Move player in the direction of swipe if (x > player.x + 10) { game.touchDirection = 1; // right } else if (x < player.x - 10) { game.touchDirection = -1; // left } else { game.touchDirection = 0; } } }; game.up = function (x, y, obj) { isTouching = false; game.lastTouchX = undefined; swipeActive = false; swipeStartY = null; swipeDetected = false; }; game.update = function () { // Player movement var speed = 16; var gravity = 7.5; // Softer gravity for more natural jump arc var jumpPower = -90; // Jump power var maxFallSpeed = 60; // Terminal velocity // Horizontal movement: move right if swipe started to the right of player, left if to the left // Allow jump and horizontal movement to be triggered simultaneously if (isTouching && typeof game.touchDirection === "number") { if (game.touchDirection === 1) { player.vx = speed; } else if (game.touchDirection === -1) { player.vx = -speed; } else { player.vx = 0; } } 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; 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) { onPlatform = true; platformY = platTop - 10; break; } } if (player.lastY < 2300 && player.y >= 2300) { onGround = true; } // Reset jump count and state if landed if ((onPlatform || onGround) && player.vy >= 0) { player.jumpCount = 0; player.isJumping = false; } // Allow jump if jumpQueued and jumpCount < 0.5 (half the previous max, disables double jump) if (jumpQueued && player.jumpCount < 0.5) { if (player._swipeJump) { player.vy = jumpPower / 2; player._swipeJump = false; } else { player.vy = jumpPower; } player.isJumping = true; player.jumpCount = 0.5; // Always set to 0.5, never allow more than 0.5 jumps 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 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; } } } } // Enemy collision 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; } } // Define edges for element removal and spawning trigger var rightEdge = 2048; // Right edge of the screen var spawnTriggerEdge = 2048 + 200; // Start spawning new platforms when the rightmost is beyond the screen edge var leftEdge = -200; // Left edge for despawning elements // Get asset dimensions for positioning. These calls are lightweight. var platformAsset = LK.getAsset('platform', { anchorX: 0.5, anchorY: 0.5 }); var platformWidth = platformAsset.width; var platformHeight = platformAsset.height; var mushroomAsset = LK.getAsset('mushroom', { anchorX: 0.5, anchorY: 1 }); // anchorY:1 for bottom var mushroomHeight = mushroomAsset.height; // Move existing platforms var platformMoveSpeed = 3; // Platforms are now slower for (var i = platforms.length - 1; i >= 0; i--) { var plat = platforms[i]; plat.x -= platformMoveSpeed; if (plat.x + platformWidth / 2 < leftEdge) { // Check if entire platform is off-screen plat.destroy(); platforms.splice(i, 1); } } // Move existing mushrooms for (var i = mushrooms.length - 1; i >= 0; i--) { var mush = mushrooms[i]; if (mush.collected) continue; // Already collected, will be invisible mush.x -= platformMoveSpeed; if (mush.x + mushroomAsset.width / 2 < leftEdge) { // Using mushroomAsset.width for consistency mush.destroy(); mushrooms.splice(i, 1); } } // Move existing level gate if (levelGate) { levelGate.x -= platformMoveSpeed; var levelGateAsset = LK.getAsset('level_gate', { anchorX: 0.5, anchorY: 1 }); // anchorY:1 for bottom if (levelGate.x + levelGateAsset.width / 2 < leftEdge) { levelGate.destroy(); levelGate = null; // Allow a new one to spawn if conditions met again } } // Find the rightmost platform's x position (its right edge) var rightmostPlatformEdge = 0; // Default to 0 if no platforms exist if (platforms.length > 0) { var currentRightmostX = -Infinity; for (var i = 0; i < platforms.length; i++) { if (platforms[i].x > currentRightmostX) { currentRightmostX = platforms[i].x; } } rightmostPlatformEdge = currentRightmostX + platformWidth / 2; } // Spawn new platforms if there's space on the right while (rightmostPlatformEdge < spawnTriggerEdge) { var newPlat = new Platform(); newPlat.x = rightmostPlatformEdge === 0 ? platformWidth / 2 : rightmostPlatformEdge + platformWidth / 2; newPlat.y = 2300; // Base Y for platforms game.addChildAt(newPlat, 0); // Add new platforms at the back platforms.push(newPlat); rightmostPlatformEdge = newPlat.x + platformWidth / 2; var platformTopY = newPlat.y - platformHeight / 2; // Chance to spawn a mushroom on this new platform if (Math.random() < 0.25) { // 25% chance for a mushroom var mush = new Mushroom(); mush.x = newPlat.x; // Spawn at varying heights above the platform mush.y = platformTopY - Math.random() * 1.5 * mushroomHeight; game.addChild(mush); // Add mushroom on top of layers mushrooms.push(mush); } // Spawn level gate on this new platform if conditions are met and no gate exists if (canLevelUp && !levelGate) { levelGate = new LevelGate(); levelGate.x = newPlat.x; levelGate.y = platformTopY; // Place bottom of the gate on the platform surface levelGate.active = true; game.addChild(levelGate); // Add gate on top of layers } } // 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)) { LK.getSound('warn').play(); LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); return; } if (meteor.y > 2800) { meteor.destroy(); meteors.splice(i, 1); } } // Level gate will now spawn dynamically on a platform when canLevelUp is true if (levelGate && player.intersects(levelGate)) { // Check if levelGate exists before intersecting if (canLevelUp) { LK.showYouWin(); } else { // Play warning sound LK.getSound('warn').play(); } } }; // Score display 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(); };
/****
* Classes
****/
// Enemy class
var Enemy = Container.expand(function () {
var self = Container.call(this);
var gfx = self.attachAsset('enemy_dino', {
anchorX: 0.5,
anchorY: 1,
scaleX: 2,
scaleY: 2
});
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', {
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', {
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', {
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', {
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', {
anchorX: 0.5,
anchorY: 1,
scaleX: 2,
scaleY: 2
});
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;
// Rotate player to face direction of movement
if (self.vx > 0) {
// Face right
if (gfx.scaleX < 0) {
gfx.scaleX = Math.abs(gfx.scaleX);
}
} else if (self.vx < 0) {
// Face left (flip horizontally)
if (gfx.scaleX > 0) {
gfx.scaleX = -Math.abs(gfx.scaleX);
}
}
// Movement and gravity will be handled in game.update
// Player position is updated in game.update, so nothing to do here
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000
});
/****
* Game Code
****/
// Play background music at game start
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();
player.x = 300;
player.y = 2200;
// Create a seamless row of platforms spanning the screen horizontally
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;
game.addChild(plat);
platforms.push(plat);
}
// Add player after platforms so player is in front of platforms
game.addChild(player);
// Mushrooms will now spawn dynamically with platforms
// 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
var jumpQueued = false;
var isTouching = false;
var swipeStartY = null;
var swipeActive = false;
var swipeDetected = false;
var swipeThreshold = 80;
// Track both horizontal touch and swipe for jump independently
game.down = function (x, y, obj) {
isTouching = true;
game.lastTouchX = x;
swipeStartY = y;
swipeActive = true;
swipeDetected = false;
// Determine intended direction based on touch position relative to player
if (player && typeof player.x === "number") {
if (x > player.x) {
game.touchDirection = 1; // right
} else if (x < player.x) {
game.touchDirection = -1; // left
} else {
game.touchDirection = 0;
}
} else {
game.touchDirection = 0;
}
};
game.move = function (x, y, obj) {
// Detect upward swipe for jump, but allow horizontal movement at the same time
// Only allow one jump per upward swipe gesture
if (swipeActive && typeof swipeStartY === "number" && swipeStartY - y > swipeThreshold && !swipeDetected && player.jumpCount < 0.5) {
jumpQueued = true;
swipeDetected = true;
// Reduce jump power by half for swipe jump
player._swipeJump = true;
}
// Always update lastTouchX for horizontal movement
if (isTouching) {
game.lastTouchX = x;
// Move player in the direction of swipe
if (x > player.x + 10) {
game.touchDirection = 1; // right
} else if (x < player.x - 10) {
game.touchDirection = -1; // left
} else {
game.touchDirection = 0;
}
}
};
game.up = function (x, y, obj) {
isTouching = false;
game.lastTouchX = undefined;
swipeActive = false;
swipeStartY = null;
swipeDetected = false;
};
game.update = function () {
// Player movement
var speed = 16;
var gravity = 7.5; // Softer gravity for more natural jump arc
var jumpPower = -90; // Jump power
var maxFallSpeed = 60; // Terminal velocity
// Horizontal movement: move right if swipe started to the right of player, left if to the left
// Allow jump and horizontal movement to be triggered simultaneously
if (isTouching && typeof game.touchDirection === "number") {
if (game.touchDirection === 1) {
player.vx = speed;
} else if (game.touchDirection === -1) {
player.vx = -speed;
} else {
player.vx = 0;
}
} 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;
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) {
onPlatform = true;
platformY = platTop - 10;
break;
}
}
if (player.lastY < 2300 && player.y >= 2300) {
onGround = true;
}
// Reset jump count and state if landed
if ((onPlatform || onGround) && player.vy >= 0) {
player.jumpCount = 0;
player.isJumping = false;
}
// Allow jump if jumpQueued and jumpCount < 0.5 (half the previous max, disables double jump)
if (jumpQueued && player.jumpCount < 0.5) {
if (player._swipeJump) {
player.vy = jumpPower / 2;
player._swipeJump = false;
} else {
player.vy = jumpPower;
}
player.isJumping = true;
player.jumpCount = 0.5; // Always set to 0.5, never allow more than 0.5 jumps
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
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;
}
}
}
}
// Enemy collision
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;
}
}
// Define edges for element removal and spawning trigger
var rightEdge = 2048; // Right edge of the screen
var spawnTriggerEdge = 2048 + 200; // Start spawning new platforms when the rightmost is beyond the screen edge
var leftEdge = -200; // Left edge for despawning elements
// Get asset dimensions for positioning. These calls are lightweight.
var platformAsset = LK.getAsset('platform', {
anchorX: 0.5,
anchorY: 0.5
});
var platformWidth = platformAsset.width;
var platformHeight = platformAsset.height;
var mushroomAsset = LK.getAsset('mushroom', {
anchorX: 0.5,
anchorY: 1
}); // anchorY:1 for bottom
var mushroomHeight = mushroomAsset.height;
// Move existing platforms
var platformMoveSpeed = 3; // Platforms are now slower
for (var i = platforms.length - 1; i >= 0; i--) {
var plat = platforms[i];
plat.x -= platformMoveSpeed;
if (plat.x + platformWidth / 2 < leftEdge) {
// Check if entire platform is off-screen
plat.destroy();
platforms.splice(i, 1);
}
}
// Move existing mushrooms
for (var i = mushrooms.length - 1; i >= 0; i--) {
var mush = mushrooms[i];
if (mush.collected) continue; // Already collected, will be invisible
mush.x -= platformMoveSpeed;
if (mush.x + mushroomAsset.width / 2 < leftEdge) {
// Using mushroomAsset.width for consistency
mush.destroy();
mushrooms.splice(i, 1);
}
}
// Move existing level gate
if (levelGate) {
levelGate.x -= platformMoveSpeed;
var levelGateAsset = LK.getAsset('level_gate', {
anchorX: 0.5,
anchorY: 1
}); // anchorY:1 for bottom
if (levelGate.x + levelGateAsset.width / 2 < leftEdge) {
levelGate.destroy();
levelGate = null; // Allow a new one to spawn if conditions met again
}
}
// Find the rightmost platform's x position (its right edge)
var rightmostPlatformEdge = 0; // Default to 0 if no platforms exist
if (platforms.length > 0) {
var currentRightmostX = -Infinity;
for (var i = 0; i < platforms.length; i++) {
if (platforms[i].x > currentRightmostX) {
currentRightmostX = platforms[i].x;
}
}
rightmostPlatformEdge = currentRightmostX + platformWidth / 2;
}
// Spawn new platforms if there's space on the right
while (rightmostPlatformEdge < spawnTriggerEdge) {
var newPlat = new Platform();
newPlat.x = rightmostPlatformEdge === 0 ? platformWidth / 2 : rightmostPlatformEdge + platformWidth / 2;
newPlat.y = 2300; // Base Y for platforms
game.addChildAt(newPlat, 0); // Add new platforms at the back
platforms.push(newPlat);
rightmostPlatformEdge = newPlat.x + platformWidth / 2;
var platformTopY = newPlat.y - platformHeight / 2;
// Chance to spawn a mushroom on this new platform
if (Math.random() < 0.25) {
// 25% chance for a mushroom
var mush = new Mushroom();
mush.x = newPlat.x;
// Spawn at varying heights above the platform
mush.y = platformTopY - Math.random() * 1.5 * mushroomHeight;
game.addChild(mush); // Add mushroom on top of layers
mushrooms.push(mush);
}
// Spawn level gate on this new platform if conditions are met and no gate exists
if (canLevelUp && !levelGate) {
levelGate = new LevelGate();
levelGate.x = newPlat.x;
levelGate.y = platformTopY; // Place bottom of the gate on the platform surface
levelGate.active = true;
game.addChild(levelGate); // Add gate on top of layers
}
}
// 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)) {
LK.getSound('warn').play();
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
return;
}
if (meteor.y > 2800) {
meteor.destroy();
meteors.splice(i, 1);
}
}
// Level gate will now spawn dynamically on a platform when canLevelUp is true
if (levelGate && player.intersects(levelGate)) {
// Check if levelGate exists before intersecting
if (canLevelUp) {
LK.showYouWin();
} else {
// Play warning sound
LK.getSound('warn').play();
}
}
};
// Score display
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