Changeset 70 for trunk


Ignore:
Timestamp:
Jul 6, 2010, 2:02:41 PM (11 years ago)
Author:
sam
Message:

Breaking the map/layer code apart. Needs more work.

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/maps/testmap-grass.tmx

    r63 r70  
    1010  <image source="../art/test/roomtest.png"/>
    1111 </tileset>
    12  <layer name="Ground 0" width="20" height="15">
     12 <layer name="H0A (ground)" width="20" height="15">
    1313  <data encoding="base64" compression="gzip">
    1414   H4sIAAAAAAAAAxNkYGAQHMWjeBSP4iGAAXa2kMCwBAAA
    1515  </data>
    1616 </layer>
    17  <layer name="Ground Decal 0" width="20" height="15">
     17 <layer name="H0B (flowers)" width="20" height="15">
    1818  <data encoding="base64" compression="gzip">
    1919   H4sIAAAAAAAAA2NgoA1gAmJmIGYBYlYon5UC84SAWBiIRYBYCYjFgFiUAjOVoG5TgZoB4qsCsRoV3AijmaDuJBeA3KQMdSOMVqXAvFEwCoY6AAA8w2LgsAQAAA==
    2020  </data>
    2121 </layer>
    22  <layer name="Object 0" width="20" height="15">
     22 <layer name="V0A (rocks)" width="20" height="15">
    2323  <data encoding="base64" compression="gzip">
    2424   H4sIAAAAAAAAA2NgGDrAcYDsU6SR+bjMNaKyPfjMIydMjdDMpDR8jBgwzaQUGOFgU8s8aruVVn4frIARCZMCAAtPgriwBAAA
    2525  </data>
    2626 </layer>
    27  <layer name="Wall 0" width="20" height="15">
     27 <layer name="V0B (walls)" width="20" height="15">
    2828  <data encoding="base64" compression="gzip">
    2929   H4sIAAAAAAAAA2NgGAWjgIHBBA2Tqx+fuZS4Bx8mBrADsRUQqyPpQ+dTy+8wPshscQrMI8Vd+NSRYx4svGDuZ0TCIDl1KIaFIan+RDaPFAAAATWdT7AEAAA=
    3030  </data>
    3131 </layer>
    32  <layer name="Ground 1" width="20" height="15">
     32 <layer name="H1A (mid ground)" width="20" height="15">
    3333  <data encoding="base64" compression="gzip">
    3434   H4sIAAAAAAAAA2NgGAUjEUgBMScVzbMEYg0g5oJiDSxquEiw0xyINaFYA4o10cwCiWmR6VYtND7MfAsqmUeOu9DdgxyWlJiHHJYwTKo/GZEwNQC5ZgEAj7AOJ7AEAAA=
    3535  </data>
    3636 </layer>
    37  <layer name="Object 1" width="20" height="15">
     37 <layer name="V1A (mid objects)" width="20" height="15">
    3838  <data encoding="base64" compression="gzip">
    3939   H4sIAAAAAAAAA2NgoB0wpKHZg8G+gQAjwY+kAMWBdgCNgBEUMyDR1DBzqAMAjCH/frAEAAA=
    4040  </data>
    4141 </layer>
    42  <layer name="Wall 1" width="20" height="15">
     42 <layer name="V1B (mid walls)" width="20" height="15">
    4343  <data encoding="base64" compression="gzip">
    4444   H4sIAAAAAAAAA2NgGAWjgIHBBA1TCtiBWJ3KZoKAJBBbAbE4lcwbKECLcLEGYg4qmTdYAQCub7nWsAQAAA==
    4545  </data>
    4646 </layer>
    47  <layer name="Ground 2" width="20" height="15">
     47 <layer name="H2A (upper ground)" width="20" height="15">
    4848  <data encoding="base64" compression="gzip">
    4949   H4sIAAAAAAAAA2NgGAVDEUgBMRcUc1LBPHMg1gRiDSimhpnI5lpQybxRMLIBANElvy+wBAAA
    5050  </data>
    5151 </layer>
    52  <layer name="Object 2" width="20" height="15">
     52 <layer name="V2A (upper objects)" width="20" height="15">
    5353  <data encoding="base64" compression="gzip">
    5454   H4sIAAAAAAAAA2NgGAVDFRhBseNAO2QUjAI6AQDJ5AfJsAQAAA==
    5555  </data>
    5656 </layer>
    57  <layer name="Wall 2" width="20" height="15">
     57 <layer name="V2B (upper walls)" width="20" height="15">
    5858  <data encoding="base64" compression="gzip">
    5959   H4sIAAAAAAAAA2NgGAWjYBQQAiZImBpAEoitgZiDSuaNFAAAEtPDprAEAAA=
    6060  </data>
    6161 </layer>
    62  <layer name="Ground 3" width="20" height="15">
     62 <layer name="H3A (high ground)" width="20" height="15">
    6363  <data encoding="base64" compression="gzip">
    6464   H4sIAAAAAAAAA2NgGAWjYPgBKSDmAmJOKplnDsSaQGxBJfNGAXkAACtdiWSwBAAA
    6565  </data>
    6666 </layer>
    67  <layer name="Object 3" width="20" height="15">
     67 <layer name="V3A (high objects)" width="20" height="15">
    6868  <data encoding="base64" compression="gzip">
    6969   H4sIAAAAAAAAA2NgGAX0BoYD7YBRMAqGKAAAeZc2/bAEAAA=
  • trunk/src/layer.cpp

    r57 r70  
    22#include "layer.h"
    33
    4 Layer::Layer(char const *name, int w, int h, FILE *fp)
     4Layer::Layer(int w, int h, int z, char const *base64)
    55{
    66    width = w;
    77    height = h;
     8    level = z;
    89    data = new unsigned int[w * h];
    910
    10     if (sscanf(name, "Ground %d", &z) == 1)
    11         ;
    12     else if (sscanf(name, "Ground Decal %d", &z) == 1)
    13         ;
    14     else if (sscanf(name, "Object %d", &z) == 1)
    15         z++;
    16     else if (sscanf(name, "Wall %d", &z) == 1)
    17         z++;
    18     else if (sscanf(name, "Wall Decal %d", &z) == 1)
    19         z++;
    20     else
    21         z = -1;
    22 
     11#if 0
    2312    fread(data, sizeof(unsigned int), width * height, fp);
    2413    for (int n = 0; n < width * height; n++)
     
    2817        data[n] = i ? i - 1 : 0;
    2918    }
     19#endif
    3020}
    3121
     
    3727int Layer::GetZ()
    3828{
    39     return z;
     29    return level;
    4030}
    4131
  • trunk/src/layer.h

    r47 r70  
    1212{
    1313public:
    14     Layer(char const *name, int w, int h, FILE *fp);
     14    Layer(int w, int h, int z, char const *base64);
    1515    ~Layer();
    1616
     
    1919
    2020private:
    21     int width, height, z;
     21    int width, height, level;
    2222    unsigned int *data;
    2323};
  • trunk/src/map.cpp

    r47 r70  
    1010    nlayers(0)
    1111{
     12    char tmp[BUFSIZ];
     13    int firstgid = 0, width = 0, height = 0, level = 0, data = 0;
     14
     15    FILE *fp = fopen(path, "r");
     16
     17    if (!fp)
     18        return;
     19
     20    while (!feof(fp))
     21    {
     22        char str[1024];
     23        int i, j, k;
     24        char a, b;
     25
     26        fgets(tmp, BUFSIZ, fp);
     27
     28        if (data)
     29        {
     30            if (--data == 0)
     31            {
     32                layers[nlayers] = new Layer(width, height, level, tmp);
     33                nlayers++;
     34            }
     35        }
     36        else if (sscanf(tmp, " <tileset firstgid=\"%i\"", &i) == 1)
     37        {
     38            firstgid = i;
     39            fprintf(stderr, "found tileset, firstgid %i\n", firstgid);
     40        }
     41        else if (sscanf(tmp, " <image source=\"%[^\"]\"", str) == 1)
     42        {
     43            fprintf(stderr, "image %s\n", str);
     44        }
     45        else if (sscanf(tmp, " <layer name=\"%c%i%c%*[^\"]\" width=\"%i\" height=\"%i\"",
     46                        &a, &i, &b, &j, &k) == 5)
     47        {
     48            fprintf(stderr, "%s layer, level %i, sublevel %c, %ix%i\n",
     49                    a == 'H' ? "horizontal" : "vertical", i, b, j, k);
     50            layers = (Layer **)realloc(layers, sizeof(Layer **) * (nlayers + 1));
     51            width = j;
     52            height = k;
     53            data = 2;
     54        }
     55        else
     56        {
     57            fprintf(stderr, ".");
     58        }
     59    }
     60
     61    fclose(fp);
     62
     63/*
    1264    char tmp[1024];
    1365
     
    1870    while (fp && !feof(fp))
    1971    {
    20         char name[1024];
    2172        int width, height;
    2273
     
    3384
    3485    pclose(fp);
     86*/
    3587}
    3688
Note: See TracChangeset for help on using the changeset viewer.