Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New Coder
    Join Date
    Mar 2007
    Posts
    33
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Tile-Based Engine - Question on Theory

    I have a non-specific question, more about the theory of tile-based engines than the actual coding.

    What do you think would be the best way to treat objects larger than the tile size? For example, a tree that is taller than the bounds of the tile, or a gate that swings open past the side of the tile's width, or a gigantic boulder that is taller and wider than the tile? How should they be handled, stored, and loadeD?

  • #2
    New Coder
    Join Date
    Feb 2009
    Posts
    30
    Thanks
    1
    Thanked 7 Times in 7 Posts
    Well. What about doing something like treating them as a combination of tiles? Like 6 tiles instead of one.

  • #3
    New Coder
    Join Date
    Mar 2007
    Posts
    33
    Thanks
    6
    Thanked 0 Times in 0 Posts
    But how do I relate that to things such as the scrolling of a screen using a gotoAndStop engine?

  • #4
    New Coder
    Join Date
    Dec 2007
    Location
    NY, USA
    Posts
    27
    Thanks
    7
    Thanked 2 Times in 2 Posts
    Hmm. Well, there are many ways to accomplish that, and I guess the "best" way would just be a matter of opinion. I guess what I would do is this:
    I would attach my tiles through a multi-dimensional array, like:
    Code:
    map_array = new Array();
    map_array = [[1,1,1,1,1,1],
                      [1,0,0,0,0,1],
                      [1,0,0,0,0,1],
                      [1,0,0,0,0,1],
                      [1,0,0,0,0,1],
                      [1,1,1,1,1,1]];
    Then, I would attach the movieclips to the stage, dynamically, using nested for loops. So I would attach tile one (probably a solid wall..) to the stage when my array says 1... etc... etc...

    Okay, so once you've got your basic tiles down, now I would think about how to attach my items, such as a big 6-tile boulder or whatever.

    So I would do something like:
    Code:
    items_array = new Array();
    items_array = [["boulder", 2, 3], ["tree", 5, 4]];  //[frame, xtile, ytile]
    So then you can loop through this array, and attach these movie clips separately (making sure that the item's layers are above the tile's layers, of course).


    So.. I guess that that would be how I would approach that situation. But again, I don't think that there is any right or wrong answer here, I think it just depends on how you like coding.

  • Users who have thanked 333qaz333 for this post:

    Shirk Deio (06-12-2009)

  • #5
    New to the CF scene
    Join Date
    Jun 2009
    Location
    Pune, India
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I had worked on a simple tile-map editor in another era on Macromedia Director, so I have some practical experience to shed upon this.

    Tiles themselves are to granular to be useful once you start building large games. You have to move on to the next level, probably calling them objects. These are game-specific bits of code which 'understand' what they are representing and have methods to manipulate them accordingly. E.g. you have a tree object which might have a Grow method. In its initial stage, it only occupies a single tile. But once you call Grow() upon it, it starts increasing in height (and number of tiles) and sends this updated list to your main map renderer object. A gate object might have Open() and Close() methods which change the state of the object.

    Other than this, you also need to have an opacity map. The player cannot pass through opaque objects while it can pass through transparent ones. I had implemented a 2-bit opacity (on or off), but you can take this to another level and make some things more or less opaque, thus affecting the speed or effort required to pass through them. This too can be handled at the object level, making it much easier than it might be if you were working with tiles directly.

    HTH.

    .p

  • #6
    New Coder
    Join Date
    Mar 2007
    Posts
    33
    Thanks
    6
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by 333qaz333 View Post
    Okay, so once you've got your basic tiles down, now I would think about how to attach my items, such as a big 6-tile boulder or whatever.

    So I would do something like:
    Code:
    items_array = new Array();
    items_array = [["boulder", 2, 3], ["tree", 5, 4]];  //[frame, xtile, ytile]
    Ah, that makes sense! Treat the larger objects not as tiles, but as objects on top of the tiles. That's perfect, thanks for the help!

  • #7
    New Coder
    Join Date
    Dec 2007
    Location
    NY, USA
    Posts
    27
    Thanks
    7
    Thanked 2 Times in 2 Posts
    Haha, no problem. I have done a ton of tile-based games.. so I know quite a bit about them. So any other questions, just ask and I'll (we'll) be glad to help you.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •