The forums have permanently moved to forum.kirupa.com. This forum will be kept around in read-only mode for archival purposes. To learn how to continue using your existing account on the new forums, check out this thread.


Results 1 to 8 of 8

Thread: wall between tiles

  1. #1

    wall between tiles

    hello, maybe the title is a bit. . . odd but i'll try to explain my best, i've been thinking about a game (tile based) and i'd like that there were certain walls between tiles (in the line that divides them) for example:

    (image taken from tonypa tutorials and modified myself)

    i'd like that the hero could move everywhere but not throught the red lines
    (whitout hitest operations)
    so far i can think about how to put the walls in their sites, but i have no idea of how to do that in an easy way, my only idea about doing that simple is doing the map, later a pathfinding of nodes, and remove the nodes that cross the wall, but i think that in a big map would be much more slow, so...
    any ideas?
    Attached Images Attached Images  

  2. #2
    209
    posts
    Registered User
    One way would be to give the tile a special code so they are only passable from certain directions. There might be a more elegant solution though.

  3. #3
    1) create 3 matrixes (I'll just make up some names for this post):
    • mapTiles - stores the actual tiles
    • mapHWalls - stores top + bottom walls
    • mapVWalls - stores left + right walls


    2) keep track of your heros location in rows + columns

    3) Then testing each side would be as simple as:
    • Up - mapHWalls[heroRow][heroColumn]
    • Down - mapHWalls[heroRow][heroColumn+1]
    • Left - mapVWalls[heroRow][heroColumn]
    • Right - mapVWalls[heroRow+1][heroColumn]

  4. #4
    the purpose of fidolo is good but as he/she said there might be a more elegant sollution

    the dlgamer one seems more elegant but i don't like the idea about having 3 matrices (nor having a matrix of matrices)
    and the part to test each side in my opinion I think in large maps it'll become slow
    Last edited by Ignasimg; June 26th, 2008 at 11:06 AM. Reason: miss clicked submit before finnishing ^^'

  5. #5
    you wouldn't have to test each side, just the side to want to exit the tile from

  6. #6
    1,627
    posts
    hugeExplosions = true;
    Just add a property to the tile object which determines the location of the walls. You could use a bitmask or an enumeration as there are only 16 possible combinations of wall locations on a single tile.
    MS Paint FTW!


  7. Quote Originally Posted by Charleh View Post
    Just add a property to the tile object which determines the location of the walls. You could use a bitmask or an enumeration as there are only 16 possible combinations of wall locations on a single tile.
    There's enumeration in actionscript???? xD

  8. #8
    I don't know how slow it would run, nor can I measure how much elegant this solution would be, but... I'm no programmer, so, I'm only giving it a try.

    Why not using strings instead of numbers for the tile types. They would be four character strings, formed by 0 for an exit side and 1 for a blocked side using the format "top down left right", thus, "1110" would be a tile you can only exit through the right, while "1010" could be left by the bottom or the right.

    In fact, as an afterthought, you could use decimal numbers and convert them to binary to get the coordinates if you like.

    Anyway, I'm feeling I'm talking bulls**t, but, then, I may, luckily not...
    Bruno Palermo
    When everything is catastrophic, thank the Gods things aren't worse!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012