Code edit (11 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'width')' in or related to this line: 'barricade.x = 2048 + spikeTrap.width;' Line Number: 454
Code edit (1 edits merged)
Please save this source code
User prompt
give all text a black outline
User prompt
the +10 signs should fly off to the left side of the screen and be destroyed after a few seconds
User prompt
show a +10 sign and play a sound effect when player picks up a collectible
User prompt
Increase score by 10 when player picks up a collectible
User prompt
add a scorelabel top center of the scree
Code edit (12 edits merged)
Please save this source code
User prompt
make a class for the dustparticle and use its update method instead of running the spread and alpha in an interval
User prompt
the dust particles should spread and go transparent before they disappear
User prompt
use a separate dustparticle asset for the dustparticles
User prompt
Please fix the bug: 'Timeout.tick error: Cannot read properties of undefined (reading 'destroy')' in or related to this line: 'particle.destroy();' Line Number: 169
User prompt
the dustparticle effect should be a small aprticle explosion looking like dust that rises from the ground on jump takeoff and landing
User prompt
make a dustparticle effect when player jumps and lands
Code edit (1 edits merged)
Please save this source code
User prompt
every five seconds, spawn a spiketrap off the right side of the screen, at groundY and bring it onto the screen at gamespeed + boostspeed
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'data')' in or related to this line: 'var startX = obj.event.data.global.x;' Line Number: 236
Code edit (9 edits merged)
Please save this source code
User prompt
plese make the game.up function detect swipes in three directions, either primarily up,primarily down or primarily right
Code edit (1 edits merged)
Please save this source code
Code edit (2 edits merged)
Please save this source code
User prompt
every 30 tiks, spawn a new collectible at random y position and x above 2048, and move it onto the screen
/**** * Classes ****/ /*** TODO: - Make a tall barricade or something where the dash movement is neccessary. - Make a low barrier where the duck movement is neccessary. - Pause to explain the jump, dash and duck mechanics first time corresponding obstacles appear. - Music - Sound effects - Difficulty ramping. - Make sure collectibles aren't moved to right side on exit, but destroyed. - Consider higher score for higher flying collectibles, maybe also make each fly at specific height, and the valuable ones rarer. Or maybe unavailable at first. - Title, description, hashtags, icon and banner image. Måske Endless Dwarven Run i stedet for Viking. */ var Collectible = Container.expand(function () { var self = Container.call(this); var assetTypes = ['snacks', 'snacks2', 'snacks3', 'snacks4', 'snacks5', 'snacks6', 'snacks7']; var randomAsset = assetTypes[Math.floor(Math.random() * assetTypes.length)]; var collectibleGraphics = self.attachAsset(randomAsset, { anchorX: 0.5, anchorY: 0.5 }); self.speed = 2 + Math.random() * 2; self.update = function () { // Collectible update logic if needed }; }); var DustParticle = Container.expand(function () { var self = Container.call(this); var dustParticleGraphics = self.attachAsset('dustParticle', { anchorX: 0.5, anchorY: 0.5 }); self.spreadX = (Math.random() - 0.5) * 10; self.spreadY = (Math.random() - 0.5) * 10; self.fadeStep = 0.02; self.update = function () { if (self.alpha > 0) { self.x += self.spreadX; self.y += self.spreadY; self.alpha -= self.fadeStep; } else { self.destroy(); } }; }); var Obstacle = Container.expand(function () { var self = Container.call(this); var obstacleGraphics = self.attachAsset('spikeTrap', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 5; self.update = function () { self.y += self.speed; if (self.y > 2732) { self.destroy(); } }; }); //<Assets used in the game will automatically appear here> // Class for the player character var Player = Container.expand(function () { var self = Container.call(this); self.playerWalkGraphics = self.attachAsset('playerWalk', { anchorX: 0.5, anchorY: 0.5 }); self.playerJumpGraphics = self.attachAsset('playerJump', { anchorX: 0.5, anchorY: 0.5, alpha: 0 }); self.playerDuckGraphics = self.attachAsset('playerDuck', { anchorX: 0.5, anchorY: 0.3, alpha: 0 }); self.playerDashGraphics = self.attachAsset('playerDash', { anchorX: 0.5, anchorY: 0.5, alpha: 0 }); self.speed = 10; self.velocityY = 0; self.jumping = false; self.dashing = false; self.ducking = false; self.actionTimer = 0; self.actionTimerMax = 120; self.update = function () { if (gameStarted) { if (self.jumping) { // Update position based on velocityY self.y -= self.velocityY; // Apply gravity self.velocityY -= 0.75; // Prevent player from falling below the ground if (self.y > groundY) { self.y = groundY; self.velocityY = 0; self.jumping = false; self.playerWalkGraphics.alpha = 1; self.playerJumpGraphics.alpha = 0; gameSpeedBoost = 0; // Create dust particle effect when landing for (var i = 0; i < 20; i++) { var dustParticle = new DustParticle(); dustParticle.x = self.x + (Math.random() * 20 - 10); dustParticle.y = self.y + self.playerWalkGraphics.height / 2 + (Math.random() * 20 - 10); dustParticle.alpha = 0.8; game.addChild(dustParticle); } } } else if (self.dashing) { self.actionTimer++; //gameSpeedBoost -= 0.1; if (self.actionTimer >= self.actionTimerMax) { self.y = groundY; self.dashing = false; self.playerWalkGraphics.alpha = 1; self.playerDashGraphics.alpha = 0; self.actionTimer = 0; gameSpeedBoost = 0; } } else if (self.ducking) { self.actionTimer++; //gameSpeedBoost -= 0.1; if (self.actionTimer >= self.actionTimerMax) { self.y = groundY; self.ducking = false; self.playerWalkGraphics.alpha = 1; self.playerDuckGraphics.alpha = 0; self.actionTimer = 0; gameSpeedBoost = 0; } } // Just walking if (!self.jumping && !self.dashing && !self.ducking) { // Bobbing and bumping animation self.y += Math.sin(LK.ticks / 3) * 2; self.rotation = Math.sin(LK.ticks / 20) * 0.1; } } }; self.jump = function () { if (!self.jumping) { gameSpeedBoost = defaultBoostAmount; self.velocityY = 50; self.jumping = true; self.playerWalkGraphics.alpha = 0; self.playerDashGraphics.alpha = 0; self.playerJumpGraphics.alpha = 1; self.playerDuckGraphics.alpha = 0; // Create dust particle effect when jumping for (var i = 0; i < 20; i++) { var dustParticle = new DustParticle(); dustParticle.x = self.x + (Math.random() * 20 - 10); dustParticle.y = self.y + self.playerWalkGraphics.height / 2 + (Math.random() * 20 - 10); dustParticle.alpha = 0.8; game.addChild(dustParticle); } } }; self.dash = function () { if (!self.dashing) { gameSpeedBoost = defaultBoostAmount; self.dashing = true; self.playerWalkGraphics.alpha = 0; self.playerDashGraphics.alpha = 1; self.playerJumpGraphics.alpha = 0; self.playerDuckGraphics.alpha = 0; } }; self.duck = function () { if (!self.ducking) { gameSpeedBoost = defaultBoostAmount; self.ducking = true; self.playerWalkGraphics.alpha = 0; self.playerDashGraphics.alpha = 0; self.playerJumpGraphics.alpha = 0; self.playerDuckGraphics.alpha = 1; } }; }); var ScoreSign = Container.expand(function () { var self = Container.call(this); var scoreSignGraphics = new Text2('+10', { size: 100, fill: "#ffffff", stroke: "#000000", strokeThickness: 5 }); scoreSignGraphics.anchor.set(0.5, 0.5); self.addChild(scoreSignGraphics); self.speedX = -5; self.lifeSpan = 60; // 1 second at 60 FPS self.update = function () { self.x += self.speedX; self.lifeSpan--; if (self.lifeSpan <= 0) { self.destroy(); } }; }); var Shrubbery = Container.expand(function () { var self = Container.call(this); var assetType = Math.random() < 0.3 ? 'shrubbery' : Math.random() < 0.5 ? 'pine' : 'berrybush'; var shrubberyGraphics = self.attachAsset(assetType, { anchorX: 0.5, anchorY: 1 }); self.speed = 0; self.update = function () { // Shrubbery update logic if needed }; }); var SpikeTrap = Container.expand(function () { var self = Container.call(this); var spikeTrapGraphics = self.attachAsset('spikeTrap', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 0; }); var TallBarricade = Container.expand(function () { var self = Container.call(this); var obstacleGraphics = self.attachAsset('tallBarricade', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 0; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x87CEEB // Sky blue background }); /**** * Game Code ****/ // Create and add score label to the top center of the screen var scoreLabel = new Text2('Score: 0', { size: 100, fill: "#ffffff", stroke: "#000000", strokeThickness: 5 }); scoreLabel.anchor.set(0.5, 0); // Center the score label horizontally LK.gui.top.addChild(scoreLabel); var gameStarted = false; var obstacles = []; var colectibles = []; var gameSpeed = 20; var gameSpeedBoost = 0; var defaultBoostAmount = 10; var touchStartX = 0; var touchStartY = 0; var groundY = 2200; //1810; //2732 - 510; // Add background image var background = LK.getAsset('background', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2 }); game.addChild(background); // Add first path image var path1 = LK.getAsset('path', { anchorX: 0, anchorY: 0, x: 0, //y: 2732 - 400 y: groundY + 130 }); game.addChild(path1); // Add second path image var path2 = LK.getAsset('path', { anchorX: 0, anchorY: 0, x: 2048, //y: 2732 - 400 y: groundY + 130 }); game.addChild(path2); var fgFill = LK.getAsset('foreground_filler', { anchorX: 0, anchorY: 0, x: 0, y: groundY + 430, width: 2048, height: 500 }); game.addChild(fgFill); // Function to place x amount of shrubberies evenly spaced function placeShrubberies(count) { var spacing = 4096 / (count + 1); for (var i = 1; i <= count; i++) { var shrubbery = new Shrubbery(); shrubbery.x = spacing * i + (Math.random() * 100 - 50); // Add randomness to x position shrubbery.y = groundY + 160 + (Math.random() * 30 - 15); // Add randomness to y position game.addChild(shrubbery); } } // Place 5 shrubberies as an example placeShrubberies(32); // Initialize player var player = new Player(); player.x = 350; //player.y = 2732 - 510; player.y = groundY; //2732 - 510; player.scale.x = player.scale.y = 1.2; game.addChild(player); // Handle touch events for player movement game.down = function (x, y, obj) { if (!gameStarted) { gameStarted = true; } //player.velocityY = 50; touchStartX = x; touchStartY = y; }; game.up = function (x, y, obj) { var deltaX = x - touchStartX; var deltaY = y - touchStartY; if (Math.abs(deltaX) > Math.abs(deltaY)) { if (deltaX > 0) { console.log("Swipe Right"); // Add logic for right swipe player.dash(); } } else { if (deltaY > 0) { console.log("Swipe Down"); // Add logic for down swipe player.duck(); } else { console.log("Swipe Up"); // Add logic for up swipe player.jump(); } } }; // Update game logic game.update = function () { if (gameStarted) { // Update player player.update(); // Update score label text scoreLabel.setText('Score: ' + LK.getScore()); // Update dust particles and score signs for (var i = game.children.length - 1; i >= 0; i--) { var child = game.children[i]; if (child instanceof DustParticle || child instanceof ScoreSign) { child.update(); } } // Move paths to the left path1.x -= gameSpeed + gameSpeedBoost; path2.x -= gameSpeed + gameSpeedBoost; // Reset path positions for seamless scrolling if (path1.x <= -2048) { path1.x = path2.x + 2048; } if (path2.x <= -2048) { path2.x = path1.x + 2048; } // Move shrubberies to the left for (var i = game.children.length - 1; i >= 0; i--) { var child = game.children[i]; if (child instanceof Shrubbery) { child.x -= gameSpeed + gameSpeedBoost + child.speed; if (child.x <= -child.width) { child.x = 2048 + child.width; } } else if (child instanceof Collectible) { child.x -= gameSpeed + gameSpeedBoost + child.speed; if (child.x <= -child.width) { child.x = 2048 + child.width; } if (child.intersects(player)) { LK.setScore(LK.getScore() + 10); scoreLabel.setText('Score: ' + LK.getScore()); // Show +10 sign var scoreSign = new ScoreSign(); scoreSign.x = player.x; scoreSign.y = player.y - 100; game.addChild(scoreSign); // Play sound effect for collectible pickup LK.getSound('collectiblePickup').play(); child.destroy(); } } } // Update obstacles for (var i = obstacles.length - 1; i >= 0; i--) { var child = obstacles[i]; child.x -= gameSpeed + gameSpeedBoost + child.speed; //obstacles[i].update(); if (child.intersects(player)) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); } else { if (child.x < 0 - child.width) { child.destroy(); obstacles.splice(i, 1); } } } // Spawn new obstacles if (LK.ticks % 300 == 0) { // 5 seconds at 60 FPS if (Math.random() < 0.5) { var spikeTrap = new SpikeTrap(); spikeTrap.x = 2048 + spikeTrap.width; spikeTrap.y = groundY; game.addChild(spikeTrap); obstacles.push(spikeTrap); } else { var barricade = new TallBarricade(); barricade.x = 2048 + barricade.width; barricade.y = groundY - barricade.height / 2 + 150; game.addChild(barricade); obstacles.push(barricade); } } // Spawn new collectible every 30 ticks if (LK.ticks % 40 == 0) { var collectible = new Collectible(); collectible.x = 2048 + collectible.width; collectible.y = 300 + Math.random() * (2032 - collectible.height); game.addChild(collectible); } } // endif gameStarted };
===================================================================
--- original.js
+++ change.js
@@ -423,9 +423,9 @@
obstacles.push(spikeTrap);
} else {
var barricade = new TallBarricade();
barricade.x = 2048 + barricade.width;
- barricade.y = groundY - barricade.height / 2;
+ barricade.y = groundY - barricade.height / 2 + 150;
game.addChild(barricade);
obstacles.push(barricade);
}
}
A background illstration for a game, rich in style, medieval fantasy themed, of a landscape seen from a great distance, like froma mountain ridge with mountains and forests and lakes and lots of features.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A spritesheet with various poses for a heavily armored little dwarven warrior with an axe in various poses for use in an endless runner game. Te poses should include walking, eating, jumping, ducking low, and chargingforward. Sprites should be laid out in a rectangular grid wih blank space between them. Style should be medieval fantasy.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A game logo for a game called 'Endless Viking Run' using norse font on a background of a viking shield and crossed axes. Muted colors.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.