-
Notifications
You must be signed in to change notification settings - Fork 386
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
buff field nerf poison remove message limit per day meloetta icon remove bad words persistent dps meter better dps meter set life 0 death animation death animation add more alternative tileset fix night slash fix monster alolan marowak quadruple type king shield buff scyther bug flying fix description human && monster rework water rework ground rework charmander fire dragon kyurem ice dragon each map hat its own music remove double cdn load music new sound system nerf gastly rework of ghost synergy remove effect number remove old tilemaps multiplier x3 >25, x5 >30, x8 >35 new map integration add arena into map fix poison maze add simplex noise feature add terrain generation working random version test tileset tileset mapping add all tilesets add metadata for 50 tilesets
- Loading branch information
1 parent
6af9ae5
commit bcc8266
Showing
261 changed files
with
2,151 additions
and
1,822 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
const {TERRAIN} = require('../models/enum'); | ||
const Mask = require('./mask'); | ||
const Terrain = require('./terrain'); | ||
const Tileset = require('./tileset'); | ||
|
||
class Design { | ||
constructor(id, frequency, persistance) { | ||
this.id = id; | ||
this.terrain = []; | ||
this.bitmask = []; | ||
this.tilemap = []; | ||
this.width = 85; | ||
this.height = 43; | ||
this.frequency = frequency; | ||
this.persistance = persistance; | ||
this.tileset = new Tileset(this.id); | ||
this.minArena = [26, 4]; | ||
this.maxArena = [58, 35]; | ||
this.leftBorder = [27, 31]; | ||
this.rightBorder = [57, 31]; | ||
this.create(); | ||
} | ||
|
||
create() { | ||
this.generateTerrain(); | ||
this.generateMask(); | ||
this.generateTilemap(); | ||
} | ||
|
||
generateTerrain() { | ||
const t = new Terrain(this.width, this.height, this.frequency, this.persistance); | ||
const generation = t.terrain; | ||
|
||
for (let i = 0; i < this.height; i++) { | ||
const row = []; | ||
for (let j = 0; j < this.width; j++) { | ||
const v = generation[i][j]; | ||
if (v > 0.66) { | ||
row.push(TERRAIN.WALL); | ||
} else if (v>0.33) { | ||
row.push(TERRAIN.GROUND); | ||
} else { | ||
row.push(TERRAIN.WATER); | ||
} | ||
} | ||
this.terrain.push(row); | ||
} | ||
|
||
for (let i = this.minArena[0]; i < this.maxArena[0]; i++) { | ||
for (let j = this.minArena[1]; j < this.maxArena[1]; j++) { | ||
this.terrain[j][i] = TERRAIN.GROUND; | ||
} | ||
} | ||
|
||
for (let i = this.leftBorder[0]; i < this.rightBorder[0]; i++) { | ||
this.terrain[this.leftBorder[1]][i] = TERRAIN.WALL; | ||
} | ||
} | ||
|
||
generateMask() { | ||
const mask = new Mask(); | ||
for (let i = 0; i < this.height; i++) { | ||
const row = []; | ||
for (let j = 0; j < this.width; j++) { | ||
row.push(mask.mask8bits(this.terrain, i, j)); | ||
} | ||
this.bitmask.push(row); | ||
} | ||
} | ||
|
||
generateTilemap() { | ||
for (let i = 0; i < this.height; i++) { | ||
for (let j = 0; j < this.width; j++) { | ||
const tileID = this.tileset.getTilemapId(this.terrain[i][j], this.bitmask[i][j]); | ||
// console.log(tileID, ','); | ||
this.tilemap.push(tileID); | ||
} | ||
} | ||
} | ||
|
||
exportToTiled() { | ||
return { | ||
compressionlevel: -1, | ||
height: this.height, | ||
infinite: false, | ||
layers: [ | ||
{ | ||
data: this.tilemap, | ||
height: this.height, | ||
id: 1, | ||
name: 'World', | ||
opacity: 1, | ||
type: 'tilelayer', | ||
visible: true, | ||
width: this.width, | ||
x: 0, | ||
y: 0 | ||
}], | ||
nextlayerid: 6, | ||
nextobjectid: 1, | ||
orientation: 'orthogonal', | ||
renderorder: 'right-down', | ||
tiledversion: '1.7.2', | ||
tileheight: 24, | ||
tilesets: [this.tileset.exportToTiled()], | ||
tilewidth: 24, | ||
type: 'map', | ||
version: '1.6', | ||
width: this.width | ||
}; | ||
} | ||
}; | ||
|
||
module.exports = Design; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
const {ID_TABLE} = require('../models/enum'); | ||
|
||
class Mask { | ||
mask8bits(matrix, row, col) { | ||
let m = 0; const v = matrix[row][col]; | ||
m |= this.eq(matrix, row - 1, col, v) << 0; | ||
m |= this.eq(matrix, row, col + 1, v) << 1; | ||
m |= this.eq(matrix, row + 1, col, v) << 2; | ||
m |= this.eq(matrix, row, col - 1, v) << 3; | ||
m |= (m & 0b0011) == 0b0011 ? this.eq(matrix, row - 1, col + 1, v) << 4 : 0; | ||
m |= (m & 0b0110) == 0b0110 ? this.eq(matrix, row + 1, col + 1, v) << 5 : 0; | ||
m |= (m & 0b1100) == 0b1100 ? this.eq(matrix, row + 1, col - 1, v) << 6 : 0; | ||
m |= (m & 0b1001) == 0b1001 ? this.eq(matrix, row - 1, col - 1, v) << 7 : 0; | ||
return ID_TABLE[m]; | ||
} | ||
|
||
eq(m, r, c, v) { | ||
return (r >= 0 && r < m.length && c >= 0 && c < m[r].length && m[r][c] == v) ? 1 : 0; | ||
} | ||
} | ||
|
||
module.exports = Mask; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.