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"); var storage = LK.import("@upit/storage.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 = -5; 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.8; self.jumpPower = -20; 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; }); var LuckyBlock = Container.expand(function () { var self = Container.call(this); var luckyBlockGraphics = self.attachAsset('luckyBlock', { anchorX: 0.5, anchorY: 0.5 }); self.collected = false; 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; var lastDistanceMilestone = 0; var dayNightTimer = 0; var isDayTime = true; var health = 5; var maxHealth = 5; var healthBars = []; var bestDistance = storage.bestDistance || 0; var luckyBlock = null; var lives = 5; var maxLives = 10; // 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); // Create best distance display in top-right corner var bestDistanceText = new Text2('Best: ' + bestDistance, { size: 50, fill: 0xFFD700 }); bestDistanceText.anchor.set(1.0, 0); LK.gui.topRight.addChild(bestDistanceText); // Create health bars in top-left corner for (var h = 0; h < 5; h++) { var healthBar = LK.getAsset('healthBar', { anchorX: 0.5, anchorY: 0.5, x: 150 + h * 70, // Space them out horizontally y: 100 }); healthBars.push(healthBar); LK.gui.topLeft.addChild(healthBar); } // Function to update health bar display function updateHealthBars() { for (var i = 0; i < healthBars.length; i++) { if (i < health) { healthBars[i].alpha = 1.0; // Show full health } else { healthBars[i].alpha = 0.3; // Show dimmed for lost health } } } // Initialize health bars display updateHealthBars(); // 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 with gaps var randomSpawnInterval = blockSpawnInterval + Math.floor(Math.random() * 40) - 20; // ±20 frames variation if (blockSpawnTimer >= randomSpawnInterval) { blockSpawnTimer = 0; // 50% chance to spawn a block (creates gaps) if (Math.random() < 0.5) { // Create new block on top of ground var newBlock = new Block(); newBlock.x = 2200; // Spawn off-screen right // Spawn blocks on top of the ground surface newBlock.y = 2652; // Ground surface level (2732 - 80) // Set speed based on current distance milestone var currentMilestone = Math.floor(distance / 1000); var speedMultiplier = 1 + currentMilestone * 0.5; newBlock.speed = -5 * speedMultiplier; blocks.push(newBlock); game.addChild(newBlock); } // Spawn lucky block occasionally above character's head level if (Math.random() < 0.1 && !luckyBlock) { // 10% chance and only if no lucky block exists luckyBlock = new LuckyBlock(); luckyBlock.x = 2200; // Spawn off-screen right luckyBlock.y = character.y - 150; // Above character's head level luckyBlock.lastIntersecting = false; game.addChild(luckyBlock); // Display "Lucky Blok has a spawned" message var luckyMessage = new Text2('Lucky Blok has a spawned', { size: 80, fill: 0xFFFF00, // Yellow color stroke: 0x000000, // Black outline strokeThickness: 4 }); luckyMessage.anchor.set(0.5, 0.5); luckyMessage.x = 1024; // Center of screen luckyMessage.y = 400; // Upper part of screen game.addChild(luckyMessage); // Animate the message to fade out after 2 seconds tween(luckyMessage, { alpha: 0 }, { duration: 2000, easing: tween.easeOut, onFinish: function onFinish() { luckyMessage.destroy(); } }); } } // 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, 500); // Reduce health health--; // Update health bar display updateHealthBars(); // Check if game over if (health <= 0) { // Update best distance if current is higher var currentDistance = Math.floor(distance / 10); if (currentDistance > bestDistance) { bestDistance = currentDistance; storage.bestDistance = bestDistance; } LK.showGameOver(); return; } } block.lastIntersecting = currentIntersecting; } // Update lucky block if (luckyBlock) { // Move lucky block left luckyBlock.x -= gameSpeed; // Remove if off-screen if (luckyBlock.x < -200) { luckyBlock.destroy(); luckyBlock = null; } else { // Check collision with character for life bonus var luckyIntersecting = character.intersects(luckyBlock); if (!luckyBlock.lastIntersecting && luckyIntersecting && !luckyBlock.collected) { // Lucky block collected - add life luckyBlock.collected = true; lives++; if (lives > maxLives) lives = maxLives; // Increase health up to maximum 1 bonus var healthBonus = Math.min(1, maxHealth - health); health += healthBonus; // Update health bar display updateHealthBars(); // Play sound and visual effect LK.getSound('powerup').play(); LK.effects.flashScreen(0x00FF00, 300); // Green flash // Remove lucky block luckyBlock.destroy(); luckyBlock = null; } if (luckyBlock) { luckyBlock.lastIntersecting = luckyIntersecting; } } } // Check if character fell off screen var currentGroundCheck = character.y <= character.groundY + 10; if (lastGroundCheck && !currentGroundCheck && character.y > 2800) { // Character fell off screen // Update best distance if current is higher var currentDistance = Math.floor(distance / 10); if (currentDistance > bestDistance) { bestDistance = currentDistance; storage.bestDistance = bestDistance; } LK.showGameOver(); return; } lastGroundCheck = currentGroundCheck; // Speed up blocks every 1000 distance var currentDistanceMilestone = Math.floor(distance / 1000); if (currentDistanceMilestone > (lastDistanceMilestone || 0)) { // Calculate new speed multiplier (0.5x faster each 1000 distance) var speedMultiplier = 1 + currentDistanceMilestone * 0.5; var newBlockSpeed = -5 * speedMultiplier; // Update speed for all existing blocks for (var k = 0; k < blocks.length; k++) { blocks[k].speed = newBlockSpeed; } // Update the milestone tracker lastDistanceMilestone = currentDistanceMilestone; } // Day/Night cycle - every 2 minutes (7200 ticks at 60fps) dayNightTimer++; if (dayNightTimer >= 7200) { dayNightTimer = 0; isDayTime = !isDayTime; var targetColor = isDayTime ? 0x87CEEB : 0x191970; // Day blue vs Night dark blue tween(game, { backgroundColor: targetColor }, { duration: 2000, easing: tween.easeInOut }); } // Increase difficulty over time if (LK.ticks % 600 === 0) { // Every 10 seconds if (blockSpawnInterval > 45) { blockSpawnInterval -= 5; } if (gameSpeed < 12) { gameSpeed += 0.5; } } };
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.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 = -5;
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.8;
self.jumpPower = -20;
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;
});
var LuckyBlock = Container.expand(function () {
var self = Container.call(this);
var luckyBlockGraphics = self.attachAsset('luckyBlock', {
anchorX: 0.5,
anchorY: 0.5
});
self.collected = false;
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;
var lastDistanceMilestone = 0;
var dayNightTimer = 0;
var isDayTime = true;
var health = 5;
var maxHealth = 5;
var healthBars = [];
var bestDistance = storage.bestDistance || 0;
var luckyBlock = null;
var lives = 5;
var maxLives = 10;
// 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);
// Create best distance display in top-right corner
var bestDistanceText = new Text2('Best: ' + bestDistance, {
size: 50,
fill: 0xFFD700
});
bestDistanceText.anchor.set(1.0, 0);
LK.gui.topRight.addChild(bestDistanceText);
// Create health bars in top-left corner
for (var h = 0; h < 5; h++) {
var healthBar = LK.getAsset('healthBar', {
anchorX: 0.5,
anchorY: 0.5,
x: 150 + h * 70,
// Space them out horizontally
y: 100
});
healthBars.push(healthBar);
LK.gui.topLeft.addChild(healthBar);
}
// Function to update health bar display
function updateHealthBars() {
for (var i = 0; i < healthBars.length; i++) {
if (i < health) {
healthBars[i].alpha = 1.0; // Show full health
} else {
healthBars[i].alpha = 0.3; // Show dimmed for lost health
}
}
}
// Initialize health bars display
updateHealthBars();
// 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 with gaps
var randomSpawnInterval = blockSpawnInterval + Math.floor(Math.random() * 40) - 20; // ±20 frames variation
if (blockSpawnTimer >= randomSpawnInterval) {
blockSpawnTimer = 0;
// 50% chance to spawn a block (creates gaps)
if (Math.random() < 0.5) {
// Create new block on top of ground
var newBlock = new Block();
newBlock.x = 2200; // Spawn off-screen right
// Spawn blocks on top of the ground surface
newBlock.y = 2652; // Ground surface level (2732 - 80)
// Set speed based on current distance milestone
var currentMilestone = Math.floor(distance / 1000);
var speedMultiplier = 1 + currentMilestone * 0.5;
newBlock.speed = -5 * speedMultiplier;
blocks.push(newBlock);
game.addChild(newBlock);
}
// Spawn lucky block occasionally above character's head level
if (Math.random() < 0.1 && !luckyBlock) {
// 10% chance and only if no lucky block exists
luckyBlock = new LuckyBlock();
luckyBlock.x = 2200; // Spawn off-screen right
luckyBlock.y = character.y - 150; // Above character's head level
luckyBlock.lastIntersecting = false;
game.addChild(luckyBlock);
// Display "Lucky Blok has a spawned" message
var luckyMessage = new Text2('Lucky Blok has a spawned', {
size: 80,
fill: 0xFFFF00,
// Yellow color
stroke: 0x000000,
// Black outline
strokeThickness: 4
});
luckyMessage.anchor.set(0.5, 0.5);
luckyMessage.x = 1024; // Center of screen
luckyMessage.y = 400; // Upper part of screen
game.addChild(luckyMessage);
// Animate the message to fade out after 2 seconds
tween(luckyMessage, {
alpha: 0
}, {
duration: 2000,
easing: tween.easeOut,
onFinish: function onFinish() {
luckyMessage.destroy();
}
});
}
}
// 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, 500);
// Reduce health
health--;
// Update health bar display
updateHealthBars();
// Check if game over
if (health <= 0) {
// Update best distance if current is higher
var currentDistance = Math.floor(distance / 10);
if (currentDistance > bestDistance) {
bestDistance = currentDistance;
storage.bestDistance = bestDistance;
}
LK.showGameOver();
return;
}
}
block.lastIntersecting = currentIntersecting;
}
// Update lucky block
if (luckyBlock) {
// Move lucky block left
luckyBlock.x -= gameSpeed;
// Remove if off-screen
if (luckyBlock.x < -200) {
luckyBlock.destroy();
luckyBlock = null;
} else {
// Check collision with character for life bonus
var luckyIntersecting = character.intersects(luckyBlock);
if (!luckyBlock.lastIntersecting && luckyIntersecting && !luckyBlock.collected) {
// Lucky block collected - add life
luckyBlock.collected = true;
lives++;
if (lives > maxLives) lives = maxLives;
// Increase health up to maximum 1 bonus
var healthBonus = Math.min(1, maxHealth - health);
health += healthBonus;
// Update health bar display
updateHealthBars();
// Play sound and visual effect
LK.getSound('powerup').play();
LK.effects.flashScreen(0x00FF00, 300); // Green flash
// Remove lucky block
luckyBlock.destroy();
luckyBlock = null;
}
if (luckyBlock) {
luckyBlock.lastIntersecting = luckyIntersecting;
}
}
}
// Check if character fell off screen
var currentGroundCheck = character.y <= character.groundY + 10;
if (lastGroundCheck && !currentGroundCheck && character.y > 2800) {
// Character fell off screen
// Update best distance if current is higher
var currentDistance = Math.floor(distance / 10);
if (currentDistance > bestDistance) {
bestDistance = currentDistance;
storage.bestDistance = bestDistance;
}
LK.showGameOver();
return;
}
lastGroundCheck = currentGroundCheck;
// Speed up blocks every 1000 distance
var currentDistanceMilestone = Math.floor(distance / 1000);
if (currentDistanceMilestone > (lastDistanceMilestone || 0)) {
// Calculate new speed multiplier (0.5x faster each 1000 distance)
var speedMultiplier = 1 + currentDistanceMilestone * 0.5;
var newBlockSpeed = -5 * speedMultiplier;
// Update speed for all existing blocks
for (var k = 0; k < blocks.length; k++) {
blocks[k].speed = newBlockSpeed;
}
// Update the milestone tracker
lastDistanceMilestone = currentDistanceMilestone;
}
// Day/Night cycle - every 2 minutes (7200 ticks at 60fps)
dayNightTimer++;
if (dayNightTimer >= 7200) {
dayNightTimer = 0;
isDayTime = !isDayTime;
var targetColor = isDayTime ? 0x87CEEB : 0x191970; // Day blue vs Night dark blue
tween(game, {
backgroundColor: targetColor
}, {
duration: 2000,
easing: tween.easeInOut
});
}
// Increase difficulty over time
if (LK.ticks % 600 === 0) {
// Every 10 seconds
if (blockSpawnInterval > 45) {
blockSpawnInterval -= 5;
}
if (gameSpeed < 12) {
gameSpeed += 0.5;
}
}
};
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