Merge pull request #21 from koneko/spritesheet
creeps load as spritesheets now
Before Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 9.7 KiB |
Before Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 9.7 KiB |
Before Width: | Height: | Size: 9.1 KiB |
Before Width: | Height: | Size: 9.3 KiB |
Before Width: | Height: | Size: 9.3 KiB |
Before Width: | Height: | Size: 9.3 KiB |
Before Width: | Height: | Size: 9.3 KiB |
Before Width: | Height: | Size: 9.3 KiB |
Before Width: | Height: | Size: 9.1 KiB |
Before Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 13 KiB |
BIN
public/assets/creeps/demon/spritesheet.png
Normal file
After Width: | Height: | Size: 94 KiB |
BIN
public/assets/creeps/hood/spritesheet.png
Normal file
After Width: | Height: | Size: 88 KiB |
Before Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 13 KiB |
@ -1,18 +1,20 @@
|
||||
|
||||
const fs = require('fs');
|
||||
const { exec, execSync } = require('child_process');
|
||||
let dir = fs.readdirSync('.');
|
||||
dir.forEach((item) => {
|
||||
const itemPath = `./${item}`;
|
||||
if (fs.lstatSync(itemPath).isDirectory()) {
|
||||
let subDir = fs.readdirSync(itemPath);
|
||||
subDir.forEach(async (subItem) => {
|
||||
const subItemPath = `${itemPath}/${subItem}`;
|
||||
if (fs.lstatSync(subItemPath).isFile() && subItem.endsWith('.png')) {
|
||||
const outputFilePath = `${itemPath}/${subItem.replace('.png', 's.png')}`;
|
||||
await execSync(`convert -resize 128x128 -quality 80 ${subItemPath} ${outputFilePath}`);
|
||||
fs.unlinkSync(subItemPath);
|
||||
fs.renameSync(outputFilePath, subItemPath);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
// dir.forEach((item) => {
|
||||
// const itemPath = `./${item}`;
|
||||
// if (fs.lstatSync(itemPath).isDirectory()) {
|
||||
// let subDir = fs.readdirSync(itemPath);
|
||||
// subDir.forEach(async (subItem) => {
|
||||
// const subItemPath = `${itemPath}/${subItem}`;
|
||||
// if (fs.lstatSync(subItemPath).isFile() && subItem.endsWith('.png')) {
|
||||
// const outputFilePath = `${itemPath}/${subItem.replace('.png', 's.png')}`;
|
||||
// await execSync(`convert -resize 128x128 -quality 80 ${subItemPath} ${outputFilePath}`);
|
||||
// fs.unlinkSync(subItemPath);
|
||||
// fs.renameSync(outputFilePath, subItemPath);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
// });
|
||||
// Disabled for now, dont need to optimize assets.
|
||||
|
BIN
public/assets/creeps/pumpkin/spritesheet.png
Normal file
After Width: | Height: | Size: 82 KiB |
Before Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 14 KiB |
BIN
public/assets/creeps/skeleton/spritesheet.png
Normal file
After Width: | Height: | Size: 92 KiB |
Before Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 14 KiB |
BIN
public/assets/creeps/wood/spritesheet.png
Normal file
After Width: | Height: | Size: 72 KiB |
BIN
public/assets/creeps/zombie/spritesheet.png
Normal file
After Width: | Height: | Size: 97 KiB |
@ -1,6 +1,7 @@
|
||||
[
|
||||
{
|
||||
"name": "basic",
|
||||
"sprite": "wood",
|
||||
"textures": [],
|
||||
"textureArrayLength": 12,
|
||||
"stats": {
|
||||
@ -18,6 +19,7 @@
|
||||
},
|
||||
{
|
||||
"name": "quick",
|
||||
"sprite": "zombie",
|
||||
"textures": [],
|
||||
"textureArrayLength": 8,
|
||||
"stats": {
|
||||
@ -35,6 +37,7 @@
|
||||
},
|
||||
{
|
||||
"name": "tank",
|
||||
"sprite": "skeleton",
|
||||
"textures": [],
|
||||
"textureArrayLength": 12,
|
||||
"stats": {
|
||||
@ -52,6 +55,7 @@
|
||||
},
|
||||
{
|
||||
"name": "cloaker",
|
||||
"sprite": "hood",
|
||||
"textures": [],
|
||||
"textureArrayLength": 12,
|
||||
"stats": {
|
||||
@ -69,6 +73,7 @@
|
||||
},
|
||||
{
|
||||
"name": "demon",
|
||||
"sprite": "demon",
|
||||
"textures": [],
|
||||
"textureArrayLength": 8,
|
||||
"stats": {
|
||||
@ -86,6 +91,7 @@
|
||||
},
|
||||
{
|
||||
"name": "maker",
|
||||
"sprite": "pumpkin",
|
||||
"textures": [],
|
||||
"textureArrayLength": 11,
|
||||
"stats": {
|
||||
|
@ -1,21 +1,21 @@
|
||||
[
|
||||
{
|
||||
"name": "Fire Gem",
|
||||
"description": "Forged from molten lava, the Fire Gem imbues your tower's attacks and adds 50% extra fire damage. It can be merged with any gem and is common.",
|
||||
"description": "Forged from molten lava, the Fire Gem imbues your tower's attacks and add extra fire damage. It can be merged with any gem and is common.",
|
||||
"color": "red",
|
||||
"type": "Fire",
|
||||
"totalLevels": 9,
|
||||
"textures": [],
|
||||
"cantCombineWith": [],
|
||||
"specialCombine": [],
|
||||
"initialGemValue": 100,
|
||||
"initialGemValue": 50,
|
||||
"genericImprovements": [
|
||||
{
|
||||
"damageUp": 2,
|
||||
"damageUp": 1,
|
||||
"attackSpeedUp": 0,
|
||||
"rangeUp": 0,
|
||||
"timeToLiveUp": 0,
|
||||
"pierceUp": 1,
|
||||
"pierceUp": 0,
|
||||
"gemValueUp": 50
|
||||
},
|
||||
{
|
||||
@ -548,7 +548,7 @@
|
||||
"textures": [],
|
||||
"cantCombineWith": [],
|
||||
"specialCombine": [],
|
||||
"initialGemValue": 200,
|
||||
"initialGemValue": 250,
|
||||
"genericImprovements": [
|
||||
{
|
||||
"damageUp": 0,
|
||||
|
@ -64,7 +64,7 @@
|
||||
"projectile": "blue",
|
||||
"projectileTextures": [],
|
||||
"projectileTexturesArrayLength": 4,
|
||||
"description": "",
|
||||
"description": "Doesn't shoot, instead buffs other towers with 50% of its power.",
|
||||
"stats": {
|
||||
"damage": 4,
|
||||
"cooldown": 1000,
|
||||
@ -83,7 +83,7 @@
|
||||
"projectile": "white",
|
||||
"projectileTextures": [],
|
||||
"projectileTexturesArrayLength": 5,
|
||||
"description": "",
|
||||
"description": "Like a regular tower, just slows down creeps.",
|
||||
"stats": {
|
||||
"damage": 2,
|
||||
"cooldown": 2000,
|
||||
@ -102,7 +102,7 @@
|
||||
"projectile": "red",
|
||||
"projectileTextures": [],
|
||||
"projectileTexturesArrayLength": 4,
|
||||
"description": "If you feel a little circular.",
|
||||
"description": "Shoots a quick, high pierce rail projectile at creeps.",
|
||||
"stats": {
|
||||
"damage": 2,
|
||||
"cooldown": 2000,
|
||||
@ -121,7 +121,7 @@
|
||||
"projectile": "stone",
|
||||
"projectileTextures": [],
|
||||
"projectileTexturesArrayLength": 1,
|
||||
"description": "If you feel a little circular.",
|
||||
"description": "Randomly places traps on the track, instead of attacking creeps.",
|
||||
"stats": {
|
||||
"damage": 2,
|
||||
"cooldown": 2000,
|
||||
@ -140,7 +140,7 @@
|
||||
"projectile": "red",
|
||||
"projectileTextures": [],
|
||||
"projectileTexturesArrayLength": 4,
|
||||
"description": "If you feel a little circular.",
|
||||
"description": "On top of a regular attack, this tower gives creeps a debuff, making them take more damage.",
|
||||
"stats": {
|
||||
"damage": 2,
|
||||
"cooldown": 2000,
|
||||
|
@ -165,8 +165,27 @@ export default class GameAssets {
|
||||
for (let idx = 0; idx < this.Creeps.length; idx++) {
|
||||
const creep = this.Creeps[idx];
|
||||
for (let i = 0; i < creep.textureArrayLength; i++) {
|
||||
const texture = await this.Load(`./assets/creeps/${creep.name}/${i}.png`);
|
||||
creep.textures[i] = texture;
|
||||
const texture = await this.Load(`./assets/creeps/${creep.sprite}/spritesheet.png`);
|
||||
const spritesheet = new PIXI.Spritesheet(texture, {
|
||||
frames: {
|
||||
[`${creep.sprite}_${i}.png`]: {
|
||||
frame: { x: i * 128, y: 0, w: 128, h: 128 },
|
||||
rotated: false,
|
||||
trimmed: false,
|
||||
spriteSourceSize: { x: 0, y: 0, w: 128, h: 128 },
|
||||
sourceSize: { w: 128, h: 128 },
|
||||
},
|
||||
},
|
||||
meta: {
|
||||
image: `./assets/creeps/${creep.sprite}/spritesheet.png`,
|
||||
format: 'RGBA8888',
|
||||
size: { w: 128 * creep.textureArrayLength, h: 128 },
|
||||
scale: '1',
|
||||
},
|
||||
});
|
||||
await spritesheet.parse();
|
||||
creep.textures[i] = spritesheet.textures[`${creep.sprite}_${i}.png`];
|
||||
// creep.textures[i] = texture;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -31,6 +31,7 @@ export type WaveDefinition = {
|
||||
|
||||
export type CreepDefinition = {
|
||||
name: string;
|
||||
sprite: string;
|
||||
textures: PIXI.Texture[];
|
||||
textureArrayLength: number;
|
||||
stats: CreepStatsDefinition;
|
||||
|
@ -116,13 +116,12 @@ export class GameScene extends Scene {
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (this.isGameOver) return Engine.NotificationManager.Notify('No more waves.', 'danger');
|
||||
if (this.roundMode == RoundMode.Misc) return;
|
||||
this.setRoundMode(RoundMode.Combat);
|
||||
this.changeRoundButton.buttonIcon.texture = GameAssets.FastForwardIconTexture;
|
||||
this.events.emit(WaveManagerEvents.NewWave, `${this.currentRound + 1}`);
|
||||
};
|
||||
this.MissionStats = new MissionStats(125, 450);
|
||||
this.MissionStats = new MissionStats(100, 250);
|
||||
this.events.on(GemEvents.TowerPanelSelectGem, (gem, index, tower) => {
|
||||
if (gem == null) {
|
||||
if (!this.MissionStats.checkIfPlayerHasAnyGems())
|
||||
|