User prompt
do not update the diver positionn on game start but on load
User prompt
on game start reposition flippers
User prompt
create diver before flippers
User prompt
make sure all assets are loaded correclty before game starts
User prompt
if dragnode is different than shield then move shield relative to its current position
User prompt
hoystic should move if the player touches anywhere int he screen
User prompt
drag node of joystic can be anywhere in the screen
User prompt
make sure shield moves in the direction the joystick is held
User prompt
Please fix the bug: 'Uncaught TypeError: joystick.update is not a function' in or related to this line: 'joystick.update();' Line Number: 596
User prompt
Please fix the bug: 'Uncaught ReferenceError: dragging is not defined' in or related to this line: 'if (dragging) {' Line Number: 47
User prompt
keep moving the shield on the direcitno the joystick is
User prompt
add joystick to move the shield
User prompt
add a joystic to move the bubble
User prompt
make depth text transparent
User prompt
make touchable area of joystic a lot bgger
User prompt
where the player touches the screen, thats where joysitc will be.
User prompt
shield should not update its position to the touch point.
User prompt
Please fix the bug: 'Uncaught ReferenceError: handleMove is not defined' in or related to this line: 'handleMove(x, y, obj);' Line Number: 498
User prompt
add a joystick to mvoe the shield
User prompt
drag node of shield can be anwyehre in the screen
User prompt
make touch area of the shield a lot bigger
User prompt
wait to load flipper untill diver is initiallizzed
User prompt
add 3 different random elements on the side to be just part of the background. either side randomly
User prompt
improve collision box to be more permisive on collision
User prompt
use lk score to keep track of depth
===================================================================
--- original.js
+++ change.js
@@ -83,14 +83,16 @@
}
self.x += self.movement;
};
// Add flippers to the diver
- var leftFlipper = self.addChild(new Flipper());
+ var leftFlipper = new Flipper();
leftFlipper.x = -50;
leftFlipper.depth = -1;
- var rightFlipper = self.addChild(new Flipper());
+ var rightFlipper = new Flipper();
rightFlipper.x = 60;
rightFlipper.depth = -1;
+ self.addChild(leftFlipper);
+ self.addChild(rightFlipper);
});
// Flipper class
var Flipper = Container.expand(function () {
var self = Container.call(this);
@@ -408,197 +410,193 @@
****/
// Create a diver instance
//<Assets used in the game will automatically appear here>
var game = new LK.Game({
- backgroundColor: 0xADD8E6,
- //Init game with a softer blue background
- onAssetsLoaded: function onAssetsLoaded() {
- // All assets are loaded, start the game
- initializeGame();
- }
+ backgroundColor: 0xADD8E6 //Init game with a softer blue background
});
/****
* Game Code
****/
-function initializeGame() {
- var lastBubbleSoundTime = 0;
- var speedMultiplier = 1;
- // Declare and initialize backgroundMusic variable
- var backgroundMusic = LK.getSound('background');
- // Play background music on loop when the game starts
- LK.on('tick', function () {
- if (!backgroundMusic.playing) {
- backgroundMusic.play();
- }
- });
- var background1 = game.addChild(new Background());
- background1.y = 0;
- // Create a shield instance
- var shield = game.addChildAt(new Shield(), game.children.length);
- // Position the shield at the center of the screen
- shield.x = 2048 / 2;
- shield.y = 2732 / 2;
- // Create a diver instance
- var dragNode = null;
- var diver = new Diver();
- diver.depth = 2;
- // Position the diver at the top center of the screen, 200 pixels down from the top
- diver.x = 2048 / 2;
- diver.y = 500;
- // Position the flippers relative to the diver
- diver.children[0].y = diver.height / 2 - 20; // Left flipper
- diver.children[0].y = diver.children[0].y; // Right flipper
- // Set diver to a higher depth than flippers
- diver.depth = 2;
- // Create an obstacle1 instance
- game.move = function (x, y, obj) {
- if (dragNode) {
- if (dragNode !== shield) {
- shield.x += x - shield.x;
- shield.y += y - shield.y;
- } else {
- dragNode.x = x;
- dragNode.y = y;
- }
- }
- if (dragNode === shield) {
- shield.x = x;
- shield.y = y;
- }
- };
- var obstacles = [];
- var spatialHash = {};
- game.addChild(diver);
- game.setChildIndex(diver, game.children.length - 1);
- // Create bubbles after obstacles
- var bubbles = [];
- for (var i = 0; i < 20; i++) {
- var bubble = new Bubble();
- bubble.x = Math.random() * 2048;
- bubble.y = Math.random() * 2732;
- bubbles.push(bubble);
- game.addChildAt(bubble, game.children.length);
- }
- // Spawn the first wave of obstacles
- spawnWave();
- ;
- // Initialize score
- var score = LK.getScore();
- // Create score text
- var depthScoreText = new Text2('Depth:0m', {
- size: 70,
- fill: "#ffffff",
- stroke: "#000000",
- strokeThickness: 6,
- font: "monospace" // Change font to be more square
- });
- depthScoreText.anchor.set(0.5, 0.5);
- depthScoreText.x = 400;
- depthScoreText.y = 100;
- LK.gui.top.addChild(depthScoreText);
- // Initialize a timer to update the score every second and increase speed multiplier
- var scoreUpdateInterval = LK.setInterval(function () {
- LK.setScore(LK.getScore() + 1);
- if (depthScoreText) {
- depthScoreText.setText('Depth:' + LK.getScore() + 'm');
- }
- speedMultiplier += 0.01; // Increase speed multiplier by 0.01 every second
- }, 1000);
- game.up = function (x, y, obj) {
- dragNode = null;
- };
- // Check if background music is playing, if not, play it
+var lastBubbleSoundTime = 0;
+var speedMultiplier = 1;
+// Declare and initialize backgroundMusic variable
+var backgroundMusic = LK.getSound('background');
+// Play background music on loop when the game starts
+LK.on('tick', function () {
if (!backgroundMusic.playing) {
backgroundMusic.play();
}
- // Update background
- background1.update();
- // Update bubbles
- for (var i = 0; i < bubbles.length; i++) {
- bubbles[i].update();
- }
- // Define the current wave
- var currentWave = 0;
- var allWavesSpawnedOnce = false;
- // Spawn wave function
- function spawnWave() {
- // Define the layout of the obstacles for each wave
- var obstacleLayouts = [{
- type: 'line',
- grid: ['.....', '.....', '.#.#.', '.....', '.....']
- }, {
- type: 'triangle',
- grid: ['.....', '..#..', '.....', '.#.#.', '.....']
- }, {
- type: 'square',
- grid: ['.....', '.#.#.', '.....', '.#.#.', '.....']
- }, {
- type: 'circle',
- grid: ['.....', '..#..', '.#.#.', '.#.#.', '..#..']
- }, {
- type: 'cross',
- grid: ['.....', '..#..', '.###.', '..#..', '.....']
- }, {
- type: 'hexagon',
- grid: ['.....', '..#..', '.#.#.', '.#.#.', '..#..']
- }, {
- type: 'heptagon',
- grid: ['..#..', '..#..', '#...#', '..#..', '..#..']
- }, {
- type: 'octagon',
- grid: ['.....', '#####', '.....', '.....', '.....']
- }, {
- type: 'nonagon',
- grid: ['.....', '..#..', '.#.#.', '.#.#.', '..#..']
- }, {
- type: 'decagon',
- grid: ['.....', '..#..', '.#.#.', '.#.#.', '..#..']
- }];
- // Get the layout for the current wave
- var layout = obstacleLayouts[currentWave];
- if (!layout) {
- console.error('Error: layout is undefined. Check the obstacleLayouts array.');
- return;
+});
+var background1 = game.addChild(new Background());
+background1.y = 0;
+// Create a shield instance
+var shield = game.addChildAt(new Shield(), game.children.length);
+// Position the shield at the center of the screen
+shield.x = 2048 / 2;
+shield.y = 2732 / 2;
+// Create a diver instance
+var dragNode = null;
+var diver = new Diver();
+diver.depth = 2;
+// Position the diver at the top center of the screen, 200 pixels down from the top
+diver.x = 2048 / 2;
+diver.y = 500;
+// Position the flippers relative to the diver
+diver.children[0].y = diver.height / 2 - 20; // Left flipper
+diver.children[0].y = diver.children[0].y; // Right flipper
+// Set diver to a higher depth than flippers
+diver.depth = 2;
+// Create an obstacle1 instance
+game.move = function (x, y, obj) {
+ if (dragNode) {
+ if (dragNode !== shield) {
+ shield.x += x - shield.x;
+ shield.y += y - shield.y;
+ } else {
+ dragNode.x = x;
+ dragNode.y = y;
}
- var layoutPositions = [];
- layout.grid.forEach(function (row, rowIndex) {
- row.split('').forEach(function (cell, colIndex) {
- if (cell === '#') {
- layoutPositions.push({
- x: colIndex,
- y: rowIndex
- });
- }
- });
+ }
+ if (dragNode === shield) {
+ shield.x = x;
+ shield.y = y;
+ }
+};
+var obstacles = [];
+var spatialHash = {};
+game.addChild(diver);
+game.setChildIndex(diver, game.children.length - 1);
+// Position the flippers relative to the diver
+diver.children[0].y = diver.height / 2 - 20; // Left flipper
+diver.children[1].y = diver.height / 2 - 20; // Right flipper
+// Create bubbles after obstacles
+var bubbles = [];
+for (var i = 0; i < 20; i++) {
+ var bubble = new Bubble();
+ bubble.x = Math.random() * 2048;
+ bubble.y = Math.random() * 2732;
+ bubbles.push(bubble);
+ game.addChildAt(bubble, game.children.length);
+}
+// Spawn the first wave of obstacles
+spawnWave();
+;
+// Initialize score
+var score = LK.getScore();
+// Create score text
+var depthScoreText = new Text2('Depth:0m', {
+ size: 70,
+ fill: "#ffffff",
+ stroke: "#000000",
+ strokeThickness: 6,
+ font: "monospace" // Change font to be more square
+});
+depthScoreText.anchor.set(0.5, 0.5);
+depthScoreText.x = 400;
+depthScoreText.y = 100;
+LK.gui.top.addChild(depthScoreText);
+// Initialize a timer to update the score every second and increase speed multiplier
+var scoreUpdateInterval = LK.setInterval(function () {
+ LK.setScore(LK.getScore() + 1);
+ if (depthScoreText) {
+ depthScoreText.setText('Depth:' + LK.getScore() + 'm');
+ }
+ speedMultiplier += 0.01; // Increase speed multiplier by 0.01 every second
+}, 1000);
+game.up = function (x, y, obj) {
+ dragNode = null;
+};
+// Check if background music is playing, if not, play it
+if (!backgroundMusic.playing) {
+ backgroundMusic.play();
+}
+// Update background
+background1.update();
+// Update bubbles
+for (var i = 0; i < bubbles.length; i++) {
+ bubbles[i].update();
+}
+// Define the current wave
+var currentWave = 0;
+var allWavesSpawnedOnce = false;
+// Spawn wave function
+function spawnWave() {
+ // Define the layout of the obstacles for each wave
+ var obstacleLayouts = [{
+ type: 'line',
+ grid: ['.....', '.....', '.#.#.', '.....', '.....']
+ }, {
+ type: 'triangle',
+ grid: ['.....', '..#..', '.....', '.#.#.', '.....']
+ }, {
+ type: 'square',
+ grid: ['.....', '.#.#.', '.....', '.#.#.', '.....']
+ }, {
+ type: 'circle',
+ grid: ['.....', '..#..', '.#.#.', '.#.#.', '..#..']
+ }, {
+ type: 'cross',
+ grid: ['.....', '..#..', '.###.', '..#..', '.....']
+ }, {
+ type: 'hexagon',
+ grid: ['.....', '..#..', '.#.#.', '.#.#.', '..#..']
+ }, {
+ type: 'heptagon',
+ grid: ['..#..', '..#..', '#...#', '..#..', '..#..']
+ }, {
+ type: 'octagon',
+ grid: ['.....', '#####', '.....', '.....', '.....']
+ }, {
+ type: 'nonagon',
+ grid: ['.....', '..#..', '.#.#.', '.#.#.', '..#..']
+ }, {
+ type: 'decagon',
+ grid: ['.....', '..#..', '.#.#.', '.#.#.', '..#..']
+ }];
+ // Get the layout for the current wave
+ var layout = obstacleLayouts[currentWave];
+ if (!layout) {
+ console.error('Error: layout is undefined. Check the obstacleLayouts array.');
+ return;
+ }
+ var layoutPositions = [];
+ layout.grid.forEach(function (row, rowIndex) {
+ row.split('').forEach(function (cell, colIndex) {
+ if (cell === '#') {
+ layoutPositions.push({
+ x: colIndex,
+ y: rowIndex
+ });
+ }
});
- // Randomly choose an obstacle type for the entire wave
- var obstacleTypes = [Obstacle1, Obstacle2, Obstacle3];
- var obstacleType = obstacleTypes[Math.floor(Math.random() * obstacleTypes.length)];
- layoutPositions.forEach(function (position) {
- var obstacle = game.addChild(new obstacleType());
- // Position the obstacles according to the layout, using the grid for positioning
- obstacle.x = 2048 / 2 + (position.x - gridSize / 2) * cellSize;
- obstacle.y = 2732 + position.y * cellSize; // Spawn obstacles offscreen at the bottom
- obstacles.push(obstacle);
- });
- currentWave++;
- if (currentWave >= obstacleLayouts.length) {
- allWavesSpawnedOnce = true;
- currentWave = 0;
- }
- if (allWavesSpawnedOnce) {
- currentWave = Math.floor(Math.random() * (obstacleLayouts.length - 3)) + 3;
- }
- // Add interval of wait between waves
- LK.setTimeout(function () {
- spawnWave();
- }, 5000); // 5 seconds wait between waves
+ });
+ // Randomly choose an obstacle type for the entire wave
+ var obstacleTypes = [Obstacle1, Obstacle2, Obstacle3];
+ var obstacleType = obstacleTypes[Math.floor(Math.random() * obstacleTypes.length)];
+ layoutPositions.forEach(function (position) {
+ var obstacle = game.addChild(new obstacleType());
+ // Position the obstacles according to the layout, using the grid for positioning
+ obstacle.x = 2048 / 2 + (position.x - gridSize / 2) * cellSize;
+ obstacle.y = 2732 + position.y * cellSize; // Spawn obstacles offscreen at the bottom
+ obstacles.push(obstacle);
+ });
+ currentWave++;
+ if (currentWave >= obstacleLayouts.length) {
+ allWavesSpawnedOnce = true;
+ currentWave = 0;
}
- // Define the grid size and the size of each cell in the grid
- var gridSize = 5;
- var cellSize = 150;
- // Call the spawn wave function every 1 second
- // Initial call to spawn the first wave
- spawnWave();
- ;
-}
\ No newline at end of file
+ if (allWavesSpawnedOnce) {
+ currentWave = Math.floor(Math.random() * (obstacleLayouts.length - 3)) + 3;
+ }
+ // Add interval of wait between waves
+ LK.setTimeout(function () {
+ spawnWave();
+ }, 5000); // 5 seconds wait between waves
+}
+// Define the grid size and the size of each cell in the grid
+var gridSize = 5;
+var cellSize = 150;
+// Call the spawn wave function every 1 second
+// Initial call to spawn the first wave
+spawnWave();
+;
\ No newline at end of file
8bit. cartoon. jellyfish.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
empty 8 bit cartoon white circle. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
cartoon. 8-bit. octopus. colorful.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
cartoon. 8-bit. sea urchin. colorful. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
cartoon 8bit stingray. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.