Terrain Modification in Grid Based Games – Exercise A: Minimap and Comets

Terrain Modification Tutorial Thumbnail

Alright, while I already wrote about putting the concepts of this series to a use, here are two examples:

  • The implementation of a minimap and
  • The concept of a bouncing map


The minimap is implemented pretty easy. With a decreased tilesize and a zero mountain height you can easily modify the size of the map and make it ‘mini’. Now the map is bigger than what the ‘playground’ shows. Pretty easy again. With the getNodeByCoords methods we’ll define the middle node (for example by clicking on the minimap) and do just show a region of the actual map.

And here is just a little idea I had when I thought about how to torture the little folks in my realm. Click on the map and imagine a mighty clashing sound.

Wish I had some more time to continue here. Meanwhile you can play Pete Barons remake of populous in flash. Have fun, yoho!

This entry was posted in as3, flash, grids, mochiads, Terrain Modification and tagged , , . Bookmark the permalink.
Be Sociable, Share!

2 Responses to Terrain Modification in Grid Based Games – Exercise A: Minimap and Comets

  1. Neil Roy says:

    An interesting problem I have, and I see you have it too, is if you raise the terrain up too high, when you point at a tile, it selects a tile far north of where you are pointing. I have been working on my own and all I can come up with is once you select a tile, the program could then compare the selected tile’s position on screen with where the mouse is pointing and then adjust accordingly (check the next tile south until one matches?). I haven’t tried implementing this idea yet, it’s just off the top of my head. I am wonder if you have a clue how games like SimCity2000 done it, or Transport Tycoon/Locomotion. They all can create huge hills (I think Locomotion can have a hill around 30 layers high). Is there a better way to calculate which tile you’re pointing at? (I use tiles rather than nodes like you, but the problem is the same).

    • kegogrog says:

      Hmm, in this example it is the intended behaviour, because the base (height 0) is taken to determine the position. It’s the same thing in Populous I.
      But since there are ‘only’ 81 nodes in this example, I think, one could store the screen coordinates of all points in an array and just query that based on the mouse position. Like:

      var myNode:* = null; // empty first
      var minimalDist:Number = 9999; // the minimal distance threshold
      var mousePos:Point; // the mouse position
      var myDistance:Number; // the distance between mouse and a node
      var nodePos:Point // a node's position
      for ( var i:int = 0; i < screenNodes.length; i++ ) through all 81 nodes
      {
        nodePos = new Point ( screenNodes[i].x, screenNodes[i].y );
        myDistance = Point.distance(mousePos, nodePos);
        myDistance < minimalDistance ? myNode = screenNodes[i] : void;
      }
      if ( myNode ) // if there is a node (which should be, but control is
      always better), use that for further actions like highlighting it.
      {
        myCursor.x = myNode.x;
        myCursor.y = myNode.y;
      }
      

      I don't know if that would be a good idea with a screen full of tiles (like SimCity), though it would be possible to run that function only if the cursor moves a certain distance since the last function call. Worth a try.

      If it doesn't work out, a quick and dirty solution would be a MOUSE_OVER listener on each tile. But, ...just don't do that.

Leave a Reply

Your email address will not be published.