Handling Larger Maps in AS3
I have been working on some ideas for a TD game that would be both entertaining and original, and I feel that – with the help of a couple friends’ input – I’m on the way to something worth developing. Since I have already put together much of the “guts” for a TD game, I am hoping that I will be able to quickly put together a prototype in my free time. Ideally, once I have a prototype together, I will be able to find a sponsor to pay for development, and I would then be able to focus some solid time on the project, but that is a bit optimistic at this point, since we are still in the baby conceptual stage.
Without giving too much away on my idea, I’m going to try to cover some concepts and specific ideas that I have had to resolve in order to visualize different portions of the interface and interactions. The first thing I realized was, to fully succeed with the idea I want to implement, I would have to be able to support fairly large maps (in some remote cases, massive may be a better term). Having been a long time RTS (Real Time Strategy) player, I decided to take some cues from them and implement a similar map-handling system. Surprisingly, once things started falling into place, it was quite easy to tweak and get working to a satisfactory level.
Here is the prototype I have come up with thus far:
Once you have clicked somewhere on the SWF to grant focus, you will notice that the little overview of the map to the right gives a scale model of the map as a whole, including pinpoint locations of both friendly and hostile units. The cyan box represents the portion of the map currently seen through the viewport, and you can scroll the map by using the A, S, D and W keys – allowing for two handed control and much more fluid game play. In addition, you will notice that by clicking the preview, you can immediately jump to a specific location on the map and center the viewport on the clicked region.
While the concept is nothing new, I thought it was a fun way to designate and display the larger maps in a TD style game in Flash. If you have any ideas of comments on this method or how the implementation may be improved, please let me know. Once I have the game completed, I may look into sharing some of the source code for individual pieces like this.
One final note as well: if you refresh the page, you will see that the map is randomly generated (both dimensions and location of items) with each page load, so you can find both very elongated or broad maps the more you look. Notice that the preview region always stays proportional to the actual size of the map as well.
Garth Henson has been working professionally as a web developer for nearly 10 years. When not coding in PHP, JavaScript or Actionscript, he can usually be found trying to refine his photography skills.






Enzo Arcade
2 May, 2009
I’ve been thinking of how to invigorate the TD genre but everytime I think of something it comes out age of empires. Bending this genre will be very hard. Are you going to use a scrolled viewport instead of the zoomed out overview. That could add a challenge but why would anyone play that, I don’t know. I’ve thought a bit of resource management would go along way or simply placing towers in resource rich areas, which could be depleted with overuse.
Not to make this comment too long but I am remaking a game called “…and the sky full of stars” here http://sol.gfxile.net/ahd/. In the original you must collect the stars by scrolling up the screen. When you’ve got enough stars you head down to destroy the shadows. My point is there is an intuitive reason for the scrolling. Why is your TD scrolling or massivly large for that matter?
I’m sure you’ll have an answer when your done. I’m just curious.
No matter what you do Good luck!
obsidian
2 May, 2009
Great question, and in my preliminary planning, there is indeed a purpose for allowing for scrolling. Now, don’t get me wrong, I don’t suggest that every level on any TD game should be large enough to scroll, but it’s hard to give justification without giving away details I’m not quite yet ready to give…
I totally agree with you, though, without purpose, simply making a TD game too large to view at once can become annoying rather than intuitive. So, I’m definitely hoping that my reasons are valid for the average gamer
Oh, and I had considered adding the zoom feature as well, but I just have not spent any time researching or implementing that yet. I am in the VERY basic stages at this point.