User prompt
bugs: still adding 2 dragon too small, increase size very slightly improve: speed text, when it gets to 1.08 when another 2 gets added make it 1.1 etc
User prompt
Please fix the bug: 'dragonTail is not defined' in or related to this line: 'self.dragonTail = dragonTail;' Line Number: 394
User prompt
its going up in 2 bugs: hotbox weird improve: dragon model use 25 shapes minimum when faster by 0.1% so 1.1 1.2 etc, make the spacing of the rocks and trees further away from eachother reasonably ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
now add a speed text in the top left, it says 1x but every time you go through one and get score it goes up by 0.01%
User prompt
make dragon and hitbox a bit smaller
User prompt
make the dragon always visible, and change the backgrounds so its more transparent with fog ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
make the jumps quicker so its easier. and make the rocks and trees loooooong so you cant cheat by going above the rock... ALSO make the background way bigger and at the bottom, make sure the main game is always visible ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
remove the coins, make it so every time you go through the rock and tree it adds 1 to score. and make background bigger
User prompt
0make the dragon smaller
User prompt
make it more like flappy bird, make the dragon look better and be smoother with its animations7 ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
make the trees like flappy bird and rocks at the top, so bassacly rocks come down from top, trees from bottom, you have to navigate thru them. make the backgrounds at the back layer so dragon alsways visible and also bigger
User prompt
now make the kill bricks be at the bottom and top at all times, to stop camping. and improve dragon and tree models, add some different environments in the background ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
cool. now make all the models look better and some kill blocks at the bottom and top ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
cool, now imrove the models to look like a full game ↪💡 Consider importing and using the following plugins: @upit/tween.v1
Code edit (1 edits merged)
Please save this source code
User prompt
Wings of Fire: Dragon Flight
Initial prompt
can you make a 2d wings of fire game based of the books? make it professional
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Dragon = Container.expand(function () {
var self = Container.call(this);
var dragonGraphics = self.attachAsset('dragon', {
anchorX: 0.5,
anchorY: 0.5
});
self.velocity = 0;
self.maxVelocity = 12;
self.gravity = 0.8;
self.flapPower = -15;
self.isFlapping = false;
self.flap = function () {
if (!self.isFlapping) {
self.velocity = self.flapPower;
self.isFlapping = true;
LK.getSound('flap').play();
// Wing flap animation
tween(dragonGraphics, {
scaleY: 1.2
}, {
duration: 100,
onFinish: function onFinish() {
tween(dragonGraphics, {
scaleY: 1.0
}, {
duration: 100
});
}
});
}
};
self.update = function () {
// Apply gravity
self.velocity += self.gravity;
// Limit velocity
if (self.velocity > self.maxVelocity) {
self.velocity = self.maxVelocity;
}
// Update position
self.y += self.velocity;
// Rotate based on velocity for realistic flight
var targetRotation = self.velocity * 0.05;
if (targetRotation > 0.3) targetRotation = 0.3;
if (targetRotation < -0.3) targetRotation = -0.3;
dragonGraphics.rotation = targetRotation;
// Keep dragon on screen
if (self.y < 100) {
self.y = 100;
self.velocity = 0;
}
if (self.y > 2632) {
self.y = 2632;
self.velocity = 0;
}
self.isFlapping = false;
};
return self;
});
var Gem = Container.expand(function () {
var self = Container.call(this);
var gemGraphics = self.attachAsset('gem', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = -4;
self.collected = false;
self.floatOffset = 0;
self.update = function () {
self.x += self.speed;
// Floating animation
self.floatOffset += 0.1;
gemGraphics.y = Math.sin(self.floatOffset) * 10;
// Gentle rotation
gemGraphics.rotation += 0.05;
};
return self;
});
var Obstacle = Container.expand(function () {
var self = Container.call(this);
var obstacleGraphics = self.attachAsset('obstacle', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = -4;
self.passed = false;
self.update = function () {
self.x += self.speed;
};
return self;
});
var Scroll = Container.expand(function () {
var self = Container.call(this);
var scrollGraphics = self.attachAsset('scroll', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = -4;
self.collected = false;
self.update = function () {
self.x += self.speed;
// Gentle sway animation
scrollGraphics.rotation = Math.sin(LK.ticks * 0.02) * 0.1;
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87ceeb
});
/****
* Game Code
****/
// Game variables
var dragon;
var obstacles = [];
var gems = [];
var scrolls = [];
var gameSpeed = 1;
var spawnTimer = 0;
var gemSpawnTimer = 0;
var scrollSpawnTimer = 0;
var distance = 0;
// UI Elements
var scoreTxt = new Text2('Score: 0', {
size: 60,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
var distanceTxt = new Text2('Distance: 0m', {
size: 50,
fill: 0xFFFFFF
});
distanceTxt.anchor.set(1, 0);
distanceTxt.x = -20;
distanceTxt.y = 80;
LK.gui.topRight.addChild(distanceTxt);
// Create dragon
dragon = game.addChild(new Dragon());
dragon.x = 400;
dragon.y = 1366;
// Controls
game.down = function (x, y, obj) {
dragon.flap();
};
game.move = function (x, y, obj) {
// Optional: Allow continuous flapping while holding
};
game.up = function (x, y, obj) {
// Release action if needed
};
// Spawn obstacle
function spawnObstacle() {
var obstacle = new Obstacle();
obstacle.x = 2200;
obstacle.y = 200 + Math.random() * 2200;
obstacles.push(obstacle);
game.addChild(obstacle);
}
// Spawn gem
function spawnGem() {
var gem = new Gem();
gem.x = 2200;
gem.y = 300 + Math.random() * 2100;
gems.push(gem);
game.addChild(gem);
}
// Spawn scroll
function spawnScroll() {
var scroll = new Scroll();
scroll.x = 2200;
scroll.y = 400 + Math.random() * 1900;
scrolls.push(scroll);
game.addChild(scroll);
}
// Main game loop
game.update = function () {
distance += gameSpeed;
distanceTxt.setText('Distance: ' + Math.floor(distance / 10) + 'm');
// Increase difficulty over time
if (LK.ticks % 1800 === 0) {
// Every 30 seconds
gameSpeed += 0.2;
}
// Spawn obstacles
spawnTimer++;
if (spawnTimer > 120 - gameSpeed * 10) {
spawnObstacle();
spawnTimer = 0;
}
// Spawn gems
gemSpawnTimer++;
if (gemSpawnTimer > 180) {
spawnGem();
gemSpawnTimer = 0;
}
// Spawn scrolls (rare)
scrollSpawnTimer++;
if (scrollSpawnTimer > 600) {
spawnScroll();
scrollSpawnTimer = 0;
}
// Update and check obstacles
for (var i = obstacles.length - 1; i >= 0; i--) {
var obstacle = obstacles[i];
if (obstacle.lastX === undefined) obstacle.lastX = obstacle.x;
// Remove off-screen obstacles
if (obstacle.lastX >= -100 && obstacle.x < -100) {
obstacle.destroy();
obstacles.splice(i, 1);
continue;
}
// Check collision with dragon
if (dragon.intersects(obstacle)) {
// Flash screen and show game over
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
return;
}
// Score for passing obstacle
if (!obstacle.passed && obstacle.x < dragon.x - 60) {
obstacle.passed = true;
LK.setScore(LK.getScore() + 10);
scoreTxt.setText('Score: ' + LK.getScore());
}
obstacle.lastX = obstacle.x;
}
// Update and check gems
for (var j = gems.length - 1; j >= 0; j--) {
var gem = gems[j];
if (gem.lastX === undefined) gem.lastX = gem.x;
// Remove off-screen gems
if (gem.lastX >= -50 && gem.x < -50) {
gem.destroy();
gems.splice(j, 1);
continue;
}
// Check collection
if (!gem.collected && dragon.intersects(gem)) {
gem.collected = true;
LK.setScore(LK.getScore() + 50);
scoreTxt.setText('Score: ' + LK.getScore());
LK.getSound('collect').play();
// Gem collection effect
tween(gem, {
alpha: 0,
scaleX: 2,
scaleY: 2
}, {
duration: 300,
onFinish: function onFinish() {
gem.destroy();
}
});
gems.splice(j, 1);
continue;
}
gem.lastX = gem.x;
}
// Update and check scrolls
for (var k = scrolls.length - 1; k >= 0; k--) {
var scroll = scrolls[k];
if (scroll.lastX === undefined) scroll.lastX = scroll.x;
// Remove off-screen scrolls
if (scroll.lastX >= -50 && scroll.x < -50) {
scroll.destroy();
scrolls.splice(k, 1);
continue;
}
// Check collection
if (!scroll.collected && dragon.intersects(scroll)) {
scroll.collected = true;
LK.setScore(LK.getScore() + 100);
scoreTxt.setText('Score: ' + LK.getScore());
LK.getSound('collect').play();
// Scroll collection effect
tween(scroll, {
alpha: 0,
scaleX: 1.5,
scaleY: 1.5
}, {
duration: 400,
onFinish: function onFinish() {
scroll.destroy();
}
});
scrolls.splice(k, 1);
continue;
}
scroll.lastX = scroll.x;
}
// Win condition - survive long enough
if (LK.getScore() >= 2000) {
LK.showYouWin();
}
};
// Start background music
LK.playMusic('flight'); ===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,310 @@
-/****
+/****
+* Plugins
+****/
+var tween = LK.import("@upit/tween.v1");
+
+/****
+* Classes
+****/
+var Dragon = Container.expand(function () {
+ var self = Container.call(this);
+ var dragonGraphics = self.attachAsset('dragon', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.velocity = 0;
+ self.maxVelocity = 12;
+ self.gravity = 0.8;
+ self.flapPower = -15;
+ self.isFlapping = false;
+ self.flap = function () {
+ if (!self.isFlapping) {
+ self.velocity = self.flapPower;
+ self.isFlapping = true;
+ LK.getSound('flap').play();
+ // Wing flap animation
+ tween(dragonGraphics, {
+ scaleY: 1.2
+ }, {
+ duration: 100,
+ onFinish: function onFinish() {
+ tween(dragonGraphics, {
+ scaleY: 1.0
+ }, {
+ duration: 100
+ });
+ }
+ });
+ }
+ };
+ self.update = function () {
+ // Apply gravity
+ self.velocity += self.gravity;
+ // Limit velocity
+ if (self.velocity > self.maxVelocity) {
+ self.velocity = self.maxVelocity;
+ }
+ // Update position
+ self.y += self.velocity;
+ // Rotate based on velocity for realistic flight
+ var targetRotation = self.velocity * 0.05;
+ if (targetRotation > 0.3) targetRotation = 0.3;
+ if (targetRotation < -0.3) targetRotation = -0.3;
+ dragonGraphics.rotation = targetRotation;
+ // Keep dragon on screen
+ if (self.y < 100) {
+ self.y = 100;
+ self.velocity = 0;
+ }
+ if (self.y > 2632) {
+ self.y = 2632;
+ self.velocity = 0;
+ }
+ self.isFlapping = false;
+ };
+ return self;
+});
+var Gem = Container.expand(function () {
+ var self = Container.call(this);
+ var gemGraphics = self.attachAsset('gem', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.speed = -4;
+ self.collected = false;
+ self.floatOffset = 0;
+ self.update = function () {
+ self.x += self.speed;
+ // Floating animation
+ self.floatOffset += 0.1;
+ gemGraphics.y = Math.sin(self.floatOffset) * 10;
+ // Gentle rotation
+ gemGraphics.rotation += 0.05;
+ };
+ return self;
+});
+var Obstacle = Container.expand(function () {
+ var self = Container.call(this);
+ var obstacleGraphics = self.attachAsset('obstacle', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.speed = -4;
+ self.passed = false;
+ self.update = function () {
+ self.x += self.speed;
+ };
+ return self;
+});
+var Scroll = Container.expand(function () {
+ var self = Container.call(this);
+ var scrollGraphics = self.attachAsset('scroll', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.speed = -4;
+ self.collected = false;
+ self.update = function () {
+ self.x += self.speed;
+ // Gentle sway animation
+ scrollGraphics.rotation = Math.sin(LK.ticks * 0.02) * 0.1;
+ };
+ return self;
+});
+
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000
-});
\ No newline at end of file
+ backgroundColor: 0x87ceeb
+});
+
+/****
+* Game Code
+****/
+// Game variables
+var dragon;
+var obstacles = [];
+var gems = [];
+var scrolls = [];
+var gameSpeed = 1;
+var spawnTimer = 0;
+var gemSpawnTimer = 0;
+var scrollSpawnTimer = 0;
+var distance = 0;
+// UI Elements
+var scoreTxt = new Text2('Score: 0', {
+ size: 60,
+ fill: 0xFFFFFF
+});
+scoreTxt.anchor.set(0.5, 0);
+LK.gui.top.addChild(scoreTxt);
+var distanceTxt = new Text2('Distance: 0m', {
+ size: 50,
+ fill: 0xFFFFFF
+});
+distanceTxt.anchor.set(1, 0);
+distanceTxt.x = -20;
+distanceTxt.y = 80;
+LK.gui.topRight.addChild(distanceTxt);
+// Create dragon
+dragon = game.addChild(new Dragon());
+dragon.x = 400;
+dragon.y = 1366;
+// Controls
+game.down = function (x, y, obj) {
+ dragon.flap();
+};
+game.move = function (x, y, obj) {
+ // Optional: Allow continuous flapping while holding
+};
+game.up = function (x, y, obj) {
+ // Release action if needed
+};
+// Spawn obstacle
+function spawnObstacle() {
+ var obstacle = new Obstacle();
+ obstacle.x = 2200;
+ obstacle.y = 200 + Math.random() * 2200;
+ obstacles.push(obstacle);
+ game.addChild(obstacle);
+}
+// Spawn gem
+function spawnGem() {
+ var gem = new Gem();
+ gem.x = 2200;
+ gem.y = 300 + Math.random() * 2100;
+ gems.push(gem);
+ game.addChild(gem);
+}
+// Spawn scroll
+function spawnScroll() {
+ var scroll = new Scroll();
+ scroll.x = 2200;
+ scroll.y = 400 + Math.random() * 1900;
+ scrolls.push(scroll);
+ game.addChild(scroll);
+}
+// Main game loop
+game.update = function () {
+ distance += gameSpeed;
+ distanceTxt.setText('Distance: ' + Math.floor(distance / 10) + 'm');
+ // Increase difficulty over time
+ if (LK.ticks % 1800 === 0) {
+ // Every 30 seconds
+ gameSpeed += 0.2;
+ }
+ // Spawn obstacles
+ spawnTimer++;
+ if (spawnTimer > 120 - gameSpeed * 10) {
+ spawnObstacle();
+ spawnTimer = 0;
+ }
+ // Spawn gems
+ gemSpawnTimer++;
+ if (gemSpawnTimer > 180) {
+ spawnGem();
+ gemSpawnTimer = 0;
+ }
+ // Spawn scrolls (rare)
+ scrollSpawnTimer++;
+ if (scrollSpawnTimer > 600) {
+ spawnScroll();
+ scrollSpawnTimer = 0;
+ }
+ // Update and check obstacles
+ for (var i = obstacles.length - 1; i >= 0; i--) {
+ var obstacle = obstacles[i];
+ if (obstacle.lastX === undefined) obstacle.lastX = obstacle.x;
+ // Remove off-screen obstacles
+ if (obstacle.lastX >= -100 && obstacle.x < -100) {
+ obstacle.destroy();
+ obstacles.splice(i, 1);
+ continue;
+ }
+ // Check collision with dragon
+ if (dragon.intersects(obstacle)) {
+ // Flash screen and show game over
+ LK.effects.flashScreen(0xff0000, 1000);
+ LK.showGameOver();
+ return;
+ }
+ // Score for passing obstacle
+ if (!obstacle.passed && obstacle.x < dragon.x - 60) {
+ obstacle.passed = true;
+ LK.setScore(LK.getScore() + 10);
+ scoreTxt.setText('Score: ' + LK.getScore());
+ }
+ obstacle.lastX = obstacle.x;
+ }
+ // Update and check gems
+ for (var j = gems.length - 1; j >= 0; j--) {
+ var gem = gems[j];
+ if (gem.lastX === undefined) gem.lastX = gem.x;
+ // Remove off-screen gems
+ if (gem.lastX >= -50 && gem.x < -50) {
+ gem.destroy();
+ gems.splice(j, 1);
+ continue;
+ }
+ // Check collection
+ if (!gem.collected && dragon.intersects(gem)) {
+ gem.collected = true;
+ LK.setScore(LK.getScore() + 50);
+ scoreTxt.setText('Score: ' + LK.getScore());
+ LK.getSound('collect').play();
+ // Gem collection effect
+ tween(gem, {
+ alpha: 0,
+ scaleX: 2,
+ scaleY: 2
+ }, {
+ duration: 300,
+ onFinish: function onFinish() {
+ gem.destroy();
+ }
+ });
+ gems.splice(j, 1);
+ continue;
+ }
+ gem.lastX = gem.x;
+ }
+ // Update and check scrolls
+ for (var k = scrolls.length - 1; k >= 0; k--) {
+ var scroll = scrolls[k];
+ if (scroll.lastX === undefined) scroll.lastX = scroll.x;
+ // Remove off-screen scrolls
+ if (scroll.lastX >= -50 && scroll.x < -50) {
+ scroll.destroy();
+ scrolls.splice(k, 1);
+ continue;
+ }
+ // Check collection
+ if (!scroll.collected && dragon.intersects(scroll)) {
+ scroll.collected = true;
+ LK.setScore(LK.getScore() + 100);
+ scoreTxt.setText('Score: ' + LK.getScore());
+ LK.getSound('collect').play();
+ // Scroll collection effect
+ tween(scroll, {
+ alpha: 0,
+ scaleX: 1.5,
+ scaleY: 1.5
+ }, {
+ duration: 400,
+ onFinish: function onFinish() {
+ scroll.destroy();
+ }
+ });
+ scrolls.splice(k, 1);
+ continue;
+ }
+ scroll.lastX = scroll.x;
+ }
+ // Win condition - survive long enough
+ if (LK.getScore() >= 2000) {
+ LK.showYouWin();
+ }
+};
+// Start background music
+LK.playMusic('flight');
\ No newline at end of file