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
Code edit (10 edits merged)
Please save this source code
User prompt
make a class for a collectible object that is assigned a random asset: snacks, snacks2,snacks3, snacks4, snacks5, snacks6, or snacks7
Code edit (5 edits merged)
Please save this source code
User prompt
use player velocityY to make hm jump
Code edit (1 edits merged)
Please save this source code
User prompt
mak the player bob and bump continously to simulate a kind of stick-doll walkcycle animation
User prompt
use two instances of path for seamless scrolling
User prompt
make a parallax effect where the path and the bushes move slowly towards the left, as new instances are spawned on the right side seamlessly
User prompt
make another asset called berrybush, and use it randomly for shrubbery
Code edit (2 edits merged)
Please save this source code
User prompt
add a bit of randomness to the shrubberies x and y positions
Code edit (9 edits merged)
Please save this source code
User prompt
make a function to place x amount of shrubberies, more or less evenly spaced
User prompt
add a few shrubberies between the background and ground
Code edit (4 edits merged)
Please save this source code
User prompt
make a path asset
===================================================================
--- original.js
+++ change.js
@@ -32,28 +32,99 @@
//<Assets used in the game will automatically appear here>
// Class for the player character
var Player = Container.expand(function () {
var self = Container.call(this);
- var playerGraphics = self.attachAsset('player', {
+ 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.5,
+ 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 = 180;
self.update = function () {
- // Update position based on velocityY
- self.y -= self.velocityY;
- // Apply gravity
- self.velocityY -= 1;
- // Prevent player from falling below the ground
- if (self.y > 2732 - 510) {
- self.y = 2732 - 510;
- self.velocityY = 0;
+ if (gameStarted) {
+ if (self.jumping) {
+ // Update position based on velocityY
+ self.y -= self.velocityY;
+ // Apply gravity
+ self.velocityY -= 1;
+ // Prevent player from falling below the ground
+ if (self.y > 2732 - 510) {
+ self.y = 2732 - 510;
+ self.velocityY = 0;
+ self.jumping = false;
+ self.playerWalkGraphics.alpha = 1;
+ self.playerJumpGraphics.alpha = 0;
+ }
+ } else if (self.dashing) {
+ self.actionTimer++;
+ if (self.actionTimer >= self.actionTimerMax) {
+ self.dashing = false;
+ self.playerWalkGraphics.alpha = 1;
+ self.playerDashGraphics.alpha = 0;
+ }
+ } else if (self.ducking) {
+ self.actionTimer++;
+ if (self.actionTimer >= self.actionTimerMax) {
+ self.dashing = false;
+ self.playerWalkGraphics.alpha = 1;
+ self.playerDuckGraphics.alpha = 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;
+ }
}
- // 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) {
+ self.jumping = true;
+ self.playerWalkGraphics.alpha = 0;
+ self.playerDashGraphics.alpha = 0;
+ self.playerJumpGraphics.alpha = 1;
+ self.playerDuckGraphics.alpha = 0;
+ }
+ };
+ self.dash = function () {
+ if (!self.dashing) {
+ 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) {
+ self.ducking = true;
+ self.playerWalkGraphics.alpha = 0;
+ self.playerDashGraphics.alpha = 0;
+ self.playerJumpGraphics.alpha = 0;
+ self.playerDuckGraphics.alpha = 1;
+ }
+ };
});
var Shrubbery = Container.expand(function () {
var self = Container.call(this);
var assetType = Math.random() < 0.3 ? 'shrubbery' : Math.random() < 0.5 ? 'pine' : 'berrybush';
@@ -119,8 +190,9 @@
player.y = 2732 - 510;
game.addChild(player);
// Array to keep track of obstacles
var obstacles = [];
+var colectibles = [];
var gameSpeed = 2;
// Function to spawn obstacles
function spawnObstacle() {
var obstacle = new Obstacle();
@@ -130,50 +202,78 @@
game.addChild(obstacle);
}
// Handle touch events for player movement
game.down = function (x, y, obj) {
- player.velocityY = 50;
+ if (!gameStarted) {
+ gameStarted = true;
+ }
+ //player.velocityY = 50;
};
+game.up = function (x, y, obj) {
+ var startX = obj.event.data.global.x;
+ var startY = obj.event.data.global.y;
+ var endX = x;
+ var endY = y;
+ var deltaX = endX - startX;
+ var deltaY = endY - startY;
+ if (Math.abs(deltaX) > Math.abs(deltaY)) {
+ if (deltaX > 0) {
+ console.log("Swipe Right");
+ // Add logic for right swipe
+ }
+ } else {
+ if (deltaY > 0) {
+ console.log("Swipe Down");
+ // Add logic for down swipe
+ } else {
+ console.log("Swipe Up");
+ // Add logic for up swipe
+ }
+ }
+};
+var gameStarted = false;
// Update game logic
game.update = function () {
- // Update player
- player.update();
- // Move paths to the left
- path1.x -= 2;
- path2.x -= 2;
- // 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 instanceof Collectible) {
- child.x -= gameSpeed + child.speed;
- if (child.x <= -child.width) {
- child.x = 2048 + child.width;
+ if (gameStarted) {
+ // Update player
+ player.update();
+ // Move paths to the left
+ path1.x -= 2;
+ path2.x -= 2;
+ // 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 instanceof Collectible) {
+ child.x -= gameSpeed + child.speed;
+ if (child.x <= -child.width) {
+ child.x = 2048 + child.width;
+ }
}
}
- }
- // Update obstacles
- for (var i = obstacles.length - 1; i >= 0; i--) {
- obstacles[i].update();
- if (obstacles[i].intersects(player)) {
- LK.effects.flashScreen(0xff0000, 1000);
- LK.showGameOver();
+ // Update obstacles
+ for (var i = obstacles.length - 1; i >= 0; i--) {
+ obstacles[i].update();
+ if (obstacles[i].intersects(player)) {
+ LK.effects.flashScreen(0xff0000, 1000);
+ LK.showGameOver();
+ }
}
- }
- // Spawn new obstacles
- if (LK.ticks % 60 == 0) {
- //spawnObstacle();
- }
- // Spawn new collectible every 30 ticks
- if (LK.ticks % 90 == 0) {
- var collectible = new Collectible();
- collectible.x = 2048 + collectible.width;
- collectible.y = Math.random() * (2332 - collectible.height);
- game.addChild(collectible);
- }
+ // Spawn new obstacles
+ if (LK.ticks % 60 == 0) {
+ //spawnObstacle();
+ }
+ // Spawn new collectible every 30 ticks
+ if (LK.ticks % 90 == 0) {
+ var collectible = new Collectible();
+ collectible.x = 2048 + collectible.width;
+ collectible.y = Math.random() * (2332 - collectible.height);
+ game.addChild(collectible);
+ }
+ } // endif gameStarted
};
\ No newline at end of file
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.