Decoding the Map UI

Doc requests, organization, and submissions

Moderators: dorpond, trevor, Azhrei

Post Reply
Si-Malik
Kobold
Posts: 4
Joined: Wed Jun 12, 2013 2:04 pm

Decoding the Map UI

Post by Si-Malik »

I am a Java/Android programmer looking into designing a RPG Mapping system for mobile devices. I've been looking through the MapTool SourceForge for a few days to see if there is an easier/better way of designing the actual map grid. I've looked into a small list of ideas, but I still find that your program has the best implementation. If I could be pointed out to a few key classes, that'd be great.

I'm mostly looking at duplicating tiles along the grid, storing grid data in the form of an array to be altered as needed, for the floor tiles at least. What I'm trying to do is, basically, figure out how the background is generated and attempt to scale it down for devices that may only have a gig of RAM at best. Then, once I've generated a background (say, a grass field), I'll have to figure out how to manage stationary objects, walls, and the like, and finally token movement. After that, it's all UI and networking.

I realize Java uses Swing/AWT, but it'd be a good start.

User avatar
Azhrei
Site Admin
Posts: 12086
Joined: Mon Jun 12, 2006 1:20 pm
Location: Tampa, FL

Re: Decoding the Map UI

Post by Azhrei »

Si-Malik wrote:I've been looking through the MapTool SourceForge for a few days to see if there is an easier/better way of designing the actual map grid.
I'm not exactly sure what you're looking for, but I'll answer if I can.
I'm mostly looking at duplicating tiles along the grid, storing grid data in the form of an array to be altered as needed, for the floor tiles at least.
MapTool doesn't do that. MapTool stores everything as explicit (x,y) coordinates in virtual space, then scales and translates the virtual locations into locations within the mapping space.

For example, when an image is placed at coordinate (0,0) and then moved to (1,1) it has moved one pixel along each of the x and y axes. Of course, if you zoom in far enough (ie. change the scale from virtual -> map coordinates) then the virtual 1-pixel distance could appear to be many pixels when its rendered.

And MapTool doesn't keep a single component with all images composited on it. Instead, it keeps a list of the virtual coords for all images, then composes the map on the fly each time it needs to be rendered (clipping to the viewable area of the map, of course).
What I'm trying to do is, basically, figure out how the background is generated
The background is a repeating texture that is blitted to the component that represents the map before anything else is done. Then all other images are layered on top, with the fog of war being done last (so that it hides things that haven't been seen).

Using this technique there are no limits to the virtual size of the map nor to the size of the map space. And a map that is 500 cells by 500 cells with no images takes the same amount of memory as a map that is 10000 cells by 10000 cells that also has no images.

Pretty cool, eh? ;)
After that, it's all UI and networking.
LOL! So it is, grasshopper. So it is.

What language do you plan to use -- Java? Just curious... :)

Si-Malik
Kobold
Posts: 4
Joined: Wed Jun 12, 2013 2:04 pm

Re: Decoding the Map UI

Post by Si-Malik »

Ah, I see. Now the ZoneRenderer classes make more sense. This is how I imagined MapTool did it, and it's just as complex as I expected. Android has its own 2D graphics renderer, but I've never worked with it. I'm not sure if its as robust as Swing/AWT.

I actually plan on coding this project in Unity, so that it can be ported to several platforms. Of course, that kinda depends on whether my current project is fruitful, that being loading Unity onto Android through a Linux VM. Otherwise, I'll have to wait until I can afford a new PSU for my PC. I'll know whether that's possible by next month.

User avatar
Azhrei
Site Admin
Posts: 12086
Joined: Mon Jun 12, 2006 1:20 pm
Location: Tampa, FL

Re: Decoding the Map UI

Post by Azhrei »

Si-Malik wrote:Ah, I see. Now the ZoneRenderer classes make more sense. This is how I imagined MapTool did it, and it's just as complex as I expected. Android has its own 2D graphics renderer, but I've never worked with it. I'm not sure if its as robust as Swing/AWT.
Glad that helped. :)

For what MapTool does, nothing fancy is happening in Swing.

MapTool uses the Shape/Area objects to represent drawn images and Image objects for everything else (JPEGs, PNGs). Swing merely provides the canvas on which to paint() the picture, but any graphical destination would work as well (assuming they had clipping, scaling, rotation, and transparency support, since MapTool uses them). Your own application may not need those features.
I actually plan on coding this project in Unity, so that it can be ported to several platforms.
Ah, yes. I looked at Unity but found it to be too closed for things I might want to write. Their licensing model was rather restrictive, IIRC...
Of course, that kinda depends on whether my current project is fruitful, that being loading Unity onto Android through a Linux VM. Otherwise, I'll have to wait until I can afford a new PSU for my PC. I'll know whether that's possible by next month.
Um, PSU = Power Supply Unit? That's necessary because your current computer is in the shop or something? They're about $50 at NewEgg.com; I think I got my ThermalTake for about $60 and it was beefy enough to run 4 hard drives and 95W AMD cpu without breaking a sweat. But no fancy GPU cuz it's not a desktop machine...

Good luck with your project, and I'd like to hear how it goes if you get a chance to update us. Cheers!

Post Reply

Return to “Documentation Requests/Discussion”