|
Last change
on this file was 28036, checked in by marder, 11 months ago |
|
rmgen: var -> let -> const
One should always use the variable declaration with the least possible scope.
This patch cleans up many (but not all) of the var in rmgen and replaces them with let or const.
The same is done for let -> const.
comments by: @sera @Stan
Differential revision: https://code.wildfiregames.com/D5214
|
-
Property svn:eol-style
set to
native
|
|
File size:
770 bytes
|
| Line | |
|---|
| 1 | /**
|
|---|
| 2 | * Paints the given texture-mapping to the given tiles.
|
|---|
| 3 | *
|
|---|
| 4 | * @param {string[]} textureIDs - Names of the terrain textures
|
|---|
| 5 | * @param {number[]} textureNames - One-dimensional array of indices of texturenames, one for each tile of the entire map.
|
|---|
| 6 | * @returns
|
|---|
| 7 | */
|
|---|
| 8 | function TerrainTextureArrayPainter(textureIDs, textureNames)
|
|---|
| 9 | {
|
|---|
| 10 | this.textureIDs = textureIDs;
|
|---|
| 11 | this.textureNames = textureNames;
|
|---|
| 12 | }
|
|---|
| 13 |
|
|---|
| 14 | TerrainTextureArrayPainter.prototype.paint = function(area)
|
|---|
| 15 | {
|
|---|
| 16 | const sourceSize = Math.sqrt(this.textureIDs.length);
|
|---|
| 17 | const scale = sourceSize / g_Map.getSize();
|
|---|
| 18 |
|
|---|
| 19 | for (const point of area.getPoints())
|
|---|
| 20 | {
|
|---|
| 21 | const sourcePos = Vector2D.mult(point, scale).floor();
|
|---|
| 22 | g_Map.setTexture(point, this.textureNames[this.textureIDs[sourcePos.x * sourceSize + sourcePos.y]]);
|
|---|
| 23 | }
|
|---|
| 24 | };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.