Sign in to follow this  
MikeKan13

Isometric World Wrap

Recommended Posts

MikeKan13    102
[img]http://img.photobucket.com/albums/v697/Mikekan13/wrap.png[/img]


Ok some details about my game:
It is an online game with a server and clients. It is isometric with tiles being 88x44. The entire world is composed of cells that are 25x25 tiles large. I am trying to make it so the world wraps. Simulating a globe.First, I need to come up with an algorithm that will change the players pixel X and Y to the right position when they walk out of the current cell and into another one. Each cell is 25X25 blocks that are 88X44 so the players pixel x and y can range between 1x1 and 2200x1100 although the white spaces would be areas they would never be. Now I can find out what block they are on and I can tell when they enter a new cell. If xblock > 25 then they move to new cell. But the problem is mirroring their pixel x and pixel y cords so they will be on the opposite side of the diamond. I hope that explanation is enough to understand what I am talking about. Picture not to scale.

Share this post


Link to post
Share on other sites
Tiblanc    560
I'd recommend working with world coordinates instead of pixel coordinates. Rendering is when you transform from world to screen coordinates. With world coordinates, it becomes trivial. If the player's X or Y is outside the world boundaries(most likely 0 and 25 * TILE_WIDTH), then remove or add the world size depending on where he reached the boundary and he'll pop on the other side.

Share this post


Link to post
Share on other sites
MikeKan13    102
[quote name='Tiblanc' timestamp='1302522303' post='4797061']
I'd recommend working with world coordinates instead of pixel coordinates. Rendering is when you transform from world to screen coordinates. With world coordinates, it becomes trivial. If the player's X or Y is outside the world boundaries(most likely 0 and 25 * TILE_WIDTH), then remove or add the world size depending on where he reached the boundary and he'll pop on the other side.
[/quote]

Although it might be easier to use world coordinates I am doing this to save bandwidth from server to client. A world coordinate would have to be sent as 4 byters per axis so a total of 8 for x,y but by doing it this way I can reduce it to half. All I really need to find out is how to wrap between cells so if they went off the bottom right edge they would essentially wrap to the top left corner. I thought it might be something like subtracting the players pixel x from the max cell x and then making that the new pixel x for the player but that isn't quite right.

Share this post


Link to post
Share on other sites
Tiblanc    560
Unless you do not have a Z axis, you might run into some issues later on. It will be impossible to distinguish between someone who reached the top on the ground and someone who reached the top while being elevated since they will both have the same screen coordinates. In that case, your X coordinate to the next cell is given by adding 1100 to your current coordinate if it's below 1100 and subtract 1100 if it's over. Same thing for your Y coordinate except use 550.

Also, I'd advise not doing such premature optimization as you'll end up shooting yourself in the foot. Bandwidth is not the rare resource it was back in the modem days. You should make sure you absolutely need this optimization because most of your code will end up twisted to accommodate this decision. Just a FYI, you can send these coordinates in much smaller than 4 bytes. The screen coordinates can fit in 21 bits. The world coordinates for the same position in the cell can be sent in 22 bits. Even if you don't compress them, that will hardly make a difference in the end and you might just save yourself some serious headaches down the road.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this