XNA Creators Club Online
Page 1 of 1 (3 items)
Sort Posts: Previous Next

Tiles and Objects

Last post 3/22/2009 12:03 AM by Demonofloom. 2 replies.
  • 3/17/2009 4:30 PM

    Tiles and Objects

    Hey, I've been reading every thread I can find related to Tiles and map editing but I've yet to find a solution to my problem.

    I've made a TileEngine which saves and loads tiles, it does so in a horrible text style format something like this:

    1
    10
    10
    2
    2
    2
    0

    and etc, going down very far.

    I created this tile engine using a tutorial which really is designed for RPG style games since I couldn't find anything else. To create the maps themselves i use Tile Studio and import them into the game.
    However this doesn't fit my needs at all as I want to have movable objects on the screen, since my game has some small momentum physics (knocking into an object will bounce you back and cause the object to move based on mass/velocity). Also all my collision detection is done based on Bounding and Radial collision which uses the positions of sprites, something which the tileEngine also dosen't seem to allow for.

    What I really want is the ability to place these sprites, which contain values such as Vel, Angle, Pos etc etc. Then somehow save there positions, so that when i Load them I am able to interact with them. If that makes any sense.

    Right now I would be able to create a single level by making lots of sprites and individually positioning them using x and y values, but I want multiple levels!

    I have a decent leveling of Programming skills, mostly related to C++/C# but when it comes to saving and importing files, I'm lost.

    Any help is greatly appreciated, thanks.
    http://lemoncog.co.uk
  • 3/17/2009 7:10 PM In reply to

    Re: Tiles and Objects

    If you've got blocks that will require multiple properties, then you're going to need to save each of those properties and associate them with the blocks. You could do this with XML or with a delimited list sort of structure.

    I'll let you work out the XML for yourself if you want to go that route, but if you used something like a comma delemited file, you might do something like

    10,200,200,10,90

    Where the first number is the tile type, the second is the x position, third is y, fourth is velocity, and fifth is angle.

    Then just have each row be a new tile. Read in one row at a time (which you may already be doing) and then split on the commas and get each property of the tile.

    For multiple levels, you can either have something in the file that indicates where the tiles for one level end and the next begin (for instance the text *END* or maybe each level simply has 20 rows) or you can do one level per file and then have a master file that contains a list of all levels (this is what I did in my game).
  • 3/22/2009 12:03 AM In reply to

    Re: Tiles and Objects

    ok Thanks, after doing some more searching into XML I found:

    http://www.devhood.com/Tutorials/tutorial_details.aspx?tutorial_id=236

    I can't believe how simple it is! Now I can start work on my Map Editor.
    http://lemoncog.co.uk
Page 1 of 1 (3 items) Previous Next