shimlong Posted April 29, 2016 Share Posted April 29, 2016 I've spent several hours going through the API, the phaser.js code itself, and Googling as much as possible but I have not been able to find a clear answer: can the X or Y value of a tile be negative? For example, doing Quote map.putTile(2, -1, -1); Doesn't seem to work. The rest of the tilemap (using positive coordinates) is displaying, but this negative one is not. I cannot tell if this is because Tilemaps ignore negative coordinate tiles, or if there is some aspect of the camera, stage, world bounds, camera bounds, that I am not aware of preventing it from rendering. I've tried changing the position of the TileMapLayer to be offset from the top left of the world but it didn't work. I've tried lots of different things with the camera to see if existed but just wasn't showing. My results are inconclusive to me, though. If I am going about this all wrong, please let me know. The basic premise is, I want a Tile with a coordinate of 0,0 to be the center of my world. I want it to expand in all four directions an indeterminate amount of tiles. This is because the game is multiplayer and would potentially need to scale much larger if the player base grew. The tile data is dynamic and is sent from the server to the client. Link to comment Share on other sites More sharing options...
shimlong Posted May 3, 2016 Author Share Posted May 3, 2016 Still trying to figure this out. Any help is appreciated! Link to comment Share on other sites More sharing options...
marcel Posted July 27, 2016 Share Posted July 27, 2016 Hey shimlong, did you find a solution? Link to comment Share on other sites More sharing options...
Cudabear Posted July 27, 2016 Share Posted July 27, 2016 I'm not entirely sure you can't, but I'd really suspect that you can't. Those parameters that you pass in (row, column) essentially get directly put as indexes of the double-indexed array that represents the map. Arrays by definition can't have things at negative indices, so there's your answer. The requirement of having a map that grows in all directions is a tough one. You could make the leftmost column 0 and the topmost row 0, and then when the player moves outside of those bounds, you could prepend the new tiles onto the front of the row and column arrays, so you maintain that the topmost and leftmost tiles are index 0. But that might be computationally expensive. Also, because tilemaps must be squares or rectangles, you might have a massive tilemap that represents what's essentially long strips of tiles when players wander off in one direction. In the end, you're going to run in to scalability problems where your server is sending massive amounts of JSON data to your clients to update them on the state of the world. How games that have "infinitely expanding worlds" usually get around this is to have "chunks", or similarly smaller-sized pieces that fit together to look seamless. What I would do here is make your chunks individual tilemaps (of small sets of tiles, maybe 50x50) that are indexed on the server as a double-indexed array. Have the client then request the required number of chunks around them from the server, and load them in to make the game look seamless (using offsets on the individual maps to align them in the world, even though they're technically all have their own 0 indexes in the top left). When the client requests a chunk from the server that hasn't been generated yet, have the server generate a new tilemap for that chunk and send it out, then cache it for other clients to see when they visit the same area. In theory, your server will then need to store this double-indexed array of tilemap JSON files in some kind of database. You'll also need to do some experimentation with how the JSON from tiled looks and replicate it if you want the server to generate it. I hope this helps. Let me know if you have any questions. drhayes 1 Link to comment Share on other sites More sharing options...
Recommended Posts