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

Can't render Tilemap with negative x/y #10

Closed
ratkingsminion opened this issue Feb 1, 2014 · 3 comments
Closed

Can't render Tilemap with negative x/y #10

ratkingsminion opened this issue Feb 1, 2014 · 3 comments

Comments

@ratkingsminion
Copy link

I have a tilemap like this:

tilemap = new Tilemap("tiles", 32, 32,
    [   [ 1, 1, 0, 1, 1, 0 ],
        [ 1, 0, 0, 0, 1, 0 ],
        [ 1, 0, 0, 0, 1, 0 ],
        [ 1, 1, 1, 1, 1, 0 ],
        [ 0, 0, 0, 0, 0, 0 ]
    ], null, true);

When I render it like this

tilemap.render(painter, Std.int(x), Std.int(y), 800, 600);

I get an error as soon as x and y become negative. As I set the tilemap with repeat = true, this doesn't make much sense in my opinion.

@RobDangerous
Copy link
Member

I agree, but I can not reproduce the error. Can you send me a complete example?

@ratkingsminion
Copy link
Author

Here is the code: http://dl.dropboxusercontent.com/u/10650964/_stuff/kha/tilemaptest/Snakhe.hx
Here is the tiles.png: http://dl.dropboxusercontent.com/u/10650964/_stuff/kha/tilemaptest/tiles.png

When I move left or up, the program will fail at some point, because tilemapPos.x or tilemapPos.y becomes negative. Then, in Tilemap.hx, line 28

tileset.render(painter, map[x % levelWidth][y % levelHeight], x * tileset.TILE_WIDTH, y * tileset.TILE_HEIGHT);

has a problem because it tries to access map[][] with negative values, as far as I understand it.

@RobDangerous
Copy link
Member

Got it. Didn't happen in all backends.
Thanks for the help!

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

No branches or pull requests

2 participants