Skip to content

Commit

Permalink
Showing 4 changed files with 19 additions and 17 deletions.
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ A dungeon-drawing module for Foundry VTT.
* Remove doors - Remove all doors within an area.
* Undo - Undoes last change.
* Redo - Redoes next change.
* Config - Change various scene-specific drawing values: floor and wall color, wall width, etc.
* Config - Change various scene-specific drawing values: floor and wall color, wall width, optional floor texture, etc.
* Delete all - Nuke everything on the current dungeon/scene.


@@ -28,6 +28,17 @@ A dungeon-drawing module for Foundry VTT.
* To delete: delete the Note and/or the JournalEntry.


### Using floor textures

If you choose a floor texture it will be used in preference to the floor fill color.

Dungeon Draw currently assumes square texture files.

Some care needs to be taken when choosing texture files and sizes. Using larger texture files (e.g., 400x400, 600x600, etc) will cause fewer texture sprites and should perform better. Conversely, using a 50x50 texture on a big map can make your browser crawl.

Want some good floor textures? Check out this free Texture Pack 3 from Forgotten Adventures: https://www.patreon.com/posts/texture-pack-3-24886718


## Known issues

* Simultaneous map editors can trample each other's changes and cause save errors. It's best to stick to one map-maker at a time (either the GM or a single player).
1 change: 0 additions & 1 deletion scripts/dungeon.js
Original file line number Diff line number Diff line change
@@ -20,7 +20,6 @@ export class Dungeon extends PlaceableObject {
doorFillOpacity: 0,
floorColor: "#F2EDDF",
floorTexture: "",
floorTextureSize: 0,
wallColor: "#000000",
wallThickness: 8,
};
16 changes: 7 additions & 9 deletions scripts/renderer.js
Original file line number Diff line number Diff line change
@@ -46,18 +46,16 @@ const addTiledBackground = async (container, mask, state) => {
return;
}

//const exterior = state.geometry.getExteriorRing();

const width = canvas.scene.data.width;
const height = canvas.scene.data.height;
const textureSize = state.config.floorTextureSize ? state.config.floorTextureSize : 100;
const rows = Math.ceil(height / textureSize);
const cols = Math.ceil(width / textureSize);
// const textureSize = state.config.floorTextureSize ? state.config.floorTextureSize : 100;
// assume square textures
const textureSize = texture.width;
const rows = Math.ceil(canvas.scene.data.height / textureSize);
const cols = Math.ceil(canvas.scene.data.width / textureSize);

const bg = new PIXI.Container();
for (let row = 0; row < rows; row++) {
for (let col = 0; col < cols; col++) {
// only create a tiling sprite if this row/col intersects with our geometry
// only create a sprite if this row/col rectangle intersects with our map geometry
const rect = geo.pointsToPolygon([
[col * textureSize, row * textureSize],
[(col + 1) * textureSize, row * textureSize],
@@ -66,7 +64,7 @@ const addTiledBackground = async (container, mask, state) => {
[col * textureSize, row * textureSize],
]);
if (state.geometry.intersects(rect) && !state.geometry.touches(rect)) {
console.log(`sprite at row ${row}, col ${col}`);
// console.log(`sprite at row ${row}, col ${col}`);
const sprite = new PIXI.TilingSprite(texture, textureSize, textureSize);
sprite.x = col * textureSize;
sprite.y = row * textureSize;
6 changes: 0 additions & 6 deletions templates/dungeon-config.html
Original file line number Diff line number Diff line change
@@ -50,12 +50,6 @@
<input class="image" type="text" name="floorTexture" value="{{object.floorTexture}}" data-dtype="String" placeholder="File Path" />
</div>
</div>
<div class="form-group">
<label>{{localize "DD.FloorTextureSize"}}</label>
<div class="form-fields">
<input type="number" name="floorTextureSize" value="{{object.floorTextureSize}}" data-dtype="Number"/>
</div>
</div>
<div class="form-group">
<label>{{localize "DD.WallColor"}}</label>
<div class="form-fields">

0 comments on commit 1994db6

Please sign in to comment.