User prompt
Increase how long the enemy is red for when hit
User prompt
Use the asset reference rather than the child index when tinting
User prompt
Instead of using a timer to remove the red tint. The tint should fade out
User prompt
The code that makes enemies flash red when hit should be moved to a support method on enemy class
User prompt
When hit by a bullet enemies should flash red. Use tint to make the enemy flash
User prompt
Move the particle exploration code to a separate function. Then also call that when bullets hit enemies
User prompt
Make bullets hit enemies
User prompt
Move up the graphics asset of particles by 150px
User prompt
Remove the particles var inside tick
User prompt
Define particles array in the root of game
User prompt
Keep track and tick particles
User prompt
Add movement to the particles
User prompt
Return true from bullet move method if the bullet should be destroyed. Then move the destruction and particle creation inside the game class
User prompt
When a hero bullet it destroyed it should spawn a series of random particles like a small explosion
User prompt
Bullets should be considered off screen with the same bounds as the hero movement
User prompt
Clean up bullets that goes off screen
User prompt
Start hero bullets with more soeed
User prompt
Start hero bullets with more velocity and slow down the acceleration
User prompt
Make hero bullets accelerate
User prompt
Increase the left and right margin from 100 to 150
User prompt
In down, set the pos min X to 100 and max X to width minus 100
User prompt
Set the max y to height minus 150
User prompt
Set the max y to height - 200
User prompt
set the min y to 700 and set the max y to height - 400
User prompt
Set the min y to 650
var ExplosionParticle = Container.expand(function () { var self = Container.call(this); var particleGraphics = XS.getAsset('particle', 'Explosion particle', .5, .5); particleGraphics.y -= 150; self.addChild(particleGraphics); self.move = function () { self.x += self.dx; self.y += self.dy; self.alpha -= 0.02; self.dx *= 0.98; self.dy *= 0.98; if (self.alpha <= 0) { self.destroy(); } }; }); var HealthBar = Container.expand(function () { var self = Container.call(this); var healthBarGraphics = XS.getAsset('healthBar', 'Health Bar', .5, 1); healthBarGraphics.tint = 0x00FF00; self.addChild(healthBarGraphics); self.updateHealth = function (health) { self.scale.x = health / 100; }; }); var TargetIndicator = Container.expand(function () { var self = Container.call(this); var targetGraphics = XS.getAsset('target', 'Target Indicator', .5, .5); targetGraphics.alpha = 0.5; targetGraphics.y -= 30; self.addChild(targetGraphics); }); var Player = Container.expand(function () { var self = Container.call(this); self.health = 100; self.findNearestEnemy = function (enemies) { var nearestEnemy = null; var nearestDistance = Infinity; for (var i = 0; i < enemies.length; i++) { var dx = enemies[i].x - self.x; var dy = enemies[i].y - self.y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance < nearestDistance) { nearestDistance = distance; nearestEnemy = enemies[i]; } } return nearestEnemy; }; var playerGraphics = XS.getAsset('player', 'Player character', .5, 1); self.addChild(playerGraphics); var healthBar = new HealthBar(); healthBar.y = -playerGraphics.height; self.addChild(healthBar); self.healthBar = healthBar; self.targetX = 2048 / 2; self.targetY = 2732 / 2; self.speed = 5; self.lastShot = 0; self.move = function () { var dx = self.targetX - self.x; var dy = self.targetY - self.y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance > self.speed) { self.x += dx / distance * self.speed; self.y += dy / distance * self.speed; self.healthBar.updateHealth(self.health); return true; } self.healthBar.updateHealth(self.health); return false; }; self.setTarget = function (x, y) { self.targetX = x; self.targetY = y; }; self.shoot = function (enemies) { var bullet = new Bullet(); bullet.x = self.x; bullet.y = self.y; var nearestEnemy = self.findNearestEnemy(enemies); if (nearestEnemy) { var dx = nearestEnemy.x - self.x; var dy = nearestEnemy.y - self.y; var distance = Math.sqrt(dx * dx + dy * dy); bullet.dx = dx / distance; bullet.dy = dy / distance; } return bullet; }; }); var Enemy = Container.expand(function () { var self = Container.call(this); self.fadeRedTint = function () { if (self.fadeOutRedTint) { var currentTint = enemyGraphics.tint; var newTint = currentTint - 0x005000; if (newTint < 0xFFFFFF) { newTint = 0xFFFFFF; self.fadeOutRedTint = false; } enemyGraphics.tint = newTint; } }; self.health = 100; var enemyGraphics = XS.getAsset('enemy', 'Enemy character', .5, 1); self.addChild(enemyGraphics); var healthBar = new HealthBar(); healthBar.y = -enemyGraphics.height; self.addChild(healthBar); self.healthBar = healthBar; self.healthBar.updateHealth(self.health); self.move = function () { self.fadeRedTint(); }; self.flashRed = function () { self.children[0].tint = 0xFF0000; self.fadeOutRedTint = true; }; }); var Bullet = Container.expand(function () { var self = Container.call(this); var bulletGraphics = XS.getAsset('bullet', 'Bullet', .5, .5); bulletGraphics.y -= 150; bulletGraphics.blendMode = 1; self.addChild(bulletGraphics); self.move = function () { self.dx *= 1.02; self.dy *= 1.02; self.x += self.dx * 4; self.y += self.dy * 4; if (self.x < 150 || self.x > 2048 - 150 || self.y < 700 || self.y > 2732 - 150) { return true; } return false; }; }); var Game = Container.expand(function () { var self = Container.call(this); self.createExplosion = function (x, y) { for (var j = 0; j < 10; j++) { var particle = new ExplosionParticle(); particle.x = x; particle.y = y; particle.dx = (Math.random() - 0.5) * 10; particle.dy = (Math.random() - 0.5) * 10; self.addChild(particle); particles.push(particle); } }; var particles = []; self.sortGameObjects = function () { self.children.sort(function (a, b) { if (a === background || b === background) return 0; if (a === targetIndicator) return -1; if (b === targetIndicator) return 1; return a.y - b.y; }); }; var background = XS.getAsset('background', 'Background', .5, .5); background.x = 2048 / 2; background.y = 2732 / 2; self.addChild(background); var targetIndicator = new TargetIndicator(); targetIndicator.x = 2048 / 2; targetIndicator.y = 2732 / 2; self.addChild(targetIndicator); var player = self.addChild(new Player()); player.x = 2048 / 2; player.y = 2732 / 2; var enemies = []; for (var i = 0; i < 5; i++) { var enemy = self.addChild(new Enemy()); enemy.x = Math.random() * (2048 - 500) + 300; enemy.y = Math.random() * (2732 - 500) + 300; enemies.push(enemy); } var bullets = []; XS.on('tick', function () { player.move(0, 0); var dx = player.targetX - player.x; var dy = player.targetY - player.y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance < player.speed && XS.ticks - player.lastShot >= 60) { player.lastShot = XS.ticks; var bullet = player.shoot(enemies); bullets.push(bullet); self.addChild(bullet); } if (distance < player.speed) { targetIndicator.visible = false; } for (var i = 0; i < enemies.length; i++) { enemies[i].move(); } for (var i = bullets.length - 1; i >= 0; i--) { if (bullets[i].move()) { self.createExplosion(bullets[i].x, bullets[i].y); bullets[i].destroy(); bullets.splice(i, 1); } else { bullets[i].move(); for (var j = 0; j < enemies.length; j++) { if (bullets[i].intersects(enemies[j])) { enemies[j].health -= 10; enemies[j].healthBar.updateHealth(enemies[j].health); enemies[j].flashRed(); if (enemies[j].health <= 0) { enemies[j].destroy(); enemies.splice(j, 1); } self.createExplosion(bullets[i].x, bullets[i].y); bullets[i].destroy(); bullets.splice(i, 1); break; } } } } for (var i = particles.length - 1; i >= 0; i--) { if (particles[i].alpha <= 0) { particles[i].destroy(); particles.splice(i, 1); } else { particles[i].move(); } } self.sortGameObjects(); }); stage.on('down', function (obj) { var pos = obj.event.getLocalPosition(self); pos.x = Math.max(Math.min(pos.x, 2048 - 150), 150); pos.y = Math.max(Math.min(pos.y, 2732 - 150), 700); player.setTarget(pos.x, pos.y); targetIndicator.x = pos.x; targetIndicator.y = pos.y; targetIndicator.visible = true; }); });
===================================================================
--- original.js
+++ change.js
@@ -93,9 +93,9 @@
var self = Container.call(this);
self.fadeRedTint = function () {
if (self.fadeOutRedTint) {
var currentTint = enemyGraphics.tint;
- var newTint = currentTint - 0x010000;
+ var newTint = currentTint - 0x005000;
if (newTint < 0xFFFFFF) {
newTint = 0xFFFFFF;
self.fadeOutRedTint = false;
}
giant wall Pixel art, 16 bit, isometric, SNES, top-down, no background, white background, low resolution, symmetrical
Single Short round Isometric dungeon column, simple, few stones, single column, no floor, dark room, Single Game Texture. In-Game asset. 2d. Pixelart. White background. Blank background. Low detail. High contrast.
Multi color chaotic noise, primary colors Single Game Texture. In-Game asset. 2d. Pixelart. White background. Blank background. Low detail. High contrast.
Round purple magic fireball. White core Single Game Texture. In-Game asset. 2d. Pixelart. White background. Blank background. Low detail. High contrast.
enemy goblin , Pixel art, 16 bit, isometric, SNES, top-down, no background, white background, low resolution, symmetrical, seen from front. No staff.
Single fire particle Single Game Texture. In-Game asset. 2d. Pixelart. White background. Blank background. Low detail. High contrast.
https://i.imgur.com/R3ZLguO.jpg Dungeon, Empty open floor, dark, fullscreen, Single Game Texture. In-Game asset. 2d. Pixelart. White background. Blank background. high detail. High contrast. --ar 2:3
single wizard, hooded Pixel art, 16 bit, isometric, SNES, top-down, no background, white background, low resolution, symmetrical, seen from front.
round bomb. fuse on fire Single Game Texture. In-Game asset. 2d. Pixelart. White background. Blank background. Low detail. High contrast.
Multi color chaotic noise, primary colors. Rays from the center. Darker center Single Game Texture. In-Game asset. 2d. Pixelart. Low detail. High contrast.