Code edit (3 edits merged)
Please save this source code
User prompt
spawn the ink from the center of the player instead of lower from it
Code edit (1 edits merged)
Please save this source code
User prompt
ass a 200 pixels pad to both the top and bottom side of the screen, so enemies can only spawn 200 pixels higher than the bottom and 200 pixels lower than the top side of the screen
Code edit (1 edits merged)
Please save this source code
User prompt
instead of spawning just one enemy on every tap, spawn 2. one from the right and one from the left
User prompt
turn the player's hitbox into a circle instead of a square
Code edit (3 edits merged)
Please save this source code
User prompt
whenever the score incremnents, bump it's size by 20% before returning to it's original size
Code edit (2 edits merged)
Please save this source code
User prompt
fix the acceleration to also consider enemies spawning from the left, as right now the acceelration is setup as a negative value, making the enemies spawning from left reverse direction, which is a bug
User prompt
fix the acceleration to also consider enemies spawning from the left, as right now the acceelration is setup as a negative value, making the enemies spawning from left reverse direction, which is a bug
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
User prompt
enemies should also have acceleration
Code edit (2 edits merged)
Please save this source code
User prompt
optimize the speed of the enemies as I think it's currently controlled from multiple places
Code edit (10 edits merged)
Please save this source code
User prompt
increase the enemies speed
Code edit (1 edits merged)
Please save this source code
User prompt
we need to change the animation for the ink. as soon as it is generated, it should instantly start moving downwards. but then have a delay before it starts fading away. so it instantly starts moving, but the fading away has a delay
Code edit (1 edits merged)
Please save this source code
User prompt
add a 500 miliseconds delay before the ink starts fading to 0 alpha. while the delay before the ink starts fading away remains, it should instantly start moving downwards
Code edit (2 edits merged)
Please save this source code
User prompt
while the delay before the ink starts fading away remains, it should instantly start moving downwards
/****
* Classes
****/
// BackgroundContainer class
var BackgroundContainer = Container.expand(function () {
var self = Container.call(this);
var background = self.attachAsset('background', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2,
width: 2048,
height: 2732
});
});
// ForegroundContainer class
var ForegroundContainer = Container.expand(function () {
var self = Container.call(this);
});
// Ink class
var Ink = Container.expand(function () {
var self = Container.call(this);
var inkGraphics = self.attachAsset('ink', {
anchorX: 0.5,
anchorY: 0.5
});
self.fadeOut = function () {
var fadeInterval = LK.setInterval(function () {
inkGraphics.alpha -= 0.03;
self.y += 6; // Move the ink 100 pixels lower over 1 second (1000ms)
if (inkGraphics.alpha <= 0) {
LK.clearInterval(fadeInterval);
self.destroy();
}
}, 1);
var fadeTimeout = LK.setTimeout(function () {
LK.clearInterval(fadeInterval);
}, 500);
};
});
// MidgroundContainer class
var MidgroundContainer = Container.expand(function () {
var self = Container.call(this);
});
// Obstacle class
var Obstacle = Container.expand(function () {
var self = Container.call(this);
self.scored = false;
var obstacleGraphics = self.attachAsset('obstacle', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = -10;
self.move = function () {
self.x += self.speed;
self.y += Math.sin(self.x / 100) * 5; // Add oscillation to the enemy's movement
};
});
// Assets will be automatically created based on usage in the code.
// Player class
var Player = Container.expand(function () {
var self = Container.call(this);
var playerGraphics = self.attachAsset('player', {
anchorX: 0.5,
anchorY: 0.5
});
self.jumpSpeed = gameVariables.jumpSpeed;
self.gravity = gameVariables.gravity;
self.acceleration = gameVariables.acceleration;
self.velocityY = gameVariables.velocityY;
self.isJumping = gameVariables.isJumping;
self.jump = function () {
if (!self.isJumping) {
self.velocityY = self.jumpSpeed;
self.isJumping = true;
}
};
self.update = function () {
self.y += self.velocityY;
self.velocityY += self.gravity;
self.gravity += self.acceleration;
// Prevent player from falling below the ground
if (self.y > 2732 - playerGraphics.height / 2) {
self.y = 2732 - playerGraphics.height / 2;
self.isJumping = false;
self.velocityY = gameVariables.velocityY;
self.gravity = gameVariables.gravity;
self.acceleration = gameVariables.acceleration;
}
};
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000 // Init game with black background
});
/****
* Game Code
****/
var backgroundContainer = game.addChild(new BackgroundContainer());
var midgroundContainer = game.addChild(new MidgroundContainer());
var foregroundContainer = game.addChild(new ForegroundContainer());
var background = backgroundContainer.addChild(LK.getAsset('background', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2,
width: 2048,
height: 2732
}));
// Game Variables class
var GameVariables = function GameVariables() {
this.jumpSpeed = -15;
this.gravity = 0.2;
this.acceleration = 0.001;
this.velocityY = 0;
this.isJumping = false;
};
var gameVariables = new GameVariables();
var spawnSide = 'right';
var player = foregroundContainer.addChild(new Player());
player.x = 2048 / 2;
player.y = 2732 / 2;
var obstacles = [];
var scoreTxt = new Text2('0', {
size: 200,
fill: "#ffffff",
align: "center",
stroke: '#000000',
strokeThickness: 10
});
scoreTxt.anchor.set(0.5, 0.5);
scoreTxt.x = 2048 / 2;
scoreTxt.y = 150;
midgroundContainer.addChild(scoreTxt);
game.on('down', function (obj) {
// Make the player jump 200 pixels upwards
player.y -= 300;
// Reset the player's speed to its initial state
player.velocityY = gameVariables.velocityY;
player.gravity = gameVariables.gravity;
player.acceleration = gameVariables.acceleration;
// Generate Ink asset
var ink = midgroundContainer.addChild(new Ink());
ink.x = player.x;
ink.y = player.y + 200;
ink.fadeOut();
// Spawn new obstacles
var newObstacle = new Obstacle();
if (spawnSide === 'right') {
newObstacle.x = 2048;
newObstacle.speed = -10;
newObstacle.scored = false;
spawnSide = 'left';
} else {
newObstacle.x = 0;
newObstacle.speed = 10;
newObstacle.scale.x = -1; // Flip the fish on its x-axis
newObstacle.scored = false;
spawnSide = 'right';
}
newObstacle.y = Math.random() * (2732 - newObstacle.height); // Position at a random height on the screen
obstacles.push(newObstacle);
game.addChild(newObstacle);
// Increment score
LK.setScore(LK.getScore() + 1);
scoreTxt.setText(LK.getScore());
});
LK.on('tick', function () {
player.update();
// Check if any part of the player touches the top or bottom side of the screen
if (player.y - player.height / 2 <= 0 || player.y + player.height / 2 >= 2732) {
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
}
obstacles.forEach(function (obstacle, index) {
obstacle.move();
if (obstacle.x < -100) {
// Remove obstacle if it moves off screen
obstacle.destroy();
obstacles.splice(index, 1);
}
if (player.intersects(obstacle)) {
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
}
});
// Update and display the score
scoreTxt.setText(LK.getScore());
});
cute tiny octopus. pixelated. 8 bit. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
cute angry spearfish. pixelated. 8 bit. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
inside the depths of the blue ocean background. pixelated. 8 bit. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
silver octo coin. pixelated. 8 bit. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
exploded silver fragments. pixelated. 8 bit. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.