User prompt
Rename Rock02 to Rock01 in assets
User prompt
Delete sphere object image from game and assets
User prompt
Fix lag
User prompt
Make the sphere object respawn's randomly and make distance between it to let space for the dragon when dodge
User prompt
Make auto refresh for the background to be clearer & fit to screen
User prompt
Reduce texture of the objects for batter more performance
User prompt
Make the background clearer
User prompt
Make the background very cleared pic
User prompt
Fix pixels of the background, the blur
User prompt
Fit the background image to the screen, inside screen outlines, no blure, reduce distortion to 0, make it cleared background pic.
User prompt
Fix scor points bug from different objects
User prompt
Make points from shooting the sphere and rock02
User prompt
Analyse and fix the bugs in the game
User prompt
Resize the objects rock02 and sphere
User prompt
make the objects 1 & 2 big little bit
User prompt
Make them big little it
User prompt
Make it 2 different objects in game
User prompt
make more fireballs and shot continuously
User prompt
make it bigger than this
User prompt
Scale it
User prompt
move it down the screen
User prompt
set health bar sam distance with level but on the left side
User prompt
Shot without stop
Code edit (1 edits merged)
Please save this source code
User prompt
Make random size for the spheres
/**** * 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, smooth: true, filterQuality: 10 }); self.speed = 10; // Speed of the dragon self.update = function () { // Update logic for the dragon can be added here if needed }; }); // Fireball class to represent the fireballs that the dragon shoots var Fireball = Container.expand(function () { var self = Container.call(this); var fireballGraphics = self.attachAsset('Shout', { anchorX: 0.5, anchorY: 0.5, scaleX: 0.5, scaleY: 0.5, smooth: true, filterQuality: 10 }); self.speed = 20; // Increase the speed of the fireball self.update = function () { // Move the fireball straight down self.y += self.speed; }; }); // 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: 0.2, // Scale to fit the game width scaleY: 0.02 }); self.maxHealth = 1000; self.currentHealth = self.maxHealth; self.update = function () { self.scaleX = self.currentHealth / self.maxHealth * 0.2; // Scale the health bar based on the current health and game width self.scaleY = 0.02; // Keep the height of the health bar constant self.currentHealth = Math.max(0, self.currentHealth); // Ensure health does not go below 0 }; }); // 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, scaleX: 0.5, scaleY: 2.5, // Increase the height of the spheres smooth: true, filterQuality: 4 }); self.speed = 3; // Speed of the sphere var size = Math.random() * (1.2 - 0.8) + 0.8; self.points = Math.floor((1.2 - size) * 20); self.update = function () { // Move the sphere straight up self.y -= self.speed; }; }); /**** * 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 fireballs = []; // Initialize fireballs array var score = 0; // Initialize score to 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 = true; // Enable smoothing to remove pixels background.filterQuality = 10; // Set the filter quality to high to remove blur background.scale.set(game.width / background.width, game.height / background.height); // Scale the background to fit the screen // Function to handle game updates game.update = function () { // Update dragon position based on touch input if (!LK.gameOver && dragNode && dragNode.global) { dragNode.x = game.toLocal(dragNode.global).x; } // Update spheres and check for collisions if (!LK.gameOver) { 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; // 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 } }); } } } else if (spheres[i].y < 0) { spheres[i].destroy(); score += spheres[i].points; // Increase score when the sphere is dodged scoreTxt.setText('Score: ' + score); // Update score text spheres.splice(i, 1); } } } // Check if a fireball hits a sphere for (var i = spheres.length - 1; i >= 0; i--) { for (var j = fireballs.length - 1; j >= 0; j--) { if (spheres[i].intersects(fireballs[j])) { spheres[i].destroy(); fireballs[j].destroy(); score += spheres[i].points; // Increase score when a sphere is hit by a fireball scoreTxt.setText('Score: ' + score); // Update score text spheres.splice(i, 1); fireballs.splice(j, 1); break; } } } // Spawn new spheres if (!LK.gameOver && LK.ticks % 60 == 0) { var newSphere = new Sphere(); newSphere.x = Math.random() * 2048; newSphere.y = 2732; spheres.push(newSphere); game.addChild(newSphere); } // Regenerate player's health to max when score reaches 1000 if (score >= 1000) { healthBar.currentHealth = healthBar.maxHealth; } }; // Initialize dragon dragon = game.addChild(new Dragon()); dragon.x = 2048 / 2; dragon.y = 200; // Initialize level display var levelTxt = new Text2('Level: 1', { size: 100, fill: 0x800080, // Purple color font: "'Time new roman',Impact,'Arial Black',Tahoma" }); levelTxt.anchor.set(1, 1); LK.gui.bottomRight.addChild(levelTxt); levelTxt.x = -50; // Move the level text to the right side of the screen levelTxt.y = -100; // Position the level text at the bottom of the screen // Initialize score display scoreTxt = new Text2('Score: 0', { size: 100, fill: 0x800080, // Purple color font: "'Time new roman',Impact,'Arial Black',Tahoma" }); 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 = game.width / 2; // Position the score text in the middle of the screen 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 = 50; healthBar.y = 50; // Move health bar to the top of the screen healthBar.scaleX = 0.6; // Increase the size of the health bar LK.gui.top.addChild(healthBar); // Add the health bar to the GUI overlay. scoreTxt.anchor.set(0, 0); // Sets anchor to the left of the top edge of the text. scoreTxt.x = 50; // Position the score text on the left side of the screen scoreTxt.y = 150; // Position the score text 150 pixels from the top of the screen LK.gui.top.addChild(scoreTxt); // Add the score text to the GUI overlay. // 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(dragon.width / 2, Math.min(2048 - dragon.width / 2, x)); var newY = Math.max(dragon.height / 2, Math.min(2732 - dragon.height / 2, y)); dragNode.x = newX; dragNode.y = newY; // Shoot two fireballs at regular intervals if (LK.ticks % 30 == 0) { var fireball1 = new Fireball(); fireball1.x = dragon.x - 50; fireball1.y = dragon.y; fireballs.push(fireball1); game.addChild(fireball1); var fireball2 = new Fireball(); fireball2.x = dragon.x + 50; fireball2.y = dragon.y; fireballs.push(fireball2); game.addChild(fireball2); } } };
/****
* 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,
smooth: true,
filterQuality: 10
});
self.speed = 10; // Speed of the dragon
self.update = function () {
// Update logic for the dragon can be added here if needed
};
});
// Fireball class to represent the fireballs that the dragon shoots
var Fireball = Container.expand(function () {
var self = Container.call(this);
var fireballGraphics = self.attachAsset('Shout', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.5,
scaleY: 0.5,
smooth: true,
filterQuality: 10
});
self.speed = 20; // Increase the speed of the fireball
self.update = function () {
// Move the fireball straight down
self.y += self.speed;
};
});
// 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: 0.2,
// Scale to fit the game width
scaleY: 0.02
});
self.maxHealth = 1000;
self.currentHealth = self.maxHealth;
self.update = function () {
self.scaleX = self.currentHealth / self.maxHealth * 0.2; // Scale the health bar based on the current health and game width
self.scaleY = 0.02; // Keep the height of the health bar constant
self.currentHealth = Math.max(0, self.currentHealth); // Ensure health does not go below 0
};
});
// 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,
scaleX: 0.5,
scaleY: 2.5,
// Increase the height of the spheres
smooth: true,
filterQuality: 4
});
self.speed = 3; // Speed of the sphere
var size = Math.random() * (1.2 - 0.8) + 0.8;
self.points = Math.floor((1.2 - size) * 20);
self.update = function () {
// Move the sphere straight up
self.y -= self.speed;
};
});
/****
* 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 fireballs = []; // Initialize fireballs array
var score = 0; // Initialize score to 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 = true; // Enable smoothing to remove pixels
background.filterQuality = 10; // Set the filter quality to high to remove blur
background.scale.set(game.width / background.width, game.height / background.height); // Scale the background to fit the screen
// Function to handle game updates
game.update = function () {
// Update dragon position based on touch input
if (!LK.gameOver && dragNode && dragNode.global) {
dragNode.x = game.toLocal(dragNode.global).x;
}
// Update spheres and check for collisions
if (!LK.gameOver) {
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; // 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
}
});
}
}
} else if (spheres[i].y < 0) {
spheres[i].destroy();
score += spheres[i].points; // Increase score when the sphere is dodged
scoreTxt.setText('Score: ' + score); // Update score text
spheres.splice(i, 1);
}
}
}
// Check if a fireball hits a sphere
for (var i = spheres.length - 1; i >= 0; i--) {
for (var j = fireballs.length - 1; j >= 0; j--) {
if (spheres[i].intersects(fireballs[j])) {
spheres[i].destroy();
fireballs[j].destroy();
score += spheres[i].points; // Increase score when a sphere is hit by a fireball
scoreTxt.setText('Score: ' + score); // Update score text
spheres.splice(i, 1);
fireballs.splice(j, 1);
break;
}
}
}
// Spawn new spheres
if (!LK.gameOver && LK.ticks % 60 == 0) {
var newSphere = new Sphere();
newSphere.x = Math.random() * 2048;
newSphere.y = 2732;
spheres.push(newSphere);
game.addChild(newSphere);
}
// Regenerate player's health to max when score reaches 1000
if (score >= 1000) {
healthBar.currentHealth = healthBar.maxHealth;
}
};
// Initialize dragon
dragon = game.addChild(new Dragon());
dragon.x = 2048 / 2;
dragon.y = 200;
// Initialize level display
var levelTxt = new Text2('Level: 1', {
size: 100,
fill: 0x800080,
// Purple color
font: "'Time new roman',Impact,'Arial Black',Tahoma"
});
levelTxt.anchor.set(1, 1);
LK.gui.bottomRight.addChild(levelTxt);
levelTxt.x = -50; // Move the level text to the right side of the screen
levelTxt.y = -100; // Position the level text at the bottom of the screen
// Initialize score display
scoreTxt = new Text2('Score: 0', {
size: 100,
fill: 0x800080,
// Purple color
font: "'Time new roman',Impact,'Arial Black',Tahoma"
});
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 = game.width / 2; // Position the score text in the middle of the screen
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 = 50;
healthBar.y = 50; // Move health bar to the top of the screen
healthBar.scaleX = 0.6; // Increase the size of the health bar
LK.gui.top.addChild(healthBar); // Add the health bar to the GUI overlay.
scoreTxt.anchor.set(0, 0); // Sets anchor to the left of the top edge of the text.
scoreTxt.x = 50; // Position the score text on the left side of the screen
scoreTxt.y = 150; // Position the score text 150 pixels from the top of the screen
LK.gui.top.addChild(scoreTxt); // Add the score text to the GUI overlay.
// 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(dragon.width / 2, Math.min(2048 - dragon.width / 2, x));
var newY = Math.max(dragon.height / 2, Math.min(2732 - dragon.height / 2, y));
dragNode.x = newX;
dragNode.y = newY;
// Shoot two fireballs at regular intervals
if (LK.ticks % 30 == 0) {
var fireball1 = new Fireball();
fireball1.x = dragon.x - 50;
fireball1.y = dragon.y;
fireballs.push(fireball1);
game.addChild(fireball1);
var fireball2 = new Fireball();
fireball2.x = dragon.x + 50;
fireball2.y = dragon.y;
fireballs.push(fireball2);
game.addChild(fireball2);
}
}
};