User prompt
can barının resmi outline siyah içi transparent olsun
User prompt
oyunun sol üst köşesine 3 can barı ekle, karakterimiz her defasında kaktüse çarparsa -1 can barı gider. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
karakterimizin yer çekimini azalt
User prompt
karakterimizin yer çekimini 1 yap
User prompt
oyunda her 2 dakikada bir oyunun arka planı gece veya gündüz olsun ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
oyunda her 1000 distance ulaşınca oyunun arkaplanı gece veya gündüz olsun
User prompt
karakterimizin yer çekimini 0.6'dan 0.8 yap
User prompt
oyunda her 1000 distance ulaşınca bloklar 0.5x hızlansın
User prompt
oyunda yol kat ettikçe blokların hızı 1x hızlı olsun.
User prompt
bloklar ground'un üstünde random hızda spawnlansın
User prompt
bloklar y eksenin en aşağısında random hızda spawnlansın
User prompt
bloklar random spawnlansın
User prompt
karakterimizin yer çekimini 1.5x artır
User prompt
karakterimizin yer çekimini azalt
User prompt
bloklar y eksenin aşağısından spawn olsunlarki blokların üstünden zıplayabilelim
Code edit (1 edits merged)
Please save this source code
User prompt
Block Jumper
Initial prompt
make a basic mario character,and blocks are spawned according to the y axis so that we can jump over the blocks.
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var Block = Container.expand(function () { var self = Container.call(this); var blockGraphics = self.attachAsset('block', { anchorX: 0.5, anchorY: 1.0 }); self.speed = -8; self.update = function () { self.x += self.speed; }; return self; }); var Character = Container.expand(function () { var self = Container.call(this); var characterGraphics = self.attachAsset('character', { anchorX: 0.5, anchorY: 1.0 }); self.velocityY = 0; self.gravity = 0.6; self.jumpPower = -16; self.isGrounded = false; self.groundY = 2652; // Ground level self.jump = function () { if (self.isGrounded) { self.velocityY = self.jumpPower; self.isGrounded = false; LK.getSound('jump').play(); } }; self.update = function () { // Apply gravity self.velocityY += self.gravity; self.y += self.velocityY; // Ground collision if (self.y >= self.groundY) { self.y = self.groundY; self.velocityY = 0; self.isGrounded = true; } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x87CEEB }); /**** * Game Code ****/ // Game variables var character; var blocks = []; var gameSpeed = 8; var blockSpawnTimer = 0; var blockSpawnInterval = 90; // frames between spawns var distance = 0; var lastGroundCheck = true; // Create ground var ground = game.addChild(LK.getAsset('ground', { anchorX: 0, anchorY: 1.0, x: 0, y: 2732 })); // Create character character = game.addChild(new Character()); character.x = 300; character.y = character.groundY; // Create score display var scoreText = new Text2('Distance: 0', { size: 60, fill: 0xFFFFFF }); scoreText.anchor.set(0.5, 0); LK.gui.top.addChild(scoreText); // Touch controls game.down = function (x, y, obj) { character.jump(); }; // Game update loop game.update = function () { // Update distance distance += gameSpeed; LK.setScore(Math.floor(distance / 10)); scoreText.setText('Distance: ' + Math.floor(distance / 10)); // Spawn blocks blockSpawnTimer++; // Random spawn interval for varied timing var randomSpawnInterval = blockSpawnInterval + Math.floor(Math.random() * 40) - 20; // ±20 frames variation if (blockSpawnTimer >= randomSpawnInterval) { blockSpawnTimer = 0; // Create new block at bottom of screen var newBlock = new Block(); newBlock.x = 2200; // Spawn off-screen right // Spawn blocks at the very bottom of the screen (y-axis bottom) newBlock.y = 2732; // Bottom of screen blocks.push(newBlock); game.addChild(newBlock); } // Update blocks for (var i = blocks.length - 1; i >= 0; i--) { var block = blocks[i]; // Track previous position for collision detection if (block.lastIntersecting === undefined) { block.lastIntersecting = false; } // Remove blocks that have moved off-screen if (block.x < -200) { block.destroy(); blocks.splice(i, 1); continue; } // Check collision with character var currentIntersecting = character.intersects(block); if (!block.lastIntersecting && currentIntersecting) { // Collision detected LK.getSound('collision').play(); LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); return; } block.lastIntersecting = currentIntersecting; } // Check if character fell off screen var currentGroundCheck = character.y <= character.groundY + 10; if (lastGroundCheck && !currentGroundCheck && character.y > 2800) { // Character fell off screen LK.showGameOver(); return; } lastGroundCheck = currentGroundCheck; // Increase difficulty over time if (LK.ticks % 600 === 0) { // Every 10 seconds if (blockSpawnInterval > 45) { blockSpawnInterval -= 5; } if (gameSpeed < 12) { gameSpeed += 0.5; } // Update block speed for existing blocks for (var j = 0; j < blocks.length; j++) { blocks[j].speed = -gameSpeed; } } };
===================================================================
--- original.js
+++ change.js
@@ -97,17 +97,17 @@
LK.setScore(Math.floor(distance / 10));
scoreText.setText('Distance: ' + Math.floor(distance / 10));
// Spawn blocks
blockSpawnTimer++;
- if (blockSpawnTimer >= blockSpawnInterval) {
+ // Random spawn interval for varied timing
+ var randomSpawnInterval = blockSpawnInterval + Math.floor(Math.random() * 40) - 20; // ±20 frames variation
+ if (blockSpawnTimer >= randomSpawnInterval) {
blockSpawnTimer = 0;
- // Create new block at random height
+ // Create new block at bottom of screen
var newBlock = new Block();
newBlock.x = 2200; // Spawn off-screen right
- // Spawn blocks at random heights that can be jumped over
- var minHeight = character.groundY - 150; // Higher blocks (smaller y value)
- var maxHeight = character.groundY; // Ground level blocks
- newBlock.y = minHeight + Math.random() * (maxHeight - minHeight);
+ // Spawn blocks at the very bottom of the screen (y-axis bottom)
+ newBlock.y = 2732; // Bottom of screen
blocks.push(newBlock);
game.addChild(newBlock);
}
// Update blocks
make a mario lucky bloks. In-Game asset. 2d. High contrast. No shadows
make a mario bros. In-Game asset. 2d. High contrast. No shadows
make a mario 8-bit ant. In-Game asset. 2d. High contrast. No shadows
make a mario ground. In-Game asset. 2d. High contrast. No shadows
red heart 8-bit mario. In-Game asset. 2d. High contrast. No shadows