Page 2 of 2 FirstFirst 12
Results 11 to 17 of 17

Thread: List in stead of a 2-D array?

  1. #11

    List in stead of a 2-D array?

    what about a list for the currently placed tiles. each item in the list only holds info on that tile in the game, so if i have placed 70 tiles i have 70 items in the list (0 to 69).

    the only bad thing is if you then want to select a tile that is currently placed, you will have to loop through all the tiles (could get slow). so basically you would have something like this:

    [pascal]

    TTile = class/record etc
    Image: TImage?;
    DrawX: integer;
    DrawY: Integer;

    [/pascal]

  2. #12

    List in stead of a 2-D array?

    This idea is simple, but doesn't sound half bad, actually.

    I allready have an array of all the tiles which are to be placed in the game. In stead of making another classlist point to the item allready in my array, I can just change a boolean (Placed := True) and change the X and Y coordinates.

    It might become a bit tricky later on when I do have to do a recursive function on all the tiles, but this may suffice, that or I'll just stick with the huge 2d array.
    Huhuhu

  3. #13

    List in stead of a 2-D array?

    Yes, each method has a downside.

    With the memory pointer one (a tile with pointers to north, south, east, west) it can become quite complex if you just want to loop through each tile (you could get into an infinate loop if your not carefull, or you could miss a tile).

    But with the TList, you dont have the "what tile is next to this one" without the extra overhead of also storing a north, south, east, west pointer. Well i guess you could loop through the list if you know what the X, Y of the tile should be... [size=7px]i should stop thinking out loud[/size]

  4. #14

    List in stead of a 2-D array?

    Yes, FPC has TFPHashTable, in the contnrs unit. You'll have to read the source to figure out how to use it, as there's no documentation.
    [size=10px]"In science one tries to tell people, in such a way as to be understood by everyone, something that no one ever knew before. But in poetry, it's the exact opposite." -- Paul Dirac[/size]

  5. #15

    List in stead of a 2-D array?

    Quote Originally Posted by jdarling
    Also, for anyone that doesn't care to copy/paste and edit to get the above hash table stuff to work, I took the time to get it to compile in FPC. Quite nice, so you don't have to duplicate efforts here is a [url=http://www.eonclash.com/PGD/HashTable.zip]download ]
    Nice work
    cheers,
    Paul.

  6. #16

    List in stead of a 2-D array?

    I really like that hashtable thingy.

    Not really applicable for this purpose to my taste, but handy nonetheless. I'll certainly keep this in mind and I bet it comes in handy in the future. Downloaded and stored it in case this thread dies in the future.
    Huhuhu

  7. #17

    List in stead of a 2-D array?

    Ok, I got to playing around a bit last night, and worked up a sample of using DisplayLists and Pointer Records. Its a bit rough in the comments area, but it works quite well. Basically you can create any number of "rooms" you want in any direction defined. There very well may be an error, but I haven't found any when playing with it. Built in Lazarus, due to the use of windows controls, but could be converted to Delphi easy enough.

    Even though I'm not using quick graphics (standard draw routines used), its pretty snappy. Graphics taken from Renears Tiles and are packaged with it. The TiledImage class may be of interest to some, as well as a few other things inside the zip file.

    Download here

Page 2 of 2 FirstFirst 12

Bookmarks

Posting Permissions

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