JernejHabjan / fuzzy-waddle

Game development with Phaser and networking available on https://fuzzy-waddle.onrender.com and https://jernejhabjan.github.io/fuzzy-waddle
https://fuzzy-waddle.onrender.com
MIT License
0 stars 0 forks source link

Bleeding tiles #58

Closed JernejHabjan closed 10 months ago

JernejHabjan commented 1 year ago

extrude tiles

https://github.com/photonstorm/phaser/issues/6460

JernejHabjan commented 1 year ago

FIxed by creating own tiles

JernejHabjan commented 10 months ago

Still happens when scrolling inwards and outwards. Also reported here https://github.com/phaserjs/phaser/issues/6674

JernejHabjan commented 10 months ago
https://github.com/sporadic-labs/tile-extruder?tab=readme-ov-file#usage-as-a-library
tile-extruder --tileWidth 64 --tileHeight 32 --input tiles.png --output tiles.png
tile-extruder --tileWidth 64 --tileHeight 32 --input tiles_2.png --output tiles_2.png

Before: image

After: image Black dots disappear, but these jagged edge is shown. Same here: image

Not sure if I can fix this

JernejHabjan commented 10 months ago

Not fixing atm as there's no good solution. One Solution is to keep tiles same dimension as they are and introduce no tile extrusion, but just extrude tile manually only on bottom part, The issue here would be that bottom of the tile would be jagged if multiple are stitched together

JernejHabjan commented 10 months ago

Conversation on Tiled forum also here: https://discord.com/channels/524610627545595904/524610627545595906/1200151476341846027

JernejHabjan commented 10 months ago

This can be worked around when zooming in and out:

private zoomIn(): void {
    const newZoom = this.mainCamera.zoom * 2;
    const validZoom = this.findNearestValidZoom(newZoom);

    if (validZoom <= this.cameraMinZoom) {
      this.mainCamera.zoom = validZoom;
    }
  }

  private zoomOut(): void {
    const newZoom = this.mainCamera.zoom * 0.5;
    const validZoom = this.findNearestValidZoom(newZoom);

    if (validZoom >= this.cameraMaxZoom) {
      this.mainCamera.zoom = validZoom;
    }
  }

  private findNearestValidZoom(zoom: number): number {
    const powersOfTwo = [0.5, 1, 2, 4, 8, 16]; // Adjust as needed
    let nearest = powersOfTwo[0];
    for (const power of powersOfTwo) {
      if (Math.abs(zoom - power) < Math.abs(zoom - nearest)) {
        nearest = power;
      }
    }
    return nearest;
  }

Making sure you're zooming in and out by powers of 2 so we don't get rounding issue which would cause these artefacts

JernejHabjan commented 10 months ago

Finally fixed with this zoom