Code edit (1 edits merged)
Please save this source code
User prompt
Deixe eu arrastar as Torres do menu para o jogo de acordo com o gold
User prompt
Deixe as Torres aparecerem sem precisar esperar uma quantidade certa de Score
User prompt
Somente a Towersprite1 está aparecendo no jogo, as outras não estão aparecendo, mesmo eu comprando elas com o gold, arrume isso imediatamente
User prompt
Deixe todas as Torres disponíveis para uso de acordo com o gold
User prompt
Quando eu clicar na torre disponível para comprar de acordo com o gold no menu deixe ela selecionada para eu usar em jogo
User prompt
Quando clico na (Towersprite) no menu de torres ela não aparece em campo no jogo, arrume isso por favor
User prompt
Delete upgrade Towers e cost
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'cost')' in or related to this line: 'var towerCost = towerTypes[obj.towerTypeIndex].cost;' Line Number: 1326
User prompt
Deixe todas as Torres do menu selecionáveis para usar de acordo com a quantidade de Gold indicada
User prompt
Faça o towersprite1 atacar usando a bulletsprite1
User prompt
Acrescente a towersprite ao menu de towers
User prompt
Delete o botão Sprite
User prompt
Coloque o Score ao lado direito da contagem de Gold
User prompt
Coloque a Contagem de Score no canto superior direito da tela
User prompt
Coloque a contagem do Gold ao Lado direito do tesouro
User prompt
Coloque a animação do Gold também no canto superior da tela junto com o tesouro ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Coloque a caixa do tesouro no canto superior a tela
User prompt
Coloque a caixa de tesouro mais para baixo
User prompt
Coloque a caixa de tesouro mais para baixo
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'cost')' in or related to this line: 'if (playerGold >= selectedTower.cost) {' Line Number: 1459
User prompt
Please fix the bug: 'TypeError: Cannot set properties of undefined (setting 'alpha')' in or related to this line: 'obj.border.alpha = 0.5;' Line Number: 1302
User prompt
Faça um menu para que eu possa escolher as Torres que eu quero colocar no jogo
User prompt
change the name of the game to (Monster Defense)
Remix started
Copy Tower Defense
/****
* Classes
****/
// Enemies below here.
var BalrogEnemy = Container.expand(function () {
var self = Container.call(this);
console.log('Balrog Spawned');
var balrogGraphics = self.attachAsset('balrogSprite', {
anchorX: 0.5,
anchorY: 0.5
});
balrogGraphics.scale.set(2.5);
var healthBar = new HealthBar(300);
healthBar.y = -balrogGraphics.height + 100;
self.addChild(healthBar);
self.healthBar = healthBar;
self.healthBar.updateHealth(100);
self.hitpoints = balrogHitpoints;
self.maxHitpoints = balrogHitpoints;
self.isDead = false;
balrogHitpoints *= 2;
self._move_migrated = function () {
var minDist = Infinity;
var closestTower = null;
for (var i = 0; i < towers.length; i++) {
var dx = towers[i].x - self.x;
var dy = towers[i].y - self.y;
var dist = Math.sqrt(dx * dx + dy * dy);
if (dist < minDist) {
minDist = dist;
closestTower = towers[i];
}
}
if (closestTower && minDist < closestTower.width / 2 + self.width / 2) {
//closestTower.health -= 4;
closestTower.takeDamage(4);
if (closestTower.health <= 0) {
var towerIndex = towers.indexOf(closestTower);
if (towerIndex > -1) {
towers.splice(towerIndex, 1);
}
closestTower.destroy();
}
} else if (closestTower && minDist < 100) {
var avoidanceForce = 8;
var ax = self.x - closestTower.x;
var ay = self.y - closestTower.y;
var len = Math.sqrt(ax * ax + ay * ay);
ax = ax / len * avoidanceForce;
ay = ay / len * avoidanceForce;
self.x += ax;
self.y += ay;
} else {
self.zigzagCounter = self.zigzagCounter || 0;
self.zigzagDirection = self.zigzagDirection || 1;
if (self.zigzagCounter++ % self.zigzagTension === 0) {
self.zigzagDirection *= -1;
}
self.x += 4 * self.zigzagDirection;
self.y += 2;
if (Math.random() < 0.01) {
self.zigzagTension = Math.floor(Math.random() * 40) + 10;
}
if (self.x > 2048) {
self.zigzagDirection = -1;
}
if (self.x < 0) {
self.zigzagDirection = 1;
}
var scaleIncrement = (1 - 0.1) / 200;
self.scale.x += scaleIncrement;
self.scale.y += scaleIncrement;
self.scale.x = Math.min(self.scale.x, 1);
self.scale.y = Math.min(self.scale.y, 1);
if (self.zigzagCounter % 10 == 0) {
self.rotation = (0.5 - Math.random()) * (Math.PI * 2 / 100);
}
}
};
self.die = function () {
playerGold += 500;
playerScore += 10000;
updateScoreLabel();
updateGoldLabel();
for (var i = 0; i < 100; i++) {
var t = new GoldCoin(self.x, self.y, 150, 150, i * 2);
game.addChild(t);
goldCoins.push(t);
}
self.isDead = true;
};
});
var Bullet = Container.expand(function (upgradeLevel) {
var self = Container.call(this);
//self.game = null;
self.upgradeLevel = upgradeLevel;
self.damage = towerDamage[self.upgradeLevel];
self.isDead = false;
var bulletGraphics = self.attachAsset('bullet', {
anchorX: 0.5,
anchorY: 0.5
});
bulletGraphics.scale.set(0.2);
var bulletGraphics1 = self.attachAsset('bulletSprite1', {
anchorX: 0.5,
anchorY: 0.5
});
var bulletGraphics2 = self.attachAsset('bulletSprite2', {
anchorX: 0.5,
anchorY: 0.5
});
var bulletGraphics3 = self.attachAsset('bulletSprite3', {
anchorX: 0.5,
anchorY: 0.5
});
var bulletGraphics4 = self.attachAsset('bulletSprite4', {
anchorX: 0.5,
anchorY: 0.5
});
var bulletGraphics5 = self.attachAsset('bulletSprite5', {
anchorX: 0.5,
anchorY: 0.5
});
var bulletGraphics6 = self.attachAsset('bulletSprite6', {
anchorX: 0.5,
anchorY: 0.5
});
var bulletGraphics7 = self.attachAsset('bulletSprite7', {
anchorX: 0.5,
anchorY: 0.5
});
var bulletGraphics8 = self.attachAsset('bulletSprite8', {
anchorX: 0.5,
anchorY: 0.5
});
bulletGraphics1.scale.set(.2);
bulletGraphics2.scale.set(.2);
bulletGraphics3.scale.set(.2);
bulletGraphics4.scale.set(.2);
bulletGraphics5.scale.set(.2);
bulletGraphics6.scale.set(.2);
bulletGraphics7.scale.set(.2);
bulletGraphics8.scale.set(.2);
bulletGraphics1.alpha = 0;
bulletGraphics2.alpha = 0;
bulletGraphics3.alpha = 0;
bulletGraphics4.alpha = 0;
bulletGraphics5.alpha = 0;
bulletGraphics6.alpha = 0;
bulletGraphics7.alpha = 0;
bulletGraphics8.alpha = 0;
var a = [bulletGraphics1, bulletGraphics2, bulletGraphics3, bulletGraphics4, bulletGraphics5, bulletGraphics6, bulletGraphics7, bulletGraphics8];
if (self.upgradeLevel > 0) {
bulletGraphics.alpha = 0;
for (var i = 0; i < 8; i++) {
if (i + 1 == self.upgradeLevel) {
a[i].alpha = 1;
} else {
a[i].setAlpha = 0;
}
}
}
self.vx = 0;
self.vy = 0;
self._move_migrated = function () {
if (self.target) {
var tx = self.target.x - this.x;
var ty = self.target.y - this.y;
var dist = Math.sqrt(tx * tx + ty * ty);
if (dist > 0) {
self.x += self.vx * 10;
self.y += self.vy * 10;
}
if (dist < self.width / 2 + self.target.width / 2) {
self.hit();
} else if (self.x < 0 || self.x > 2048 || self.y < 0 || self.y > 2732) {
self.isDead = true;
}
}
};
self.hit = function () {
self.target.hitpoints -= self.damage;
self.target.healthBar.updateHealth(self.target.hitpoints / self.target.maxHitpoints * 100);
if (self.target.hitpoints <= 0) {
self.target.die();
}
self.isDead = true;
};
});
var CityWall = Container.expand(function () {
var self = Container.call(this);
var wallGraphics = self.attachAsset('cityWallSprite', {
anchorX: 0.5,
anchorY: 0.5
});
self.addChild(wallGraphics);
});
var DeathKnightEnemy = Container.expand(function () {
var self = Container.call(this);
console.log('DeathKnight Spawned');
var dKnightGraphics = self.attachAsset('deathKnightSprite', {
anchorX: 0.5,
anchorY: 0.5
});
dKnightGraphics.scale.set(2.5);
var healthBar = new HealthBar(100);
healthBar.y = -dKnightGraphics.height - 50;
self.addChild(healthBar);
self.healthBar = healthBar;
self.healthBar.updateHealth(100);
self.hitpoints = 100;
self.maxHitpoints = 100;
self.isDead = false;
self._move_migrated = function () {
var minDist = Infinity;
var closestTower = null;
for (var i = 0; i < towers.length; i++) {
var dx = towers[i].x - self.x;
var dy = towers[i].y - self.y;
var dist = Math.sqrt(dx * dx + dy * dy);
if (dist < minDist) {
minDist = dist;
closestTower = towers[i];
}
}
if (closestTower && minDist < closestTower.width / 2 + self.width / 2) {
//closestTower.health -= 1;
closestTower.takeDamage(1);
if (closestTower.health <= 0) {
var towerIndex = towers.indexOf(closestTower);
if (towerIndex > -1) {
towers.splice(towerIndex, 1);
}
closestTower.destroy();
}
} else if (closestTower && minDist < 100) {
var avoidanceForce = 8;
var ax = self.x - closestTower.x;
var ay = self.y - closestTower.y;
var len = Math.sqrt(ax * ax + ay * ay);
ax = ax / len * avoidanceForce;
ay = ay / len * avoidanceForce;
self.x += ax;
self.y += ay;
} else {
self.zigzagCounter = self.zigzagCounter || 0;
self.zigzagDirection = self.zigzagDirection || 1;
if (self.zigzagCounter++ % self.zigzagTension === 0) {
self.zigzagDirection *= -1;
}
self.x += 4 * self.zigzagDirection;
self.y += 2;
if (Math.random() < 0.01) {
self.zigzagTension = Math.floor(Math.random() * 40) + 10;
}
if (self.x > 2048) {
self.zigzagDirection = -1;
}
if (self.x < 0) {
self.zigzagDirection = 1;
}
var scaleIncrement = (1 - 0.1) / 200;
self.scale.x += scaleIncrement;
self.scale.y += scaleIncrement;
self.scale.x = Math.min(self.scale.x, 1);
self.scale.y = Math.min(self.scale.y, 1);
if (self.zigzagCounter % 10 == 0) {
self.rotation = (0.5 - Math.random()) * (Math.PI * 2 / 100);
}
}
};
self.die = function () {
playerGold += 50;
playerScore += 2222;
updateScoreLabel();
updateGoldLabel();
for (var i = 0; i < 40; i++) {
var t = new GoldCoin(self.x, self.y, 150, 150, i * 2);
game.addChild(t);
goldCoins.push(t);
}
self.isDead = true;
};
});
var DragonEnemy = Container.expand(function () {
var self = Container.call(this);
console.log('Dragon Enemy Spawned');
var enemyGraphics1 = self.attachAsset('dragonSprite1', {
anchorX: 0.5,
anchorY: 0.5
});
enemyGraphics1.scale.set(1);
var enemyGraphics2 = self.attachAsset('dragonSprite2', {
anchorX: 0.5,
anchorY: 0.5
});
enemyGraphics2.scale.set(1);
enemyGraphics2.alpha = 0;
/*
var dragonFire = new DragonFire();
dragonFire.x = -100;
dragonFire.y = 80;
self.addChild(dragonFire);
self.dragonFire = dragonFire;
*/
var healthBar = new HealthBar();
healthBar.y = -enemyGraphics1.height + 180;
self.addChild(healthBar);
self.healthBar = healthBar;
self.healthBar.updateHealth(100);
self.healthBar.alpha = 0;
self.hitpoints = 6000;
self.maxHitpoints = 6000;
self.isDead = false;
self.zigzagTension = 400;
self.zigzagDirection = 1;
self.flying = true;
self._move_migrated = function () {
var minDist = Infinity;
var closestTower = null;
for (var i = 0; i < towers.length; i++) {
var dx = towers[i].x - self.x;
var dy = towers[i].y - self.y;
var dist = Math.sqrt(dx * dx + dy * dy);
if (dist < minDist) {
minDist = dist;
closestTower = towers[i];
}
}
if (closestTower && minDist < closestTower.width / 2 + self.width / 2) {
//closestTower.health -= 0.5;
closestTower.takeDamage(7);
if (closestTower.health <= 0) {
var towerIndex = towers.indexOf(closestTower);
if (towerIndex > -1) {
towers.splice(towerIndex, 1);
}
closestTower.destroy();
}
}
self.zigzagCounter = self.zigzagCounter || 0;
//self.zigzagDirection = self.zigzagDirection || 1;
if (self.zigzagCounter++ % self.zigzagTension === 0) {
if (self.y < 1800) {
self.zigzagDirection *= -1;
}
}
self.x += 4 * self.zigzagDirection;
if (self.y < 1800) {
self.y += 2;
}
/*
if (Math.random() < 0.005) {
self.zigzagTension = Math.floor(Math.random() * 380) + 20;
}*/
if (self.x > 2048) {
if (self.y < 1800) {
self.zigzagDirection = -1;
} else {
if (self.x > 2448) {
self.isDead = true;
}
}
}
if (self.x < 0) {
if (self.y < 1800) {
self.zigzagDirection = 1;
} else {
if (self.x < -400) {
self.isDead = true;
}
}
}
var scaleIncrement = (1 - 0.1) / 200;
self.scale.x += scaleIncrement;
self.scale.y += scaleIncrement;
self.scale.x = Math.min(self.scale.x, 1);
self.scale.y = Math.min(self.scale.y, 1);
if (self.zigzagCounter++ % self.zigzagTension === 0) {
self.zigzagDirection *= -1;
}
if (self.zigzagCounter % 5 == 0) {
self.rotation = (0.5 - Math.random()) * (Math.PI * 2 / 50);
}
if (self.zigzagDirection == 1) {
//self.removeChild(self.graphics);
//self.graphics = enemyGraphics1;
//self.addChild(self.graphics);
enemyGraphics2.alpha = 0;
enemyGraphics1.alpha = 1;
//self.dragonFire.scale.x = -1;
//self.dragonFire.x = 100;
} else {
//self.removeChild(self.graphics);
//self.graphics = enemyGraphics2;
//self.addChild(self.graphics);
enemyGraphics1.alpha = 0;
enemyGraphics2.alpha = 1;
//self.dragonFire.scale.x = 1;
//self.dragonFire.x = -100;
}
/*
// Check for damage to towers
var minDist = Infinity;
var closestTower = null;
for (var i = 0; i < towers.length; i++) {
var dfx = self.x + self.zigzagDirection == 1 ? 300 : -300;
var dfy = self.y + 250;
//var dx = towers[i].x - self.x + dragonFire.x;
//var dy = towers[i].y - self.y + dragonFire.y;
var dx = towers[i].x - dfx;
var dy = towers[i].y - dfy;
var dist = Math.sqrt(dx * dx + dy * dy);
if (dist < minDist) {
minDist = dist;
closestTower = towers[i];
}
}
//if (closestTower && minDist < closestTower.width / 2 + self.width / 2) {
if (closestTower && minDist < 800) {
//closestTower.health -= 0.5;
closestTower.takeDamage(10);
if (closestTower.health <= 0) {
var towerIndex = towers.indexOf(closestTower);
if (towerIndex > -1) {
towers.splice(towerIndex, 1);
}
closestTower.destroy();
}
}*/
};
self.die = function () {
playerGold += 10;
playerScore += 150;
updateScoreLabel();
updateGoldLabel();
for (var i = 0; i < 8; i++) {
var t = new GoldCoin(self.x, self.y, 150, 150, i * 2);
game.addChild(t);
goldCoins.push(t);
}
self.isDead = true;
};
});
var DragonFire = Container.expand(function () {
var self = Container.call(this);
var graphics = self.attachAsset('dragonFire', {
anchorX: 1,
anchorY: 0
});
self.update = function () {
this.scale.x += 0.2 - Math.random() * 0.4;
};
});
// Goblin,
var Enemy = Container.expand(function () {
var self = Container.call(this);
console.log('Standard Enemy Spawned');
var enemyGraphics = self.attachAsset('enemySprite', {
anchorX: 0.5,
anchorY: 0.5
});
enemyGraphics.scale.set(0.8);
var healthBar = new HealthBar(3);
healthBar.y = -enemyGraphics.height + 40;
self.addChild(healthBar);
self.healthBar = healthBar;
self.healthBar.updateHealth(100);
self.isDead = false;
self.hitpoints = 3;
self.maxHitpoints = 3;
self.zigzagTension = Math.floor(Math.random() * 40) + 10;
self._move_migrated = function () {
//console.log('Enemy move');
var minDist = Infinity;
var closestTower = null;
for (var i = 0; i < towers.length; i++) {
var dx = towers[i].x - self.x;
var dy = towers[i].y - self.y;
var dist = Math.sqrt(dx * dx + dy * dy);
if (dist < minDist) {
minDist = dist;
closestTower = towers[i];
}
}
if (closestTower && minDist < closestTower.width / 2 + self.width / 2) {
//closestTower.health -= 0.5;
closestTower.takeDamage(0.5);
if (closestTower.health <= 0) {
var towerIndex = towers.indexOf(closestTower);
if (towerIndex > -1) {
towers.splice(towerIndex, 1);
}
closestTower.destroy();
}
} else if (closestTower && minDist < 100) {
var avoidanceForce = 8;
var ax = self.x - closestTower.x;
var ay = self.y - closestTower.y;
var len = Math.sqrt(ax * ax + ay * ay);
ax = ax / len * avoidanceForce;
ay = ay / len * avoidanceForce;
self.x += ax;
self.y += ay;
} else {
self.zigzagCounter = self.zigzagCounter || 0;
self.zigzagDirection = self.zigzagDirection || 1;
if (self.zigzagCounter++ % self.zigzagTension === 0) {
self.zigzagDirection *= -1;
}
self.x += 4 * self.zigzagDirection;
self.y += 2;
if (Math.random() < 0.01) {
self.zigzagTension = Math.floor(Math.random() * 40) + 10;
}
if (self.x > 2048) {
self.zigzagDirection = -1;
}
if (self.x < 0) {
self.zigzagDirection = 1;
}
var scaleIncrement = (1 - 0.1) / 200;
self.scale.x += scaleIncrement;
self.scale.y += scaleIncrement;
self.scale.x = Math.min(self.scale.x, 1);
self.scale.y = Math.min(self.scale.y, 1);
self.rotation = (0.5 - Math.random()) * (Math.PI * 2 / 50);
}
};
self.die = function () {
playerGold += 5;
playerScore += 100;
updateScoreLabel();
updateGoldLabel();
for (var i = 0; i < 5; i++) {
var t = new GoldCoin(self.x, self.y, 150, 150, i * 2);
game.addChild(t);
goldCoins.push(t);
}
self.isDead = true;
};
});
var FlyingEnemy = Container.expand(function () {
var self = Container.call(this);
console.log('Flying Enemy Spawned');
var enemyGraphics1 = self.attachAsset('flyingEnemySprite', {
anchorX: 0.5,
anchorY: 0.5
});
enemyGraphics1.scale.set(1);
var enemyGraphics2 = self.attachAsset('flyingEnemySprite2', {
anchorX: 0.5,
anchorY: 0.5
});
enemyGraphics2.scale.set(1);
var healthBar = new HealthBar(6);
healthBar.y = -enemyGraphics1.height + 20;
self.addChild(healthBar);
self.healthBar = healthBar;
self.healthBar.updateHealth(100);
self.hitpoints = 6;
self.maxHitpoints = 6;
self.isDead = false;
self.zigzagTension = 400;
self.flying = true;
self._move_migrated = function () {
self.zigzagCounter = self.zigzagCounter || 0;
self.zigzagDirection = self.zigzagDirection || 1;
if (self.zigzagCounter++ % self.zigzagTension === 0) {
self.zigzagDirection *= -1;
}
self.x += 4 * self.zigzagDirection;
self.y += 2;
if (Math.random() < 0.005) {
self.zigzagTension = Math.floor(Math.random() * 380) + 20;
}
if (self.x > 2048) {
self.zigzagDirection = -1;
}
if (self.x < 0) {
self.zigzagDirection = 1;
}
var scaleIncrement = (1 - 0.1) / 200;
self.scale.x += scaleIncrement;
self.scale.y += scaleIncrement;
self.scale.x = Math.min(self.scale.x, 1);
self.scale.y = Math.min(self.scale.y, 1);
if (self.zigzagCounter++ % self.zigzagTension === 0) {
self.zigzagDirection *= -1;
}
if (self.zigzagCounter % 5 == 0) {
self.rotation = (0.5 - Math.random()) * (Math.PI * 2 / 50);
}
if (self.zigzagDirection == 1) {
self.removeChild(self.graphics);
self.graphics = enemyGraphics1;
self.addChild(self.graphics);
} else {
self.removeChild(self.graphics);
self.graphics = enemyGraphics2;
self.addChild(self.graphics);
}
};
self.die = function () {
playerGold += 10;
playerScore += 150;
updateScoreLabel();
updateGoldLabel();
for (var i = 0; i < 8; i++) {
var t = new GoldCoin(self.x, self.y, 150, 150, i * 2);
game.addChild(t);
goldCoins.push(t);
}
self.isDead = true;
};
});
var GoldCoin = Container.expand(function (startX, startY, endX, endY, delay) {
var self = Container.call(this);
GoldCoin.delayIncrement = 0;
//self.game = this;
var coinGraphics = self.attachAsset('goldCoinSprite', {
anchorX: 0.5,
anchorY: 0.5
});
self.addChild(coinGraphics);
self.x = startX;
self.y = startY;
self.isDead = false;
var distance = Math.sqrt(Math.pow(endX - startX, 2) + Math.pow(endY - startY, 2));
self.delayCounter = delay * 2;
var duration = 60 + delay;
var vx = (endX - startX) / duration;
var vy = (endY - startY) / duration;
self.alpha = 0;
self.path = createQuadraticBezierArcPoints(startX, startY, endX, startY - 100, endX, endY, 60);
self._move_migrated = function () {
if (self.delayCounter > 0) {
self.delayCounter--;
} else {
self.alpha = 1;
if (self.path[duration]) {
self.x = self.path[duration - self.delayCounter][0];
self.y = self.path[duration - self.delayCounter][1];
}
}
if (--duration <= 0) {
//self.destroy();
self.isDead = true;
}
};
});
var HealthBar = Container.expand(function (maxHealth) {
var self = Container.call(this);
var healthBarGraphics = self.attachAsset('healthBar', {
anchorX: 0.5,
anchorY: 1
});
self.maxHealth = maxHealth;
self.maxWidth;
if (self.maxHealth == 3) {
//healthBarGraphics.width *= 0.3;
self.maxWidth = 50;
} else if (self.maxHealth == 6) {
//healthBarGraphics.width *= 0.6;
self.maxWidth = 100;
} else if (self.maxHealth == 30) {
self.maxWidth = 150;
} else if (self.maxHealth == 100) {
self.maxWidth = 200;
} else {
self.maxWidth = 300;
}
/*
self.setTint = function (tint) {
healthBarGraphics.tint = tint;
};*/
//self.setTint(0x00FF00);
self.updateHealth = function (health) {
//self.scale.set(health / 100, 1);
//self.scale.set(health / self.maxHealth * (self.maxWidth / 100), 1);
//self.scale.set(health / self.maxHealth * (self.maxWidth / 100), 1);
self.scale.set(health / 100 * (self.maxWidth / 100), 1);
};
});
var HealthBarTower = Container.expand(function () {
var self = Container.call(this);
var healthBarGraphics = self.attachAsset('healthBarTower', {
anchorX: 0.5,
anchorY: 1
});
/*
self.setTint = function (tint) {
healthBarGraphics.tint = tint;
};*/
//self.setTint(0x00FF00);
self.updateHealth = function (health) {
self.scale.set(health, 1);
};
});
var OrcEnemy = Container.expand(function () {
var self = Container.call(this);
console.log('Orc Spawned');
var enemyGraphics = self.attachAsset('orcEnemySprite', {
anchorX: 0.5,
anchorY: 0.5
});
enemyGraphics.scale.set(0.8);
var healthBar = new HealthBar(6);
healthBar.y = -enemyGraphics.height + 100;
self.addChild(healthBar);
self.healthBar = healthBar;
self.healthBar.updateHealth(100);
self.hitpoints = 6;
self.maxHitpoints = 6;
self.isDead = false;
self.zigzagTension = Math.floor(Math.random() * 20) + 10;
self._move_migrated = function () {
var minDist = Infinity;
var closestTower = null;
for (var i = 0; i < towers.length; i++) {
var dx = towers[i].x - self.x;
var dy = towers[i].y - self.y;
var dist = Math.sqrt(dx * dx + dy * dy);
if (dist < minDist) {
minDist = dist;
closestTower = towers[i];
}
}
if (closestTower && minDist < closestTower.width / 2 + self.width / 2) {
//closestTower.health -= 0.8;
closestTower.takeDamage(0.8);
if (closestTower.health <= 0) {
var towerIndex = towers.indexOf(closestTower);
if (towerIndex > -1) {
towers.splice(towerIndex, 1);
}
closestTower.destroy();
}
} else if (closestTower && minDist < 100) {
var avoidanceForce = 8;
var ax = self.x - closestTower.x;
var ay = self.y - closestTower.y;
var len = Math.sqrt(ax * ax + ay * ay);
ax = ax / len * avoidanceForce;
ay = ay / len * avoidanceForce;
self.x += ax;
self.y += ay;
} else {
self.zigzagCounter = self.zigzagCounter || 0;
self.zigzagDirection = self.zigzagDirection || 1;
if (self.zigzagCounter++ % self.zigzagTension === 0) {
self.zigzagDirection *= -1;
}
self.x += 4 * self.zigzagDirection;
self.y += 2;
if (Math.random() < 0.01) {
self.zigzagTension = Math.floor(Math.random() * 40) + 10;
}
if (self.x > 2048) {
self.zigzagDirection = -1;
}
if (self.x < 0) {
self.zigzagDirection = 1;
}
var scaleIncrement = (1 - 0.1) / 200;
self.scale.x += scaleIncrement;
self.scale.y += scaleIncrement;
self.scale.x = Math.min(self.scale.x, 1);
self.scale.y = Math.min(self.scale.y, 1);
if (self.zigzagCounter % 5 == 0) {
self.rotation = (0.5 - Math.random()) * (Math.PI * 2 / 100);
}
}
};
self.die = function () {
playerGold += 10;
playerScore += 150;
updateScoreLabel();
updateGoldLabel();
for (var i = 0; i < 8; i++) {
var t = new GoldCoin(self.x, self.y, 150, 150, i * 2);
game.addChild(t);
goldCoins.push(t);
}
self.isDead = true;
};
});
var Tower = Container.expand(function (towerTypeIndex) {
var self = Container.call(this);
self.upgradeLevel = upgradeLevel;
self.towerType = towerTypeIndex || 0;
self.towerData = towerTypes[self.towerType];
var towerGraphics = self.attachAsset('towerSprite', {
anchorX: 0.5,
anchorY: 0.5
});
var towerGraphics1 = self.attachAsset('towerSprite1', {
anchorX: 0.5,
anchorY: 0.5
});
var towerGraphics2 = self.attachAsset('towerSprite2', {
anchorX: 0.5,
anchorY: 0.5
});
var towerGraphics3 = self.attachAsset('towerSprite3', {
anchorX: 0.5,
anchorY: 0.5
});
var towerGraphics4 = self.attachAsset('towerSprite4', {
anchorX: 0.5,
anchorY: 0.5
});
var towerGraphics5 = self.attachAsset('towerSprite5', {
anchorX: 0.5,
anchorY: 0.5
});
var towerGraphics6 = self.attachAsset('towerSprite6', {
anchorX: 0.5,
anchorY: 0.5
});
var towerGraphics7 = self.attachAsset('towerSprite7', {
anchorX: 0.5,
anchorY: 0.5
});
var towerGraphics8 = self.attachAsset('towerSprite8', {
anchorX: 0.5,
anchorY: 0.5
});
towerGraphics.scale.set(2);
towerGraphics1.scale.set(2);
towerGraphics2.scale.set(2);
towerGraphics3.scale.set(2);
towerGraphics4.scale.set(2);
towerGraphics5.scale.set(2);
towerGraphics6.scale.set(2);
towerGraphics7.scale.set(2);
towerGraphics8.scale.set(2);
towerGraphics1.alpha = 0;
towerGraphics2.alpha = 0;
towerGraphics3.alpha = 0;
towerGraphics4.alpha = 0;
towerGraphics5.alpha = 0;
towerGraphics6.alpha = 0;
towerGraphics7.alpha = 0;
towerGraphics8.alpha = 0;
var a = [towerGraphics1, towerGraphics2, towerGraphics3, towerGraphics4, towerGraphics5, towerGraphics6, towerGraphics7, towerGraphics8];
// Show correct sprite based on tower type
towerGraphics.alpha = 0;
towerGraphics1.alpha = 0;
towerGraphics2.alpha = 0;
towerGraphics3.alpha = 0;
towerGraphics4.alpha = 0;
towerGraphics5.alpha = 0;
towerGraphics6.alpha = 0;
towerGraphics7.alpha = 0;
towerGraphics8.alpha = 0;
if (self.towerType === 0) {
towerGraphics1.alpha = 1;
} else if (self.towerType === 1) {
towerGraphics2.alpha = 1;
} else if (self.towerType === 2) {
towerGraphics3.alpha = 1;
} else if (self.towerType === 3) {
towerGraphics4.alpha = 1;
} else if (self.towerType === 4) {
towerGraphics.alpha = 1;
} else if (upgradeLevel > 0) {
for (var i = 0; i < 8; i++) {
if (i + 1 == upgradeLevel) {
a[i].alpha = 1;
} else {
a[i].alpha = 0;
}
}
} else {
towerGraphics.alpha = 1;
}
var healthBar = new HealthBarTower();
healthBar.y = towerGraphics.height;
self.addChild(healthBar);
self.healthBar = healthBar;
self.healthBar.updateHealth(1);
self.shoot = function (enemies) {
if (self.shootCounter++ % (self.towerData.fireRate || towerShotDelay[self.upgradeLevel]) === 0) {
for (var i = 0; i < enemies.length; i++) {
var enemy = enemies[i];
var dx = enemy.x - self.x;
var dy = enemy.y - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance <= (self.towerData.range || 300)) {
//console.log('shot');
// For towerSprite1 (towerType 0), use upgrade level 1 to show bulletSprite1
var bulletUpgradeLevel = self.towerType === 0 ? 1 : self.upgradeLevel;
var bullet = new Bullet(bulletUpgradeLevel);
bullet.damage = self.towerData.damage || towerDamage[self.upgradeLevel];
bullet.x = self.x;
bullet.y = self.y;
bullet.target = enemy;
var tx = bullet.target.x - bullet.x;
var ty = bullet.target.y - bullet.y;
var rad = Math.atan2(ty, tx);
bullet.rotation = rad + Math.PI / 2;
bullet.vx = Math.cos(rad);
bullet.vy = Math.sin(rad);
addBullet(bullet);
break;
}
}
}
};
self.upgrade = function () {};
self.takeDamage = function (dam) {
self.health -= dam;
self.healthBar.updateHealth(self.health / self.maxHealth);
};
self.shootCounter = 0;
self.health = 200;
self.maxHealth = 200;
});
var TreasureChest = Container.expand(function () {
var self = Container.call(this);
var chestGraphics = self.attachAsset('treasureChestSprite', {
anchorX: 0.5,
anchorY: 0.5
});
self.addChild(chestGraphics);
});
var TrollEnemy = Container.expand(function () {
var self = Container.call(this);
console.log('Troll Spawned');
var trollGraphics = self.attachAsset('trollSprite', {
anchorX: 0.5,
anchorY: 0.5
});
trollGraphics.scale.set(2.5);
var healthBar = new HealthBar(30);
healthBar.y = -trollGraphics.height - 40;
self.addChild(healthBar);
self.healthBar = healthBar;
self.healthBar.updateHealth(100);
self.hitpoints = 30;
self.maxHitpoints = 30;
self.isDead = false;
self._move_migrated = function () {
var minDist = Infinity;
var closestTower = null;
for (var i = 0; i < towers.length; i++) {
var dx = towers[i].x - self.x;
var dy = towers[i].y - self.y;
var dist = Math.sqrt(dx * dx + dy * dy);
if (dist < minDist) {
minDist = dist;
closestTower = towers[i];
}
}
if (closestTower && minDist < closestTower.width / 2 + self.width / 2) {
//closestTower.health -= 0.5;
closestTower.takeDamage(0.5);
if (closestTower.health <= 0) {
var towerIndex = towers.indexOf(closestTower);
if (towerIndex > -1) {
towers.splice(towerIndex, 1);
}
closestTower.destroy();
}
} else if (closestTower && minDist < 100) {
var avoidanceForce = 8;
var ax = self.x - closestTower.x;
var ay = self.y - closestTower.y;
var len = Math.sqrt(ax * ax + ay * ay);
ax = ax / len * avoidanceForce;
ay = ay / len * avoidanceForce;
self.x += ax;
self.y += ay;
} else {
self.zigzagCounter = self.zigzagCounter || 0;
self.zigzagDirection = self.zigzagDirection || 1;
if (self.zigzagCounter++ % self.zigzagTension === 0) {
self.zigzagDirection *= -1;
}
self.x += 4 * self.zigzagDirection;
self.y += 2;
if (Math.random() < 0.01) {
self.zigzagTension = Math.floor(Math.random() * 40) + 10;
}
if (self.x > 2048) {
self.zigzagDirection = -1;
}
if (self.x < 0) {
self.zigzagDirection = 1;
}
var scaleIncrement = (1 - 0.1) / 200;
self.scale.x += scaleIncrement;
self.scale.y += scaleIncrement;
self.scale.x = Math.min(self.scale.x, 1);
self.scale.y = Math.min(self.scale.y, 1);
if (self.zigzagCounter % 5 == 0) {
self.rotation = (0.5 - Math.random()) * (Math.PI * 2 / 100);
}
}
};
self.die = function () {
playerGold += 20;
playerScore += 300;
updateScoreLabel();
updateGoldLabel();
for (var i = 0; i < 20; i++) {
var t = new GoldCoin(self.x, self.y, 150, 150, i * 2);
game.addChild(t);
goldCoins.push(t);
}
self.isDead = true;
};
});
var UpgradeButton = Container.expand(function () {
var self = Container.call(this);
var upgradeButtonGraphics = self.attachAsset('buttonSprite', {
anchorX: 0.5,
anchorY: 0.5
});
self.addChild(upgradeButtonGraphics);
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000,
name: 'Monster Defense'
});
/****
* Game Code
****/
var playerGold = 30; // TODO: Reset to 30;
var playerScore = 0;
var enemySpawnDelay = 120;
var upgradeLevel = 0;
var towerDamage = [1, 1.5, 2, 2.5, 3, 3.5, 4, 5, 8];
var towerShotDelay = [50, 45, 45, 40, 35, 30, 25, 20, 15];
var balrogHitpoints = 500;
var towers = [];
var enemies = [];
var bullets = [];
var goldCoins = [];
var enemySpawnCounter = 0;
var totalEnemiesSpawned = 0;
var selectedTowerType = 0;
var towerTypes = [{
name: 'Basic Tower',
cost: 10,
sprite: 'towerSprite',
damage: 1,
range: 300,
fireRate: 50
}, {
name: 'Cannon Tower',
cost: 25,
sprite: 'towerSprite2',
damage: 3,
range: 250,
fireRate: 80
}, {
name: 'Magic Tower',
cost: 40,
sprite: 'towerSprite3',
damage: 2,
range: 400,
fireRate: 45
}, {
name: 'Ice Tower',
cost: 60,
sprite: 'towerSprite4',
damage: 1.5,
range: 350,
fireRate: 40
}, {
name: 'Tower Sprite',
cost: 15,
sprite: 'towerSprite',
damage: 1.2,
range: 320,
fireRate: 45
}];
var towerMenuButtons = [];
;
var lerp = function lerp(start, end, t) {
return start * (1 - t) + end * t;
};
var createQuadraticBezierArcPoints = function createQuadraticBezierArcPoints(p0x, p0y, p1x, p1y, p2x, p2y, numberOfSteps) {
var points_along_axis = new Array(numberOfSteps).fill(null).map(function () {
return [0, 0];
});
var stepping_constant = 1 / numberOfSteps;
for (var i = 0; i < numberOfSteps; i++) {
var i_p0_p1x = lerp(p0x, p1x, i * stepping_constant);
var i_p0_p1y = lerp(p0y, p1y, i * stepping_constant);
var i_p1_p2x = lerp(p1x, p2x, i * stepping_constant);
var i_p1_p2y = lerp(p1y, p2y, i * stepping_constant);
if (false) {
points_along_axis.push(lerp(i_p0_p1x, i_p1_p2x, i * stepping_constant), lerp(i_p0_p1y, i_p1_p2y, i * stepping_constant));
}
points_along_axis[i][0] = lerp(i_p0_p1x, i_p1_p2x, i * stepping_constant);
points_along_axis[i][1] = lerp(i_p0_p1y, i_p1_p2y, i * stepping_constant);
}
if (false) {
console.log('path: ' + points_along_axis);
console.log('path[2]: ' + points_along_axis[2]);
}
return points_along_axis.reverse();
};
var temp = createQuadraticBezierArcPoints(0, 0, 50, 50, 0, 50, 10);
var updateGoldLabel = function updateGoldLabel() {
goldLabel.setText('Gold: ' + playerGold);
updateTowerButtons();
};
var updateScoreLabel = function updateScoreLabel() {
scoreLabel.setText('Score: ' + playerScore);
};
var updateTowerButtons = function updateTowerButtons() {
for (var i = 0; i < towerMenuButtons.length; i++) {
var button = towerMenuButtons[i];
var towerCost = towerTypes[i].cost;
if (playerGold >= towerCost) {
button.alpha = 1.0;
button.interactive = true;
button.buttonMode = true;
} else {
button.alpha = 0.5;
button.interactive = true;
button.buttonMode = true;
}
// Maintain selection visual for currently selected tower
if (selectedTowerType === i) {
button.border.alpha = 0.8;
} else {
button.border.alpha = 0;
}
}
};
var addBullet = function addBullet(bullet) {
bullets.push(bullet);
game.addChild(bullet);
};
function sufficientDistanceToOtherTowers(position) {
console.log('sufficientDistanceToOtherTowers');
for (var i = 0; i < towers.length; i++) {
var tower = towers[i];
var dx = tower.x - position.x;
var dy = tower.y - position.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance < 120) {
return false;
}
}
return true;
}
;
var background = game.attachAsset('background', {});
background.width = 2048;
background.height = 2732;
background.y = 0;
game.addChildAt(background, 0);
var initialEnemy = new Enemy();
initialEnemy.x = 300 + Math.random() * (1848 - 300);
initialEnemy.y = 200;
initialEnemy.scale.set(0.1);
enemies.push(initialEnemy);
game.addChild(initialEnemy);
var cityWall = game.addChild(new CityWall());
cityWall.y = 2632;
cityWall.x = 332;
cityWall.scale.y = 0.5;
cityWall.scale.x = 0.5;
var cityWall2 = game.addChild(new CityWall());
cityWall2.y = 2632;
cityWall2.x = 1012;
cityWall2.scale.y = 0.5;
cityWall2.scale.x = 0.5;
var cityWall3 = game.addChild(new CityWall());
cityWall3.y = 2632;
cityWall3.x = 1691;
cityWall3.scale.y = 0.5;
cityWall3.scale.x = 0.5;
var bottomBlackBox = game.attachAsset('blackBox', {
anchorY: 1
});
bottomBlackBox.width = 2048;
bottomBlackBox.height = 400;
bottomBlackBox.y = 2732;
game.addChild(bottomBlackBox);
var goldLabel = new Text2('Gold: 30', {
size: 100,
fill: '#ffd700',
align: 'left',
dropShadow: true
});
goldLabel.x = 270;
goldLabel.y = 120;
game.addChild(goldLabel);
var scoreLabel = new Text2('Score: 0', {
size: 100,
fill: '#ccbbff',
align: 'left',
dropShadow: true
});
scoreLabel.x = 650;
scoreLabel.y = 120;
game.addChild(scoreLabel);
var instructionLabel = new Text2("Select tower type, then tap to build\nDon't let enemies reach the City Wall!", {
size: 58,
fill: '#eeeeee',
align: 'left',
dropShadow: true
});
instructionLabel.x = 920;
instructionLabel.y = 2632 - bottomBlackBox.height + (bottomBlackBox.height - instructionLabel.height) / 2;
game.addChild(instructionLabel);
// Create tower selection menu
for (var i = 0; i < towerTypes.length; i++) {
var towerButton = LK.getAsset(towerTypes[i].sprite, {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.5,
scaleY: 1.5
});
towerButton.x = 200 + i * 150;
towerButton.y = 2400;
towerButton.towerTypeIndex = i;
towerButton.interactive = true;
towerButton.buttonMode = true;
// Add border to show selection
var border = LK.getAsset('debug', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2,
scaleY: 2
});
border.alpha = 0;
border.x = towerButton.x;
border.y = towerButton.y;
towerButton.border = border;
game.addChild(border);
// Tower cost label
var costText = new Text2(towerTypes[i].cost + 'g', {
size: 40,
fill: '#ffd700',
align: 'center'
});
costText.anchor.set(0.5, 0);
costText.x = towerButton.x;
costText.y = towerButton.y + 70;
// Tower name label
var nameText = new Text2(towerTypes[i].name, {
size: 30,
fill: '#ffffff',
align: 'center'
});
nameText.anchor.set(0.5, 1);
nameText.x = towerButton.x;
nameText.y = towerButton.y - 70;
game.addChild(towerButton);
game.addChild(costText);
game.addChild(nameText);
towerMenuButtons.push(towerButton);
towerButton.on('down', function (x, y, obj) {
// Check if towerTypeIndex is valid and tower type exists
if (obj.towerTypeIndex !== undefined && towerTypes[obj.towerTypeIndex]) {
var towerCost = towerTypes[obj.towerTypeIndex].cost;
if (playerGold >= towerCost) {
// Clear previous selection
for (var j = 0; j < towerMenuButtons.length; j++) {
if (towerMenuButtons[j].border) {
towerMenuButtons[j].border.alpha = 0;
}
}
// Set new selection
selectedTowerType = obj.towerTypeIndex;
if (obj.border) {
obj.border.alpha = 0.8;
}
}
}
});
}
// Set initial selection and update button states
if (towerMenuButtons.length > 0 && playerGold >= towerTypes[0].cost) {
selectedTowerType = 0;
towerMenuButtons[0].border.alpha = 0.8;
}
updateTowerButtons();
var treasureChest = game.addChild(new TreasureChest());
treasureChest.scale.x = 1.3;
treasureChest.scale.y = 1.3;
treasureChest.x = 150;
treasureChest.y = 150;
// Main game loop and click handler below here.
LK.on('tick', function () {
//console.log('tick:' + LK.ticks);
enemySpawnCounter = enemySpawnCounter || 0;
totalEnemiesSpawned = totalEnemiesSpawned || 0;
if (++enemySpawnCounter >= enemySpawnDelay) {
var newEnemy;
if (totalEnemiesSpawned > 200 && totalEnemiesSpawned % 199 == 0) {
newEnemy = new BalrogEnemy();
} else if (totalEnemiesSpawned > 100 && totalEnemiesSpawned % 99 == 0) {
newEnemy = new DragonEnemy();
} else if (totalEnemiesSpawned > 3 && totalEnemiesSpawned % 50 == 0) {
newEnemy = new DeathKnightEnemy();
} else if (totalEnemiesSpawned > 3 && totalEnemiesSpawned % 10 == 0) {
newEnemy = new TrollEnemy();
} else {
if (Math.random() < 0.2 + upgradeLevel * 0.06) {
newEnemy = new OrcEnemy();
} else {
if (Math.random() < 0.5) {
newEnemy = new FlyingEnemy();
//newEnemy = new DragonEnemy();
} else {
newEnemy = new Enemy();
}
}
}
if (newEnemy) {
newEnemy.x = 300 + Math.random() * (1848 - 300);
newEnemy.y = 200;
newEnemy.scale.set(0.1);
enemies.push(newEnemy);
game.addChild(newEnemy);
}
totalEnemiesSpawned++;
if (totalEnemiesSpawned > 0 && totalEnemiesSpawned % 20 == 0) {
enemySpawnDelay -= 4;
if (enemySpawnDelay < 20) {
enemySpawnDelay = 20;
}
}
enemySpawnCounter = 0;
}
//console.log('enemies length:' + enemies.length);
for (var i = enemies.length - 1; i >= 0; i--) {
if (enemies[i].isDead) {
enemies[i].destroy();
enemies.splice(i, 1);
} else {
enemies[i]._move_migrated();
if (enemies[i].y >= 2332 - enemies[i].height / 2) {
/*
var finalScoreLabel = new Text2('*** Your Final Score: ' + playerScore + ' ***', {
size: 120,
fill: '#ffffff',
align: 'left',
dropShadow: true
});
finalScoreLabel.x = 1024 - finalScoreLabel.width / 2;
finalScoreLabel.y = 260;
game.addChild(finalScoreLabel);
'*/
LK.setScore(playerScore);
LK.showGameOver();
}
}
}
//console.log('towers length:' + towers.length);
for (var j = 0; j < towers.length; j++) {
towers[j].shoot(enemies);
}
//console.log('bullets length:' + bullets.length);
for (var k = bullets.length - 1; k >= 0; k--) {
if (bullets[k].isDead) {
bullets[k].destroy();
bullets.splice(k, 1);
} else {
bullets[k]._move_migrated();
}
}
//console.log('goldCoins length:' + goldCoins.length);
for (var l = goldCoins.length - 1; l >= 0; l--) {
if (goldCoins[l].isDead) {
goldCoins[l].destroy();
goldCoins.splice(l, 1);
} else {
goldCoins[l]._move_migrated();
}
}
if (LK.ticks % 10 == 0) {
sortDepths();
}
});
function sortDepths() {
var en = enemies.filter(function (el) {
return !el.flying;
});
var a = [].concat(towers, en);
a.sort(function (a, b) {
return a.y - b.y;
});
a.forEach(function (e, index) {
game.addChildAt(e, 6 + index);
//console.log('y and zIndex:' + e.y + ', ' + e.parent.getChildIndex(e));
});
}
;
game.on('down', function (x, y, obj) {
//console.log('game on down, position:' + obj.event.getLocalPosition(game).x + ',' + obj.event.getLocalPosition(game).y);
var position = game.toLocal(obj.global);
if (position.y >= 600 && position.y <= 2112) {
var selectedTower = towerTypes[selectedTowerType];
if (selectedTower && playerGold >= selectedTower.cost) {
if (sufficientDistanceToOtherTowers(position)) {
playerGold -= selectedTower.cost;
var newTower = game.addChild(new Tower(selectedTowerType));
newTower.x = position.x;
newTower.y = position.y;
towers.push(newTower);
sortDepths();
/*
towers.sort(function (a, b) {
return a.y - b.y;
});
towers.forEach(function (tower, index) {
game.addChildAt(tower, 6 + index);
console.log('y and zIndex:' + tower.y + ', ' + tower.parent.getChildIndex(tower));
});
*/
updateGoldLabel();
}
}
}
}); ===================================================================
--- original.js
+++ change.js
@@ -1048,9 +1048,9 @@
var selectedTowerType = 0;
var towerTypes = [{
name: 'Basic Tower',
cost: 10,
- sprite: 'towerSprite1',
+ sprite: 'towerSprite',
damage: 1,
range: 300,
fireRate: 50
}, {
@@ -1278,17 +1278,8 @@
selectedTowerType = obj.towerTypeIndex;
if (obj.border) {
obj.border.alpha = 0.8;
}
- // Start dragging tower
- var dragPosition = game.toLocal(obj.global);
- var dragTower = new Tower(obj.towerTypeIndex);
- dragTower.x = dragPosition.x;
- dragTower.y = dragPosition.y;
- dragTower.alpha = 0.7;
- dragTower.isDragging = true;
- game.addChild(dragTower);
- game.dragTower = dragTower;
}
}
});
}
@@ -1409,15 +1400,8 @@
//console.log('y and zIndex:' + e.y + ', ' + e.parent.getChildIndex(e));
});
}
;
-game.move = function (x, y, obj) {
- if (game.dragTower) {
- var position = game.toLocal(obj.global);
- game.dragTower.x = position.x;
- game.dragTower.y = position.y;
- }
-};
game.on('down', function (x, y, obj) {
//console.log('game on down, position:' + obj.event.getLocalPosition(game).x + ',' + obj.event.getLocalPosition(game).y);
var position = game.toLocal(obj.global);
if (position.y >= 600 && position.y <= 2112) {
@@ -1442,30 +1426,5 @@
updateGoldLabel();
}
}
}
-});
-game.up = function (x, y, obj) {
- if (game.dragTower) {
- var position = game.toLocal(obj.global);
- if (position.y >= 600 && position.y <= 2112) {
- var selectedTower = towerTypes[selectedTowerType];
- if (selectedTower && playerGold >= selectedTower.cost) {
- if (sufficientDistanceToOtherTowers(position)) {
- playerGold -= selectedTower.cost;
- game.dragTower.alpha = 1;
- game.dragTower.isDragging = false;
- towers.push(game.dragTower);
- sortDepths();
- updateGoldLabel();
- game.dragTower = null;
- return;
- }
- }
- }
- // Invalid placement - remove drag tower
- if (game.dragTower) {
- game.dragTower.destroy();
- game.dragTower = null;
- }
- }
-};
\ No newline at end of file
+});
\ No newline at end of file
brown wooden board. game gui style. 2048x400 pixels. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A medieval stone wall seen from the front. pixelart. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A treasure chest. Medieval style. cartoony. Open and full of gold coins. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A metalic square button with the symbol of a tower from chess. Pixelart. Gamegui style. Medieval. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A smooth round gold coin. Pixelart. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
An evil snotling flying on a dragonfly. front view. enemy character in a game. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Um monstrinho do tipo normal inspirado em Pokémon e Digimon estilo Defensor. In-Game asset. 2d. High contrast. No shadows
ESPADA DE MADEIRA Estilo pokémon e Digimon
ESPINHO SPRITE. In-Game asset. 2d. High contrast. No shadows
Remova o fundo da imagem
Poder de água estilo Mago inspirado em pokémon e Digimon. In-Game asset. 2d. High contrast. No shadows
Um monstrinho Raposa+Lobó Guará+Robinwood do tipo Fogo inspirado em Pokémon e Digimon estilo Arqueiro. In-Game asset. 2d. High contrast. No shadows
Fire Bullet inspired by Pokemon and Digimon
Acrescente o conceito Pirata e Cacto do deserto e estilo Ladino, Mantendo a inspiração em pokémon e Digimon, imagem sem fundo
Um monstrinho do tipo Terra inspirado em Pokémon e Digimon estilo invocador aparência inspirada em gambá, nordeste, Cabaça nas costas e faroeste. In-Game asset. 2d. High contrast. No shadows
Arma de Cabaça tipo terra com o estilo de arte pokémon e Digimon.. In-Game asset. 2d. High contrast. No shadows
Um monstrinho do tipo Gelo inspirado em Pokémon e Digimon com aparência de Coruja fantasma classe guerreiro com lanças de Gelo nas costas arte com contorno de preto
Ice Spear inspired by Pokemon and Digimon. In-Game asset. 2d. High contrast. No shadows
Tire esses raios em volta
Ataque de Mão fechada com luva preta Soco elétrico. Inspirado em jogos GBA
empty battlefield. meadow without trees. direct top down view. horizon in distance with dark florest.. concept Style inspired by Pokemon and Digimon but Unic
MONSTRINHO URSO PARDO COM GRANADAS NO ESTILO POKÉMON E DIGIMON. In-Game asset. 2d. High contrast. No shadows
Uma Granada, pointing up. top down view. pixelart. vertical. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Sprite de monstro voador inspirado em Vampiros, Hulk Golem e morcegos.
Faça uma versão dele de frente.
Abelha totalmente de aço do tipo aço com contorno preto bonita charmosa estilo Vingadores pokémon e Digimon.. In-Game asset. 2d. High contrast. No shadows