Changeset 47


Ignore:
Timestamp:
Jul 4, 2010, 2:07:55 AM (10 years ago)
Author:
sam
Message:

The layer name is no longer ignored.

Location:
trunk
Files:
8 edited

Legend:

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

    r36 r47  
    44  <image source="../art/test/groundtest.png"/>
    55 </tileset>
    6  <layer name="Layer 0" width="32" height="32">
     6 <layer name="Ground 0" width="32" height="32">
    77  <data encoding="base64" compression="gzip">
    88   H4sIAAAAAAAAA+3QyQ2AMAxEUSuQAsJWQCD0XyITyWnBIPQPT5ZPY08xs/IBSSaZJfueA/MXWWWTKofsgTdU//3yzL43uV/oYMzkPUTl959P72DMFpgPAAAAAH/2ACvSWwAAEAAA
     
    1111 <layer name="Layer 1" width="32" height="32">
    1212  <data encoding="base64" compression="gzip">
    13    H4sIAAAAAAAAA+2SwQqDQAxEtyfZ/kDBW0+uHr1oe+v//5QJ7kAILaWQtSDzYMCsuDOMSYmA178DfAH57g09frk7KsccdE+kfy/K6ZidmF0G7fUhKqJrVXnznZ7nQH+bYRGNVaVqdN56NgX4I4N97kRP0ZD2LiY3I8/ayN/O8PezZrkF+fss3t/vQlTvn/wtdhegqN4B/jf6vBjpu6EKO9Cid4v1J4QQQgg5Ext/7GfGABAAAA==
     13   H4sIAAAAAAAAA2NgGAUw4DjQDiAAYO5TpKEdpJhNLXcYUckcWthPjzRhhOYGWsYvPvsHMh6McLAHyv6BDouBtn+kA0YkPApGwSgYBaNgFIyCUTCcAABQE1isABAAAA==
    1414  </data>
    1515 </layer>
    16  <layer name="Layer 2" width="32" height="32">
     16 <layer name="Wall 0" width="32" height="32">
    1717  <data encoding="base64" compression="gzip">
    18    H4sIAAAAAAAAA2NgGDzAcKAdQAAMdvcNRwALcykg5oJizgFwhzkQawKxBhTT2w3sQKyO5A4LOtsPA5JAbAXE4lC+4gC5Y6QBIyhmQKKpCUDxag3EHATcMApGwSgYBaNgFIyCUTAKhjYAAE/faMAAEAAA
     18   H4sIAAAAAAAAA2NgGAWjYBQQAiZomF724XMHPewnBtMCsAOxFRCrI9mDzh+ouIDxQW4Rp6P9tPQ3PnPpYT8svmHhyYiEQXLqUAxLA7QOd2T7R8EoGAWjYBSMglEwCoYTAACc6uxXABAAAA==
    1919  </data>
    2020 </layer>
    21  <layer name="Layer 3" width="32" height="32">
     21 <layer name="Ground 1" width="32" height="32">
    2222  <data encoding="base64" compression="gzip">
    23    H4sIAAAAAAAAA+3OsQkAIBAEwQ/VDrQDUxMFI/tvygssQXjEHdj4zgx4Qzst7yO4rqikotN+V1UNp/2spgpO+wAAAPjDBmeeUZcAEAAA
     23   H4sIAAAAAAAAA+2SwQnAIAwA7bMdoRNEF2jdf7FGUAih35jPHdwnCBfFUgDAc6tnYr+rol5T+Tkz5lE7PmqdyrS69pi1oL6lu856m7HPm9TfcW/b839hZ9/+hWX0ux/GDDLbAAAAAJF8EOMQKwAQAAA=
    2424  </data>
    2525 </layer>
    26  <layer name="Layer 4" width="32" height="32">
     26 <layer name="Object 1" width="32" height="32">
     27  <data encoding="base64" compression="gzip">
     28   H4sIAAAAAAAAA+3QsQ0AIAwDQa/CCLD/cGko6CjtwJ9kpX1FyjHdARfpfS/i59mGO+ATa0/HdTQAAACgtwJ8x6WQABAAAA==
     29  </data>
     30 </layer>
     31 <layer name="Wall 1" width="32" height="32">
     32  <data encoding="base64" compression="gzip">
     33   H4sIAAAAAAAAA+3RsQkAIAxE0XS6gTiBC1jp/nt5tjZ2ich/8OsLxAzATT/yllQLvmGraqgStP+rF/46VQ7aBwAAgI8FOcHtzAAQAAA=
     34  </data>
     35 </layer>
     36 <layer name="Ground 2" width="32" height="32">
     37  <data encoding="base64" compression="gzip">
     38   H4sIAAAAAAAAA+3OsQ0AIAwDwbQwAhPABGT/yXCRgg0M0p/0tR0BvG+oXjXD/lZLzcrx4f6Rpn0AAAAA/zpR9K8YABAAAA==
     39  </data>
     40 </layer>
     41 <layer name="Object 2" width="32" height="32">
     42  <data encoding="base64" compression="gzip">
     43   H4sIAAAAAAAAA+3OQQkAAAgEQTPZwP6l/NhBDmZg/1sFGfqa7xEAAIBAC7dEfuMAEAAA
     44  </data>
     45 </layer>
     46 <layer name="Wall 2" width="32" height="32">
     47  <data encoding="base64" compression="gzip">
     48   H4sIAAAAAAAAA+3NoREAMAgAMSQrdI869t+ryG6AILl7/REAu92vCaerLof+AADs8ABYXepiABAAAA==
     49  </data>
     50 </layer>
     51 <layer name="Ground 3" width="32" height="32">
     52  <data encoding="base64" compression="gzip">
     53   H4sIAAAAAAAAA+3NMREAIBAEsW9BAg5QAP6VcSr4JpnZeqsAeq0002j6n7TTbfoDAMAPD4e462AAEAAA
     54  </data>
     55 </layer>
     56 <layer name="Object 3" width="32" height="32">
    2757  <data encoding="base64" compression="gzip">
    2858   H4sIAAAAAAAAA+3OMQEAAAwCICutf7ll8PKBBCTQuXUAAACA2gPEOzOTABAAAA==
  • trunk/src/layer.cpp

    r38 r47  
    22#include "layer.h"
    33
    4 Layer::Layer(int w, int h, FILE *fp)
     4Layer::Layer(char const *name, int w, int h, FILE *fp)
    55{
    66    width = w;
    77    height = h;
    88    data = new unsigned int[w * h];
     9
     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        ;
     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;
    922
    1023    fread(data, sizeof(unsigned int), width * height, fp);
     
    2235}
    2336
     37int Layer::GetZ()
     38{
     39    return z;
     40}
     41
    2442unsigned int Layer::GetTile(int x, int y)
    2543{
  • trunk/src/layer.h

    r38 r47  
    11
    2 #if !defined __LAYER_H__
    3 #define __LAYER_H__
     2/*
     3 * The layer object
     4 */
     5
     6#if !defined __DH_LAYER_H__
     7#define __DH_LAYER_H__
    48
    59#include <cstdio>
     
    812{
    913public:
    10     Layer(int w, int h, FILE *fp);
     14    Layer(char const *name, int w, int h, FILE *fp);
    1115    ~Layer();
    1216
     17    int GetZ();
    1318    unsigned int GetTile(int x, int y);
    1419
    15 //private:
    16     int width, height;
     20private:
     21    int width, height, z;
    1722    unsigned int *data;
    1823};
    1924
    20 #endif // __LAYER_H__
     25#endif // __DH_LAYER_H__
    2126
  • trunk/src/map.cpp

    r38 r47  
    2828        fgets(tmp, 1024, fp); // Ignore rest of line
    2929        layers = (Layer **)realloc(layers, sizeof(Layer **) * (nlayers + 1));
    30         layers[nlayers] = new Layer(width, height, fp);
     30        layers[nlayers] = new Layer(name, width, height, fp);
    3131        nlayers++;
    3232    }
     
    4545{
    4646    for (int i = 0; i < nlayers; i++)
     47    {
     48        int z = layers[i]->GetZ();
     49
    4750        for (int y = 0; y < 32; y++)
    4851            for (int x = 0; x < 32; x++)
    49                 tiler->AddTile(layers[i]->GetTile(x, y), x * 32, y * 32, i);
     52                tiler->AddTile(layers[i]->GetTile(x, y), x * 32, y * 32, z);
     53    }
    5054}
    5155
  • trunk/src/map.h

    r38 r47  
     1
     2/*
     3 * The map object
     4 */
     5
     6#if !defined __DH_MAP_H__
     7#define __DH_MAP_H__
    18
    29#include <cstdio>
     
    1825};
    1926
     27#endif // __DH_MAP_H__
     28
  • trunk/src/test-map.cpp

    r38 r47  
    1414    Video *video = new Video("Deus Hax", 640, 480);
    1515    Tiler *tiler = new Tiler();
    16     Map *map = new Map("maps/testmap-coll.tmx");
     16    Map *map = new Map("maps/testmap-grass.tmx");
    1717
    1818    for (int done = 0; !done; )
     
    2525        int playerx, playery;
    2626        SDL_GetMouseState(&playerx, &playery);
     27        playerx = playerx * (640 - 32) / 640;
     28        playery = playery * (480 - 32) / 480;
    2729
    2830        tiler->AddTile(50, playerx, playery, 1);
    29         tiler->AddTile(50, playerx + 64, playery + 32, 3);
    3031
    3132        tiler->Render();
  • trunk/src/tiler.h

    r38 r47  
    1 
    21
    32/*
     
    54 */
    65
    7 #if !defined __TILER_H__
    8 #define __TILER_H__
     6#if !defined __DH_TILER_H__
     7#define __DH_TILER_H__
    98
    109class TilerData;
     
    2423};
    2524
    26 #endif // __TILER_H__
     25#endif // __DH_TILER_H__
    2726
  • trunk/src/video.h

    r22 r47  
     1
     2/*
     3 * The video driver
     4 */
     5
     6#if !defined __DH_VIDEO_H__
     7#define __DH_VIDEO_H__
    18
    29class VideoData;
     
    1724    VideoData *data;
    1825};
     26
     27#endif // __DH_VIDEO_H__
     28
Note: See TracChangeset for help on using the changeset viewer.