Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Matrix for Tile Map? #35

Open
sn3p opened this issue Apr 16, 2019 · 3 comments
Open

Use Matrix for Tile Map? #35

sn3p opened this issue Apr 16, 2019 · 3 comments
Labels
question Further information is requested

Comments

@sn3p
Copy link
Collaborator

sn3p commented Apr 16, 2019

related #28

Matrices are used in most tile-based games afaik. For Elixir there is the Matrix modules which might be helpful. Not sure if this is something for us.

Some resources on this

Basic example from the demo above

const map = {
  cols: 8,
  rows: 8,
  tsize: 64,
  tiles: [
    1, 3, 3, 3, 1, 1, 3, 1,
    1, 1, 1, 1, 1, 1, 1, 1,
    1, 1, 1, 1, 1, 2, 1, 1,
    1, 1, 1, 1, 1, 1, 1, 1,
    1, 1, 1, 2, 1, 1, 1, 1,
    1, 1, 1, 1, 2, 1, 1, 1,
    1, 1, 1, 1, 2, 1, 1, 1,
    1, 1, 1, 0, 0, 1, 1, 1
  ],
  getTile: (col, row) => {
    return this.tiles[row * map.cols + col]
  }
};

translated to:

no-scroll

@sn3p sn3p added the question Further information is requested label Apr 16, 2019
@richardvdveen
Copy link
Contributor

Implicitly, we are already using a matrix I guess. What would be the benefit of making it hardcoded like this?

@sn3p
Copy link
Collaborator Author

sn3p commented Apr 16, 2019

Implicitly, we are already using a matrix I guess

True

What would be the benefit of making it hardcoded like this?

The example is hardcoded, but could be generated and updated of course.
I'm looking for a way fix #28 and have a nice way to have tiles with different textures on top of each other.

@richardvdveen
Copy link
Contributor

Ah oke! Might be nice, running into this when clawing as well (new random background)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants