User prompt
resize the background
User prompt
Make the background fit to screen and not blurry
Code edit (1 edits merged)
Please save this source code
User prompt
Reduce more the damage
User prompt
Make less damage to the dragon from other objects
User prompt
Make health reduced by points, Each object have amount of points make it random by size of the objects.
Code edit (1 edits merged)
Please save this source code
User prompt
let screen not blurry always.
User prompt
Make the image background fit to screen, make it not blurry
User prompt
Make the background fir to screen
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'anchor')' in or related to this line: 'scoreTxt.anchor.set(0, 0);' Line Number: 145
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'x')' in or related to this line: 'levelTxt.x = healthBar.x + healthBar.width + 10; // Move the level text to the right of the health bar' Line Number: 148
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'x')' in or related to this line: 'levelTxt.x = healthBar.x + healthBar.width + 10; // Move the level text to the right of the health bar' Line Number: 148
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'anchor')' in or related to this line: 'scoreTxt.anchor.set(0, 0);' Line Number: 145
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'anchor')' in or related to this line: 'scoreTxt.anchor.set(0, 0);' Line Number: 145
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'anchor')' in or related to this line: 'scoreTxt.anchor.set(0, 0);' Line Number: 145
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'anchor')' in or related to this line: 'scoreTxt.anchor.set(0, 0);' Line Number: 145
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'anchor')' in or related to this line: 'scoreTxt.anchor.set(0, 0);' Line Number: 145
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'anchor')' in or related to this line: 'scoreTxt.anchor.set(0, 0);' Line Number: 145
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'x')' in or related to this line: 'levelTxt.x = healthBar.x + healthBar.width + 10; // Move the level text to the right of the health bar' Line Number: 148
User prompt
show it beside the health bar
User prompt
make on the front of the background
User prompt
Its not shoowing on the screen try to make it seen
User prompt
Resize text level to 200
User prompt
Resize text level to 800
/**** * Classes ****/ //<Assets used in the game will automatically appear here> //<Write imports for supported plugins here> // Dragon class to represent the player character var Dragon = Container.expand(function () { var self = Container.call(this); var dragonGraphics = self.attachAsset('dragon', { anchorX: 0.5, anchorY: 0.5, scaleX: 1.5, scaleY: 1.5 }); self.speed = 10; // Speed of the dragon self.update = function () { // Update logic for the dragon can be added here if needed }; }); // HealthBar class to represent the player's health var HealthBar = Container.expand(function () { var self = Container.call(this); var healthBarGraphics = self.attachAsset('healthBar', { anchorX: 0.0, anchorY: 0.0, scaleX: 2048 / 1000, // Scale to fit the game width scaleY: 0.1 }); self.maxHealth = 1000; self.currentHealth = self.maxHealth; self.update = function () { healthBarGraphics.scaleX = self.currentHealth / self.maxHealth; healthBarGraphics.scaleY = 0.05; // Resize the health bar to fit the top of the screen }; }); // Sphere class to represent the obstacles var Sphere = Container.expand(function () { var self = Container.call(this); var sphereGraphics = self.attachAsset('sphere', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 5; // Speed of the sphere self.points = Math.floor(Math.random() * 51); // Random points based on size self.update = function () { self.y -= self.speed; // Move the sphere upwards }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000, //Init game with black background height: 3000 // Increase the game screen height }); /**** * Game Code ****/ // Initialize game variables var dragon; var spheres = []; var score = 0; var scoreTxt; // Add background image to the game var background = LK.getAsset('Background', { anchorX: 0.0, anchorY: 0.0 }); background = game.addChild(background); background.width = game.width; background.height = game.height; background.smooth = false; // Disable smoothing to prevent blurriness // Function to handle game updates game.update = function () { // Update dragon position based on touch input if (dragNode && dragNode.global) { dragNode.x = game.toLocal(dragNode.global).x; } // Update spheres and check for collisions for (var i = spheres.length - 1; i >= 0; i--) { spheres[i].update(); if (spheres[i].intersects(dragon)) { var evade = Math.floor(Math.random() * 51); if (evade <= 50) { healthBar.currentHealth -= spheres[i].points / 4; // Reduce health based on points if (healthBar.currentHealth <= 0) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver({ bar: { color: 0xFFA500, // Orange color for the outlines fill: 0xFFA500 // Orange color for the fill }, text: { color: 0x00FFFF // Blue cyan color for the text } }); } } } if (spheres[i].y < -50) { spheres[i].destroy(); spheres.splice(i, 1); } } // Spawn new spheres if (LK.ticks % 30 == 0) { for (var i = 0; i < 2; i++) { var newSphere = new Sphere(); newSphere.x = Math.random() * 2048; newSphere.y = 2732; // Randomly assign one of three sizes to the sphere var sizes = [0.7, 0.5, 1]; var size = sizes[Math.floor(Math.random() * sizes.length)]; newSphere.scaleX = size; newSphere.scaleY = size; spheres.push(newSphere); game.addChild(newSphere); score += 100; // Increase score by 100 for each new sphere } scoreTxt.setText('Score: ' + score); // Update score text var level = Math.floor(score / 500) + 1; // Calculate level based on score levelTxt.setText('Level: ' + level); // Update level text } }; // Initialize dragon dragon = game.addChild(new Dragon()); dragon.x = 2048 / 2; dragon.y = 200; // Initialize level display var levelTxt = new Text2('Level: 1', { size: 200, fill: 0xFFFF00 }); levelTxt.anchor.set(0.5, 0); LK.gui.top.addChild(levelTxt); levelTxt.x = 2048 - levelTxt.width; // Move the level text to the right side of the screen levelTxt.y = 0; // Position the level text at the top of the screen // Initialize score display scoreTxt = new Text2('Score: 0', { size: 1000, fill: 0xFFFF00 }); LK.gui.top.addChild(scoreTxt); scoreTxt.anchor.set(0.5, 0); // Sets anchor to the center of the top edge of the text. scoreTxt.x = 2048 / 2; // Center the score text horizontally scoreTxt.y = 50; // Position the score text 50 pixels from the top of the screen // Initialize health bar var healthBar = game.addChild(new HealthBar()); healthBar.x = 0; healthBar.y = 2732 - healthBar.height; scoreTxt.anchor.set(0, 0); LK.gui.bottomLeft.addChild(scoreTxt); // Handle touch input for dragging the dragon var dragNode = null; game.down = function (x, y, obj) { dragNode = dragon; }; game.up = function (x, y, obj) { dragNode = null; }; game.move = function (x, y, obj) { if (dragNode) { // Limit the dragon's movement to the game area var newX = Math.max(0, Math.min(2048, x)); dragNode.x = newX; } };
===================================================================
--- original.js
+++ change.js
@@ -70,10 +70,10 @@
anchorX: 0.0,
anchorY: 0.0
});
background = game.addChild(background);
-background.scaleX = game.width / background.width;
-background.scaleY = game.height / background.height;
+background.width = game.width;
+background.height = game.height;
background.smooth = false; // Disable smoothing to prevent blurriness
// Function to handle game updates
game.update = function () {
// Update dragon position based on touch input