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 Cloud = Container.expand(function (size) {
var self = Container.call(this);
var cloudType = size || 'medium';
var cloudGraphics = self.attachAsset('cloud_' + cloudType, {
anchorX: 0.5,
anchorY: 0.5,
alpha: 0.7
});
self.speed = -1 - Math.random() * 2;
self.driftY = Math.random() * 0.5 - 0.25;
self.update = function () {
self.x += self.speed;
self.y += self.driftY;
// Gentle cloud movement
cloudGraphics.alpha = 0.5 + Math.sin(LK.ticks * 0.01) * 0.2;
};
return self;
});
var Dragon = Container.expand(function () {
var self = Container.call(this);
// Create dragon body parts
var dragonBody = self.attachAsset('dragon_body', {
anchorX: 0.5,
anchorY: 0.5
});
var dragonHead = self.attachAsset('dragon_head', {
anchorX: 0.5,
anchorY: 0.5,
x: 70,
y: -10
});
var dragonTail = self.attachAsset('dragon_tail', {
anchorX: 0.5,
anchorY: 0.5,
x: -80,
y: 0
});
var leftWing = self.attachAsset('dragon_wing_left', {
anchorX: 0.8,
anchorY: 0.5,
x: -30,
y: -20
});
var rightWing = self.attachAsset('dragon_wing_right', {
anchorX: 0.2,
anchorY: 0.5,
x: -30,
y: 20
});
// Store references for animations
self.dragonBody = dragonBody;
self.dragonHead = dragonHead;
self.leftWing = leftWing;
self.rightWing = rightWing;
self.dragonTail = dragonTail;
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(self.leftWing, {
rotation: -0.5,
scaleY: 1.3
}, {
duration: 120,
easing: tween.easeOut
});
tween(self.rightWing, {
rotation: 0.5,
scaleY: 1.3
}, {
duration: 120,
easing: tween.easeOut,
onFinish: function onFinish() {
// Return wings to normal position
tween(self.leftWing, {
rotation: 0,
scaleY: 1.0
}, {
duration: 150,
easing: tween.easeIn
});
tween(self.rightWing, {
rotation: 0,
scaleY: 1.0
}, {
duration: 150,
easing: tween.easeIn
});
}
});
// Head bob animation
tween(self.dragonHead, {
y: -20
}, {
duration: 100,
onFinish: function onFinish() {
tween(self.dragonHead, {
y: -10
}, {
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;
self.dragonBody.rotation = targetRotation;
self.dragonHead.rotation = targetRotation * 0.8;
self.dragonTail.rotation = targetRotation * 1.2;
// Tail sway animation
self.dragonTail.rotation += Math.sin(LK.ticks * 0.1) * 0.1;
// Wings gentle movement when not flapping
if (!self.isFlapping) {
self.leftWing.rotation = Math.sin(LK.ticks * 0.08) * 0.1;
self.rightWing.rotation = -Math.sin(LK.ticks * 0.08) * 0.1;
}
// 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;
// Sparkling effect - scale animation
var sparkleScale = 1 + Math.sin(LK.ticks * 0.15) * 0.3;
gemGraphics.scaleX = sparkleScale;
gemGraphics.scaleY = sparkleScale;
// Color shifting for magical effect
var colorShift = Math.sin(LK.ticks * 0.1);
if (colorShift > 0.5) {
gemGraphics.tint = 0xffff00; // Golden
} else if (colorShift > 0) {
gemGraphics.tint = 0xff8c00; // Orange
} else {
gemGraphics.tint = 0xffd700; // Default gold
}
};
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 clouds = [];
var gameSpeed = 1;
var spawnTimer = 0;
var gemSpawnTimer = 0;
var scrollSpawnTimer = 0;
var cloudSpawnTimer = 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);
}
// Spawn cloud
function spawnCloud() {
var cloudSizes = ['small', 'medium', 'large'];
var size = cloudSizes[Math.floor(Math.random() * cloudSizes.length)];
var cloud = new Cloud(size);
cloud.x = 2200;
cloud.y = 200 + Math.random() * 2000;
clouds.push(cloud);
game.addChild(cloud);
}
// 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;
}
// Spawn clouds for atmosphere
cloudSpawnTimer++;
if (cloudSpawnTimer > 200 + Math.random() * 300) {
spawnCloud();
cloudSpawnTimer = 0;
}
// Update and clean up clouds
for (var c = clouds.length - 1; c >= 0; c--) {
var cloud = clouds[c];
if (cloud.x < -400) {
cloud.destroy();
clouds.splice(c, 1);
}
}
// 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)) {
// Enhanced collision effect - shake dragon before game over
tween(dragon, {
x: dragon.x + 20
}, {
duration: 50,
onFinish: function onFinish() {
tween(dragon, {
x: dragon.x - 40
}, {
duration: 50,
onFinish: function onFinish() {
tween(dragon, {
x: dragon.x + 20
}, {
duration: 50,
onFinish: function onFinish() {
// 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
@@ -5,14 +5,63 @@
/****
* Classes
****/
+var Cloud = Container.expand(function (size) {
+ var self = Container.call(this);
+ var cloudType = size || 'medium';
+ var cloudGraphics = self.attachAsset('cloud_' + cloudType, {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ alpha: 0.7
+ });
+ self.speed = -1 - Math.random() * 2;
+ self.driftY = Math.random() * 0.5 - 0.25;
+ self.update = function () {
+ self.x += self.speed;
+ self.y += self.driftY;
+ // Gentle cloud movement
+ cloudGraphics.alpha = 0.5 + Math.sin(LK.ticks * 0.01) * 0.2;
+ };
+ return self;
+});
var Dragon = Container.expand(function () {
var self = Container.call(this);
- var dragonGraphics = self.attachAsset('dragon', {
+ // Create dragon body parts
+ var dragonBody = self.attachAsset('dragon_body', {
anchorX: 0.5,
anchorY: 0.5
});
+ var dragonHead = self.attachAsset('dragon_head', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 70,
+ y: -10
+ });
+ var dragonTail = self.attachAsset('dragon_tail', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: -80,
+ y: 0
+ });
+ var leftWing = self.attachAsset('dragon_wing_left', {
+ anchorX: 0.8,
+ anchorY: 0.5,
+ x: -30,
+ y: -20
+ });
+ var rightWing = self.attachAsset('dragon_wing_right', {
+ anchorX: 0.2,
+ anchorY: 0.5,
+ x: -30,
+ y: 20
+ });
+ // Store references for animations
+ self.dragonBody = dragonBody;
+ self.dragonHead = dragonHead;
+ self.leftWing = leftWing;
+ self.rightWing = rightWing;
+ self.dragonTail = dragonTail;
self.velocity = 0;
self.maxVelocity = 12;
self.gravity = 0.8;
self.flapPower = -15;
@@ -22,16 +71,48 @@
self.velocity = self.flapPower;
self.isFlapping = true;
LK.getSound('flap').play();
// Wing flap animation
- tween(dragonGraphics, {
- scaleY: 1.2
+ tween(self.leftWing, {
+ rotation: -0.5,
+ scaleY: 1.3
}, {
- duration: 100,
+ duration: 120,
+ easing: tween.easeOut
+ });
+ tween(self.rightWing, {
+ rotation: 0.5,
+ scaleY: 1.3
+ }, {
+ duration: 120,
+ easing: tween.easeOut,
onFinish: function onFinish() {
- tween(dragonGraphics, {
+ // Return wings to normal position
+ tween(self.leftWing, {
+ rotation: 0,
scaleY: 1.0
}, {
+ duration: 150,
+ easing: tween.easeIn
+ });
+ tween(self.rightWing, {
+ rotation: 0,
+ scaleY: 1.0
+ }, {
+ duration: 150,
+ easing: tween.easeIn
+ });
+ }
+ });
+ // Head bob animation
+ tween(self.dragonHead, {
+ y: -20
+ }, {
+ duration: 100,
+ onFinish: function onFinish() {
+ tween(self.dragonHead, {
+ y: -10
+ }, {
duration: 100
});
}
});
@@ -49,9 +130,18 @@
// 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;
+ self.dragonBody.rotation = targetRotation;
+ self.dragonHead.rotation = targetRotation * 0.8;
+ self.dragonTail.rotation = targetRotation * 1.2;
+ // Tail sway animation
+ self.dragonTail.rotation += Math.sin(LK.ticks * 0.1) * 0.1;
+ // Wings gentle movement when not flapping
+ if (!self.isFlapping) {
+ self.leftWing.rotation = Math.sin(LK.ticks * 0.08) * 0.1;
+ self.rightWing.rotation = -Math.sin(LK.ticks * 0.08) * 0.1;
+ }
// Keep dragon on screen
if (self.y < 100) {
self.y = 100;
self.velocity = 0;
@@ -79,8 +169,21 @@
self.floatOffset += 0.1;
gemGraphics.y = Math.sin(self.floatOffset) * 10;
// Gentle rotation
gemGraphics.rotation += 0.05;
+ // Sparkling effect - scale animation
+ var sparkleScale = 1 + Math.sin(LK.ticks * 0.15) * 0.3;
+ gemGraphics.scaleX = sparkleScale;
+ gemGraphics.scaleY = sparkleScale;
+ // Color shifting for magical effect
+ var colorShift = Math.sin(LK.ticks * 0.1);
+ if (colorShift > 0.5) {
+ gemGraphics.tint = 0xffff00; // Golden
+ } else if (colorShift > 0) {
+ gemGraphics.tint = 0xff8c00; // Orange
+ } else {
+ gemGraphics.tint = 0xffd700; // Default gold
+ }
};
return self;
});
var Obstacle = Container.expand(function () {
@@ -126,12 +229,14 @@
var dragon;
var obstacles = [];
var gems = [];
var scrolls = [];
+var clouds = [];
var gameSpeed = 1;
var spawnTimer = 0;
var gemSpawnTimer = 0;
var scrollSpawnTimer = 0;
+var cloudSpawnTimer = 0;
var distance = 0;
// UI Elements
var scoreTxt = new Text2('Score: 0', {
size: 60,
@@ -184,8 +289,18 @@
scroll.y = 400 + Math.random() * 1900;
scrolls.push(scroll);
game.addChild(scroll);
}
+// Spawn cloud
+function spawnCloud() {
+ var cloudSizes = ['small', 'medium', 'large'];
+ var size = cloudSizes[Math.floor(Math.random() * cloudSizes.length)];
+ var cloud = new Cloud(size);
+ cloud.x = 2200;
+ cloud.y = 200 + Math.random() * 2000;
+ clouds.push(cloud);
+ game.addChild(cloud);
+}
// Main game loop
game.update = function () {
distance += gameSpeed;
distanceTxt.setText('Distance: ' + Math.floor(distance / 10) + 'm');
@@ -211,8 +326,22 @@
if (scrollSpawnTimer > 600) {
spawnScroll();
scrollSpawnTimer = 0;
}
+ // Spawn clouds for atmosphere
+ cloudSpawnTimer++;
+ if (cloudSpawnTimer > 200 + Math.random() * 300) {
+ spawnCloud();
+ cloudSpawnTimer = 0;
+ }
+ // Update and clean up clouds
+ for (var c = clouds.length - 1; c >= 0; c--) {
+ var cloud = clouds[c];
+ if (cloud.x < -400) {
+ cloud.destroy();
+ clouds.splice(c, 1);
+ }
+ }
// 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;
@@ -223,11 +352,33 @@
continue;
}
// Check collision with dragon
if (dragon.intersects(obstacle)) {
- // Flash screen and show game over
- LK.effects.flashScreen(0xff0000, 1000);
- LK.showGameOver();
+ // Enhanced collision effect - shake dragon before game over
+ tween(dragon, {
+ x: dragon.x + 20
+ }, {
+ duration: 50,
+ onFinish: function onFinish() {
+ tween(dragon, {
+ x: dragon.x - 40
+ }, {
+ duration: 50,
+ onFinish: function onFinish() {
+ tween(dragon, {
+ x: dragon.x + 20
+ }, {
+ duration: 50,
+ onFinish: function onFinish() {
+ // 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) {