Skip to content

Scrolling World #10

Description

@fractalbach

Scrolling Logical Map. Allows players to traverse a large world map by re-rendering map blocks.

Currently, using 9 mapblocks in a 3x3 grid. Where each mapblock is made of a bunch of tiles. Using CSS grid. : https://css-tricks.com/snippets/css/complete-guide-grid/

Strategy

Trigger event when all of the following are true...

  • you're in one of the outer mapblocks. (Not in middle mapblock)
  • you're less than halfway away from the outer edge of that mapblock

What happens:

  • the 3 blocks furthest away from you are "removed".
    -the rest shift the fill the "gap"
  • 3 new blocks appear in the area you are headed toward.
  • the camera scrolls back to the tile it was initially looking at.

What actually happens

  • save camera location (the tile)
  • the 3 furthest blocks are cleared and redrawn
  • swap 3 furthest with the 3 your player is standing on.
  • swap the 3 your player is standing on with the middle 3.
  • update variable camera.FIRST_TILE
  • scroll to initial camera location (the tile)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions