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 Castle = Container.expand(function () {
var self = Container.call(this);
// Castle base
var castleBase = self.attachAsset('obstacle', {
anchorX: 0.5,
anchorY: 1.0,
x: 0,
y: 0,
scaleX: 2.0,
scaleY: 1.5,
tint: 0x696969
});
// Castle towers
var tower1 = self.attachAsset('obstacle', {
anchorX: 0.5,
anchorY: 1.0,
x: -80,
y: -100,
scaleX: 0.8,
scaleY: 1.8,
tint: 0x555555
});
var tower2 = self.attachAsset('obstacle', {
anchorX: 0.5,
anchorY: 1.0,
x: 80,
y: -100,
scaleX: 0.8,
scaleY: 1.8,
tint: 0x555555
});
// Castle flags
var flag1 = self.attachAsset('scroll', {
anchorX: 0.0,
anchorY: 1.0,
x: -80,
y: -260,
scaleX: 1.2,
scaleY: 1.0,
tint: 0xff0000
});
var flag2 = self.attachAsset('scroll', {
anchorX: 0.0,
anchorY: 1.0,
x: 80,
y: -260,
scaleX: 1.2,
scaleY: 1.0,
tint: 0x0000ff
});
self.speed = -3;
self.update = function () {
self.x += self.speed;
// Flags wave in wind
flag1.rotation = Math.sin(LK.ticks * 0.1) * 0.2;
flag2.rotation = Math.sin(LK.ticks * 0.1 + 1) * 0.2;
};
return self;
});
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 with enhanced visuals
var dragonBody = self.attachAsset('dragon_body', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.4,
scaleY: 1.3,
tint: 0xff4500
});
// Add body segments for more detailed look
var bodySegment1 = self.attachAsset('dragon_body', {
anchorX: 0.5,
anchorY: 0.5,
x: -40,
y: 5,
scaleX: 1.0,
scaleY: 0.9,
tint: 0xe03e00
});
var bodySegment2 = self.attachAsset('dragon_body', {
anchorX: 0.5,
anchorY: 0.5,
x: -65,
y: 8,
scaleX: 0.8,
scaleY: 0.7,
tint: 0xcc3700
});
var dragonHead = self.attachAsset('dragon_head', {
anchorX: 0.5,
anchorY: 0.5,
x: 80,
y: -15,
scaleX: 1.5,
scaleY: 1.4,
tint: 0xb30000
});
// Add dragon eyes
var leftEye = self.attachAsset('gem', {
anchorX: 0.5,
anchorY: 0.5,
x: 90,
y: -20,
scaleX: 0.3,
scaleY: 0.3,
tint: 0x00ff00
});
var rightEye = self.attachAsset('gem', {
anchorX: 0.5,
anchorY: 0.5,
x: 90,
y: -10,
scaleX: 0.3,
scaleY: 0.3,
tint: 0x00ff00
});
var dragonTail = self.attachAsset('dragon_tail', {
anchorX: 0.5,
anchorY: 0.5,
x: -90,
y: 0,
scaleX: 0.9,
scaleY: 1.6,
tint: 0xaa2200
});
var leftWing = self.attachAsset('dragon_wing_left', {
anchorX: 0.8,
anchorY: 0.5,
x: -30,
y: -20,
scaleX: 1.4,
scaleY: 1.3
});
var rightWing = self.attachAsset('dragon_wing_right', {
anchorX: 0.2,
anchorY: 0.5,
x: -30,
y: 20,
scaleX: 1.4,
scaleY: 1.3
});
// 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,
scaleX: 1.3,
scaleY: 1.3,
tint: 0xffdd44
});
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 Mountain = Container.expand(function () {
var self = Container.call(this);
// Mountain peak
var mountainPeak = self.attachAsset('obstacle', {
anchorX: 0.5,
anchorY: 1.0,
x: 0,
y: 0,
scaleX: 3.0,
scaleY: 2.5,
tint: 0x696969
});
// Mountain side
var mountainSide = self.attachAsset('obstacle', {
anchorX: 0.5,
anchorY: 1.0,
x: -60,
y: 0,
scaleX: 2.5,
scaleY: 2.0,
tint: 0x778899
});
// Snow cap
var snowCap = self.attachAsset('cloud_small', {
anchorX: 0.5,
anchorY: 1.0,
x: 0,
y: -200,
scaleX: 1.5,
scaleY: 0.6,
tint: 0xfffafa
});
self.speed = -2;
self.update = function () {
self.x += self.speed;
};
return self;
});
var Obstacle = Container.expand(function () {
var self = Container.call(this);
// Tree trunk
var treeTrunk = self.attachAsset('obstacle', {
anchorX: 0.5,
anchorY: 1.0,
x: 0,
y: 0,
scaleX: 0.8,
scaleY: 1.2,
tint: 0x8b4513
});
// Tree foliage (top)
var treeFoliage1 = self.attachAsset('cloud_large', {
anchorX: 0.5,
anchorY: 0.5,
x: 0,
y: -180,
scaleX: 1.1,
scaleY: 0.8,
tint: 0x228b22
});
// Additional foliage layers
var treeFoliage2 = self.attachAsset('cloud_medium', {
anchorX: 0.5,
anchorY: 0.5,
x: -20,
y: -160,
scaleX: 0.9,
scaleY: 0.7,
tint: 0x32cd32
});
var treeFoliage3 = self.attachAsset('cloud_medium', {
anchorX: 0.5,
anchorY: 0.5,
x: 25,
y: -150,
scaleX: 0.8,
scaleY: 0.6,
tint: 0x00ff00
});
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;
});
var Spike = Container.expand(function (type) {
var self = Container.call(this);
var spikeType = type || 'top';
var spikeGraphics = self.attachAsset('spike_' + spikeType, {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = -4;
self.update = function () {
self.x += self.speed;
// Add menacing glow effect
var glowIntensity = 0.8 + Math.sin(LK.ticks * 0.2) * 0.2;
spikeGraphics.alpha = glowIntensity;
// Subtle color shift between dark gray and red
var colorShift = Math.sin(LK.ticks * 0.1);
if (colorShift > 0.3) {
spikeGraphics.tint = 0x4a0000; // Dark red
} else {
spikeGraphics.tint = 0x2c2c2c; // Dark gray
}
};
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 mountains = [];
var castles = [];
var topSpikes = [];
var bottomSpikes = [];
var gameSpeed = 1;
var spawnTimer = 0;
var gemSpawnTimer = 0;
var scrollSpawnTimer = 0;
var cloudSpawnTimer = 0;
var spikeSpawnTimer = 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;
// Create permanent kill zones to prevent camping
createPermanentKillZones();
// 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);
}
// Create permanent kill zones at top and bottom
function createPermanentKillZones() {
// Top kill zone - continuous barrier
for (var i = 0; i < 30; i++) {
var topKillBrick = new Spike('top');
topKillBrick.x = i * 80;
topKillBrick.y = 30;
topKillBrick.speed = 0; // Static, doesn't move
topSpikes.push(topKillBrick);
game.addChild(topKillBrick);
}
// Bottom kill zone - continuous barrier
for (var j = 0; j < 30; j++) {
var bottomKillBrick = new Spike('bottom');
bottomKillBrick.x = j * 80;
bottomKillBrick.y = 2702;
bottomKillBrick.speed = 0; // Static, doesn't move
bottomSpikes.push(bottomKillBrick);
game.addChild(bottomKillBrick);
}
}
// Spawn deadly spikes at top
function spawnTopSpikes() {
for (var i = 0; i < 8; i++) {
var spike = new Spike('top');
spike.x = 2200 + i * 80;
spike.y = 30;
topSpikes.push(spike);
game.addChild(spike);
}
}
// Spawn deadly spikes at bottom
function spawnBottomSpikes() {
for (var i = 0; i < 8; i++) {
var spike = new Spike('bottom');
spike.x = 2200 + i * 80;
spike.y = 2702;
bottomSpikes.push(spike);
game.addChild(spike);
}
}
// Spawn mountain environment
function spawnMountain() {
var mountain = new Mountain();
mountain.x = 2400;
mountain.y = 1800 + Math.random() * 800;
mountains.push(mountain);
game.addChild(mountain);
}
// Spawn castle environment
function spawnCastle() {
var castle = new Castle();
castle.x = 2400;
castle.y = 1600 + Math.random() * 600;
castles.push(castle);
game.addChild(castle);
}
// 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;
}
// Spawn mountains (background environment)
if (LK.ticks % 900 === 0) {
spawnMountain();
}
// Spawn castles (background environment)
if (LK.ticks % 1200 === 0) {
spawnCastle();
}
// Update and clean up mountains
for (var m = mountains.length - 1; m >= 0; m--) {
var mountain = mountains[m];
if (mountain.x < -600) {
mountain.destroy();
mountains.splice(m, 1);
}
}
// Update and clean up castles
for (var ct = castles.length - 1; ct >= 0; ct--) {
var castle = castles[ct];
if (castle.x < -400) {
castle.destroy();
castles.splice(ct, 1);
}
}
// Spawn deadly spikes periodically (less frequent now that we have permanent ones)
spikeSpawnTimer++;
if (spikeSpawnTimer > 800 + Math.random() * 400) {
spawnTopSpikes();
spawnBottomSpikes();
spikeSpawnTimer = 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;
}
// Update and clean up top spikes
for (var s1 = topSpikes.length - 1; s1 >= 0; s1--) {
var topSpike = topSpikes[s1];
if (topSpike.x < -100) {
topSpike.destroy();
topSpikes.splice(s1, 1);
continue;
}
// Check deadly collision with dragon
if (dragon.intersects(topSpike)) {
// Enhanced death effect - make dragon flash red
tween(dragon, {
tint: 0xff0000,
scaleX: 1.3,
scaleY: 1.3
}, {
duration: 200,
onFinish: function onFinish() {
LK.effects.flashScreen(0xff0000, 1500);
LK.showGameOver();
}
});
return;
}
}
// Update and clean up bottom spikes
for (var s2 = bottomSpikes.length - 1; s2 >= 0; s2--) {
var bottomSpike = bottomSpikes[s2];
if (bottomSpike.x < -100) {
bottomSpike.destroy();
bottomSpikes.splice(s2, 1);
continue;
}
// Check deadly collision with dragon
if (dragon.intersects(bottomSpike)) {
// Enhanced death effect - make dragon flash red
tween(dragon, {
tint: 0xff0000,
scaleX: 1.3,
scaleY: 1.3
}, {
duration: 200,
onFinish: function onFinish() {
LK.effects.flashScreen(0xff0000, 1500);
LK.showGameOver();
}
});
return;
}
}
// Win condition - survive long enough
if (LK.getScore() >= 2000) {
LK.showYouWin();
}
};
// Start background music
LK.playMusic('flight'); ===================================================================
--- original.js
+++ change.js
@@ -5,8 +5,67 @@
/****
* Classes
****/
+var Castle = Container.expand(function () {
+ var self = Container.call(this);
+ // Castle base
+ var castleBase = self.attachAsset('obstacle', {
+ anchorX: 0.5,
+ anchorY: 1.0,
+ x: 0,
+ y: 0,
+ scaleX: 2.0,
+ scaleY: 1.5,
+ tint: 0x696969
+ });
+ // Castle towers
+ var tower1 = self.attachAsset('obstacle', {
+ anchorX: 0.5,
+ anchorY: 1.0,
+ x: -80,
+ y: -100,
+ scaleX: 0.8,
+ scaleY: 1.8,
+ tint: 0x555555
+ });
+ var tower2 = self.attachAsset('obstacle', {
+ anchorX: 0.5,
+ anchorY: 1.0,
+ x: 80,
+ y: -100,
+ scaleX: 0.8,
+ scaleY: 1.8,
+ tint: 0x555555
+ });
+ // Castle flags
+ var flag1 = self.attachAsset('scroll', {
+ anchorX: 0.0,
+ anchorY: 1.0,
+ x: -80,
+ y: -260,
+ scaleX: 1.2,
+ scaleY: 1.0,
+ tint: 0xff0000
+ });
+ var flag2 = self.attachAsset('scroll', {
+ anchorX: 0.0,
+ anchorY: 1.0,
+ x: 80,
+ y: -260,
+ scaleX: 1.2,
+ scaleY: 1.0,
+ tint: 0x0000ff
+ });
+ self.speed = -3;
+ self.update = function () {
+ self.x += self.speed;
+ // Flags wave in wind
+ flag1.rotation = Math.sin(LK.ticks * 0.1) * 0.2;
+ flag2.rotation = Math.sin(LK.ticks * 0.1 + 1) * 0.2;
+ };
+ return self;
+});
var Cloud = Container.expand(function (size) {
var self = Container.call(this);
var cloudType = size || 'medium';
var cloudGraphics = self.attachAsset('cloud_' + cloudType, {
@@ -29,26 +88,67 @@
// Create dragon body parts with enhanced visuals
var dragonBody = self.attachAsset('dragon_body', {
anchorX: 0.5,
anchorY: 0.5,
- scaleX: 1.2,
- scaleY: 1.1
+ scaleX: 1.4,
+ scaleY: 1.3,
+ tint: 0xff4500
});
+ // Add body segments for more detailed look
+ var bodySegment1 = self.attachAsset('dragon_body', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: -40,
+ y: 5,
+ scaleX: 1.0,
+ scaleY: 0.9,
+ tint: 0xe03e00
+ });
+ var bodySegment2 = self.attachAsset('dragon_body', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: -65,
+ y: 8,
+ scaleX: 0.8,
+ scaleY: 0.7,
+ tint: 0xcc3700
+ });
var dragonHead = self.attachAsset('dragon_head', {
anchorX: 0.5,
anchorY: 0.5,
- x: 70,
+ x: 80,
+ y: -15,
+ scaleX: 1.5,
+ scaleY: 1.4,
+ tint: 0xb30000
+ });
+ // Add dragon eyes
+ var leftEye = self.attachAsset('gem', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 90,
+ y: -20,
+ scaleX: 0.3,
+ scaleY: 0.3,
+ tint: 0x00ff00
+ });
+ var rightEye = self.attachAsset('gem', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 90,
y: -10,
- scaleX: 1.3,
- scaleY: 1.2
+ scaleX: 0.3,
+ scaleY: 0.3,
+ tint: 0x00ff00
});
var dragonTail = self.attachAsset('dragon_tail', {
anchorX: 0.5,
anchorY: 0.5,
- x: -80,
+ x: -90,
y: 0,
- scaleX: 0.8,
- scaleY: 1.4
+ scaleX: 0.9,
+ scaleY: 1.6,
+ tint: 0xaa2200
});
var leftWing = self.attachAsset('dragon_wing_left', {
anchorX: 0.8,
anchorY: 0.5,
@@ -198,17 +298,87 @@
}
};
return self;
});
+var Mountain = Container.expand(function () {
+ var self = Container.call(this);
+ // Mountain peak
+ var mountainPeak = self.attachAsset('obstacle', {
+ anchorX: 0.5,
+ anchorY: 1.0,
+ x: 0,
+ y: 0,
+ scaleX: 3.0,
+ scaleY: 2.5,
+ tint: 0x696969
+ });
+ // Mountain side
+ var mountainSide = self.attachAsset('obstacle', {
+ anchorX: 0.5,
+ anchorY: 1.0,
+ x: -60,
+ y: 0,
+ scaleX: 2.5,
+ scaleY: 2.0,
+ tint: 0x778899
+ });
+ // Snow cap
+ var snowCap = self.attachAsset('cloud_small', {
+ anchorX: 0.5,
+ anchorY: 1.0,
+ x: 0,
+ y: -200,
+ scaleX: 1.5,
+ scaleY: 0.6,
+ tint: 0xfffafa
+ });
+ self.speed = -2;
+ self.update = function () {
+ self.x += self.speed;
+ };
+ return self;
+});
var Obstacle = Container.expand(function () {
var self = Container.call(this);
- var obstacleGraphics = self.attachAsset('obstacle', {
+ // Tree trunk
+ var treeTrunk = self.attachAsset('obstacle', {
anchorX: 0.5,
+ anchorY: 1.0,
+ x: 0,
+ y: 0,
+ scaleX: 0.8,
+ scaleY: 1.2,
+ tint: 0x8b4513
+ });
+ // Tree foliage (top)
+ var treeFoliage1 = self.attachAsset('cloud_large', {
+ anchorX: 0.5,
anchorY: 0.5,
- scaleX: 1.2,
- scaleY: 1.1,
- tint: 0x654321
+ x: 0,
+ y: -180,
+ scaleX: 1.1,
+ scaleY: 0.8,
+ tint: 0x228b22
});
+ // Additional foliage layers
+ var treeFoliage2 = self.attachAsset('cloud_medium', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: -20,
+ y: -160,
+ scaleX: 0.9,
+ scaleY: 0.7,
+ tint: 0x32cd32
+ });
+ var treeFoliage3 = self.attachAsset('cloud_medium', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 25,
+ y: -150,
+ scaleX: 0.8,
+ scaleY: 0.6,
+ tint: 0x00ff00
+ });
self.speed = -4;
self.passed = false;
self.update = function () {
self.x += self.speed;
@@ -269,8 +439,10 @@
var obstacles = [];
var gems = [];
var scrolls = [];
var clouds = [];
+var mountains = [];
+var castles = [];
var topSpikes = [];
var bottomSpikes = [];
var gameSpeed = 1;
var spawnTimer = 0;
@@ -297,8 +469,10 @@
// Create dragon
dragon = game.addChild(new Dragon());
dragon.x = 400;
dragon.y = 1366;
+// Create permanent kill zones to prevent camping
+createPermanentKillZones();
// Controls
game.down = function (x, y, obj) {
dragon.flap();
};
@@ -341,8 +515,29 @@
cloud.y = 200 + Math.random() * 2000;
clouds.push(cloud);
game.addChild(cloud);
}
+// Create permanent kill zones at top and bottom
+function createPermanentKillZones() {
+ // Top kill zone - continuous barrier
+ for (var i = 0; i < 30; i++) {
+ var topKillBrick = new Spike('top');
+ topKillBrick.x = i * 80;
+ topKillBrick.y = 30;
+ topKillBrick.speed = 0; // Static, doesn't move
+ topSpikes.push(topKillBrick);
+ game.addChild(topKillBrick);
+ }
+ // Bottom kill zone - continuous barrier
+ for (var j = 0; j < 30; j++) {
+ var bottomKillBrick = new Spike('bottom');
+ bottomKillBrick.x = j * 80;
+ bottomKillBrick.y = 2702;
+ bottomKillBrick.speed = 0; // Static, doesn't move
+ bottomSpikes.push(bottomKillBrick);
+ game.addChild(bottomKillBrick);
+ }
+}
// Spawn deadly spikes at top
function spawnTopSpikes() {
for (var i = 0; i < 8; i++) {
var spike = new Spike('top');
@@ -361,8 +556,24 @@
bottomSpikes.push(spike);
game.addChild(spike);
}
}
+// Spawn mountain environment
+function spawnMountain() {
+ var mountain = new Mountain();
+ mountain.x = 2400;
+ mountain.y = 1800 + Math.random() * 800;
+ mountains.push(mountain);
+ game.addChild(mountain);
+}
+// Spawn castle environment
+function spawnCastle() {
+ var castle = new Castle();
+ castle.x = 2400;
+ castle.y = 1600 + Math.random() * 600;
+ castles.push(castle);
+ game.addChild(castle);
+}
// Main game loop
game.update = function () {
distance += gameSpeed;
distanceTxt.setText('Distance: ' + Math.floor(distance / 10) + 'm');
@@ -394,11 +605,35 @@
if (cloudSpawnTimer > 200 + Math.random() * 300) {
spawnCloud();
cloudSpawnTimer = 0;
}
- // Spawn deadly spikes periodically
+ // Spawn mountains (background environment)
+ if (LK.ticks % 900 === 0) {
+ spawnMountain();
+ }
+ // Spawn castles (background environment)
+ if (LK.ticks % 1200 === 0) {
+ spawnCastle();
+ }
+ // Update and clean up mountains
+ for (var m = mountains.length - 1; m >= 0; m--) {
+ var mountain = mountains[m];
+ if (mountain.x < -600) {
+ mountain.destroy();
+ mountains.splice(m, 1);
+ }
+ }
+ // Update and clean up castles
+ for (var ct = castles.length - 1; ct >= 0; ct--) {
+ var castle = castles[ct];
+ if (castle.x < -400) {
+ castle.destroy();
+ castles.splice(ct, 1);
+ }
+ }
+ // Spawn deadly spikes periodically (less frequent now that we have permanent ones)
spikeSpawnTimer++;
- if (spikeSpawnTimer > 400 + Math.random() * 200) {
+ if (spikeSpawnTimer > 800 + Math.random() * 400) {
spawnTopSpikes();
spawnBottomSpikes();
spikeSpawnTimer = 0;
}