User prompt
accuracy upgrades should increase accuracy by 4 instead of 2
User prompt
start the tanks accuracy at 80%
User prompt
there's a duplicate mention of the tanks accuracy, delete the duplicate mentions
User prompt
both tanks needs to start with their accuracy at 80%
User prompt
hp upgrades should increase health by 20 instead of 10
User prompt
health upgrades should only increase hp by 10 instead of 20
User prompt
change the text that says HP to say Health instead
User prompt
the sound that should play when upgrading the HP no longer plays. fix this
User prompt
change the stat terminology from HP to Health
User prompt
when the button that upgrades the maximum damage is pressed, play the Upg_Dmg_Max sound
User prompt
when the button that upgrades the minimum damage is pressed, play the Upg_Dmg_Min sound
User prompt
when the button that upgrades the Accuracy is pressed, play the Upg_Acc sound
User prompt
when the button that upgrades the HP is pressed, play the Upg_HP sound
User prompt
there's a bug with the round text, as it increases by 2 instead of just 1
Code edit (4 edits merged)
Please save this source code
User prompt
the text for the round has duplicate mentions, remove this redundant part of the code "var roundText = new Text2('Round: ' + gameState.currentRound.toString(), { size: 100, fill: "#ffffff", stroke: "#000000", strokeThickness: 15, anchorX: 0.5, anchorY: 0.5, align: "center", x: 2048 / 2 - 200, y: 2732 / 2 });"
User prompt
center the text for the roudn tio the center of the screen
User prompt
there's duplicate information for the score text "var roundText = new Text2('Round: ' + gameState.currentRound.toString(), { size: 100, fill: "#ffffff", stroke: "#000000", strokeThickness: 15, anchorX: 0.5, anchorY: 0.5, align: "center", x: 2048 / 2 - 200, y: 2732 / 2 }); foregroundContainer.addChild(roundText); roundText.x = 2048 / 2 - 200; roundText.y = 2732 / 2; var statTextProperties = { size: 60, fill: "#ffffff", stroke: "#000000", strokeThickness: 10, width: 400, align: "center" };" remove the duplicates
Code edit (1 edits merged)
Please save this source code
User prompt
move the text showing the round 100 pixels to the left
===================================================================
--- original.js
+++ change.js
@@ -82,10 +82,10 @@
// Tank class
var Tank = Container.expand(function (isEnemy) {
var self = Container.call(this);
this.isEnemy = isEnemy || false;
- self.baseHealth = 100; // Base health points of the tank
- self.Health = self.baseHealth; // Current health points of the tank
+ self.baseHP = 100; // Base health points of the tank
+ self.HP = self.baseHP; // Current health points of the tank
self.Accuracy = 0.90; // Accuracy of the tank's shots
self.minDmg = 10; // Minimum damage the tank can inflict
self.maxDmg = 20; // Maximum damage the tank can inflict
self.isEnemy = self.isEnemy ? true : false;
@@ -125,21 +125,21 @@
width: statTextProperties.width,
align: statTextProperties.align
}));
}
- self.healthText = createHUDTextElement();
+ self.hpText = createHUDTextElement();
self.accuracyText = createHUDTextElement();
self.minDmgText = createHUDTextElement();
self.maxDmgText = createHUDTextElement();
// Set initial positions
- self.healthText.y = 0;
+ self.hpText.y = 0;
self.accuracyText.y = 130;
self.minDmgText.y = 260;
self.maxDmgText.y = 390;
// Consolidated method to update HUD with tank stats
self.updateHUD = function () {
// Update all stats in a single method to streamline HUD updates
- self.healthText.setText("Health: ".concat(self.tank.Health));
+ self.hpText.setText("Health: ".concat(self.tank.HP));
self.accuracyText.setText("Accuracy: ".concat(Math.round(self.tank.Accuracy * 100), "%"));
self.minDmgText.setText("Min Dmg: ".concat(self.tank.minDmg));
self.maxDmgText.setText("Max Dmg: ".concat(self.tank.maxDmg));
};
@@ -230,9 +230,9 @@
align: "center"
};
// Define a single source of truth for stat upgrades
var statUpgrades = {
- 'Health': 20,
+ 'HP': 20,
// Match player's tank upgrade value
'Accuracy': 0.02,
// Match player's tank upgrade value
'MinDmg': 5,
@@ -242,11 +242,11 @@
function applyStatUpgrade(selectedUpgrade, tank) {
if (statUpgrades.hasOwnProperty(selectedUpgrade)) {
var upgradeValue = statUpgrades[selectedUpgrade];
switch (selectedUpgrade) {
- case 'Health':
- tank.baseHealth += upgradeValue;
- tank.Health += upgradeValue; // Increase current Health by upgradeValue instead of setting it to new baseHealth
+ case 'HP':
+ tank.baseHP += upgradeValue;
+ tank.HP += upgradeValue; // Increase current HP by upgradeValue instead of setting it to new baseHP
break;
case 'Accuracy':
tank.Accuracy = Math.min(1.0, tank.Accuracy + upgradeValue);
break;
@@ -350,9 +350,9 @@
// Conditions to filter out maximized stats
if (upgrade === 'Accuracy' && gameState.enemyTank.Accuracy >= 1.0) {
return false;
}
- if (upgrade === 'Health' && gameState.enemyTank.Health >= gameState.enemyTank.baseHealth) {
+ if (upgrade === 'HP' && gameState.enemyTank.HP >= gameState.enemyTank.baseHP) {
return false;
}
if (upgrade === 'MinDmg' && (gameState.enemyTank.minDmg >= gameState.enemyTank.maxDmg - 5 || gameState.enemyTank.minDmg === gameState.enemyTank.maxDmg)) {
return false;
@@ -378,10 +378,10 @@
bullet.destroy();
});
bullets = [];
// Reset both tanks' HP to their baseHP at the beginning of a new round
- gameState.playerTank.Health = gameState.playerTank.baseHealth;
- gameState.enemyTank.Health = gameState.enemyTank.baseHealth;
+ gameState.playerTank.HP = gameState.playerTank.baseHP;
+ gameState.enemyTank.HP = gameState.enemyTank.baseHP;
// Update both player and enemy HUDs to reflect the reset state
playerTankHUD.updateHUD();
enemyTankHUD.updateHUD();
}
@@ -389,9 +389,9 @@
function calculateDamage(shooter, target) {
var hit = Math.random() < shooter.Accuracy;
if (hit) {
var damage = Math.floor(Math.random() * (shooter.maxDmg - shooter.minDmg + 1)) + shooter.minDmg;
- target.Health = Math.max(0, target.Health - damage);
+ target.HP = Math.max(0, target.HP - damage);
// Initiate shake effect
var originalX = target.x;
var originalY = target.y;
var shakeDuration = 200; // Duration in milliseconds
@@ -514,9 +514,9 @@
manageShootingInterval('stop'); // Use the dedicated function to stop shooting
}
// Start a new shooting interval
shootingInterval = LK.setInterval(function () {
- if (gameState.isAnimating || gameState.playerTank.Health <= 0 || gameState.enemyTank.Health <= 0) {
+ if (gameState.isAnimating || gameState.playerTank.HP <= 0 || gameState.enemyTank.HP <= 0) {
return; // Prevent firing if any condition is met.
}
if (gameState.currentRound === 1 || gameState.playerTurn) {
triggerPlayerShoot();
@@ -535,9 +535,9 @@
manageShootingInterval('start');
// Move bullets
LK.on('tick', function () {
// Implement a pre-check at the beginning of this function to halt actions if a tank's HP is 0.
- if (gameState.playerTank.Health <= 0 || gameState.enemyTank.Health <= 0) {
+ if (gameState.playerTank.HP <= 0 || gameState.enemyTank.HP <= 0) {
// Consider implementing logic here to pause the game and trigger any end-of-round or game over logic.
gameState.isAnimating = false; // Halt animations.
return; // Exit the tick function early.
}
@@ -552,14 +552,14 @@
if (calculateDamage(enemyTank, playerTank)) {
// Ensure enemyTank is the shooter and playerTank is the target
playerTankHUD.updateHUD(); // Update player tank HUD stats
// Check if either tank's HP reaches 0 to pause game and show upgrades
- if (playerTank.Health === 0) {
+ if (playerTank.HP === 0) {
gameState.isPaused = true; // Stop all actions immediately
LK.clearInterval(shootingInterval); // Stop shooting immediately
game.off('down'); // Disable movement immediately
LK.showGameOver(); // End game if player tank HP drops to 0
- } else if (enemyTank.Health === 0) {
+ } else if (enemyTank.HP === 0) {
// Delay pausing the game until after the bullet is destroyed
bullets[i].destroy(); // Remove bullet from game
bullets.splice(i, 1); // Remove bullet from bullets array
gameState.isPaused = true; // Stop all actions immediately
@@ -578,9 +578,9 @@
} else if (bullets[i].intersects(enemyTank) && bullets[i] instanceof Projectile) {
// Invoke calculateDamage for player bullet hitting enemy tank
if (calculateDamage(gameState.playerTank, enemyTank)) {
enemyTankHUD.updateHUD(); // Refresh enemy tank HUD stats
- if (enemyTank.Health === 0) {
+ if (enemyTank.HP === 0) {
LK.getSound('Upgrade_Screen').play(); // Play Upgrade_Screen sound when enemy tank reaches 0 HP
// Set game state to paused
gameState.isPaused = true;
// Clear shooting interval to pause shooting
@@ -633,10 +633,9 @@
id: 'Upgrade_' + upgrade
});
upgradeBtn.on('down', function () {
LK.getSound('Upgrade_Btn').play(); // Play Upgrade_Btn sound when any upgrade button is pressed
- if (upgrade === 'Health') {
- LK.getSound('Upg_HP').play(); // Play Upg_HP sound when Health upgrade button is pressed
+ if (upgrade === 'HP') {
LK.getSound('Upg_HP').play(); // Play Upg_HP sound when HP upgrade button is pressed
} else if (upgrade === 'Accuracy') {
LK.getSound('Upg_Acc').play(); // Play Upg_Acc sound when Accuracy upgrade button is pressed
} else if (upgrade === 'MinDmg') {
blue upgrade button with a "+" sign on it. pixelated. 8 bit. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
dragon shaped firing turret. top-down bird-eye perspective seen directly from above. 8-bit pixelated. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
dragon shaped firing turret. top-down bird-eye perspective seen directly from above. 8-bit pixelated. blue soft-palette colored. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
chunky frost magical projectile. 8-bit pixelated. blue soft-palette colored. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
top-down bird-eye view perspective off a magical land, divided into two distinct elements of magma and ice. 8-bit pixelated. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
isometric stone wall platform. top-down bird-eye view perspective. 8-bit pixelated. grey soft-color palette.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.