Changeset 1184


Ignore:
Timestamp:
Apr 3, 2012, 1:25:03 AM (8 years ago)
Author:
sam
Message:

core: allow to stretch 2D sprits in both X and Y directions.

Location:
trunk
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/deushax/debugsprite.cpp

    r1046 r1184  
    4141    Ticker::Ref(game);
    4242    data->tileset = Tiler::Register("deushax/art/test/character-dress.png",
    43                                     ivec2(32), ivec2(0), sqrtf(2));
     43                                    ivec2(32), ivec2(0), vec2(1.0f, sqrtf(2)));
    4444    data->pos = vec3(320, 206, 0);
    4545}
  • trunk/monsterz/board.cpp

    r1135 r1184  
    102102    data->npieces = minnpieces;
    103103    data->maxnpieces = maxnpieces;
    104     data->screen = Tiler::Register(PNG_BACKGROUND, ivec2(640, 480), ivec2(0), 1.0f);
    105     data->board = Tiler::Register(PNG_BOARD, ivec2(384), ivec2(0), 1.0f);
    106     data->tiles = Tiler::Register(PNG_TILES, data->size, ivec2(0), 1.0f);
    107     data->icons = Tiler::Register(PNG_ICONS, ivec2(24), ivec2(0), 1.0f);
     104    data->screen = Tiler::Register(PNG_BACKGROUND, ivec2(640, 480), ivec2(0), vec2(1.0f));
     105    data->board = Tiler::Register(PNG_BOARD, ivec2(384), ivec2(0), vec2(1.0f));
     106    data->tiles = Tiler::Register(PNG_TILES, data->size, ivec2(0), vec2(1.0f));
     107    data->icons = Tiler::Register(PNG_ICONS, ivec2(24), ivec2(0), vec2(1.0f));
    108108    data->click = Sampler::Register(WAV_CLICK);
    109109    data->whip = Sampler::Register(WAV_WHIP);
  • trunk/monsterz/interface.cpp

    r1135 r1184  
    5757    data->title = NULL;
    5858    data->board = NULL;
    59     data->tiles = Tiler::Register(PNG_TILES, ivec2(48), ivec2(0), 1.0f);
     59    data->tiles = Tiler::Register(PNG_TILES, ivec2(48), ivec2(0), vec2(1.0f));
    6060    data->state = InterfaceData::INIT;
    6161
  • trunk/monsterz/piece.cpp

    r1135 r1184  
    9494    case PIECE_HUNT:
    9595        data->size = ivec2(48);
    96         data->tileset = Tiler::Register(PNG_TILES, data->size, ivec2(0), 1.0f);
     96        data->tileset = Tiler::Register(PNG_TILES, data->size, ivec2(0), vec2(1.0f));
    9797        data->pieceid = 80 + 20 * pieceid;
    9898        break;
  • trunk/monsterz/thumbs.cpp

    r1046 r1184  
    4747  : data(new ThumbsData())
    4848{
    49     data->icons = Tiler::Register(PNG_ICONS, ivec2(24), ivec2(0), 1.0f);
     49    data->icons = Tiler::Register(PNG_ICONS, ivec2(24), ivec2(0), vec2(1.0f));
    5050
    5151    data->npieces = 0;
  • trunk/monsterz/title.cpp

    r1137 r1184  
    139139    srand(rand() ^ time(NULL));
    140140
    141     data->logo = Tiler::Register(PNG_TITLE_LOGO, ivec2(380, 181), ivec2(0), 1.0f);
     141    data->logo = Tiler::Register(PNG_TITLE_LOGO, ivec2(380, 181), ivec2(0), vec2(1.0f));
    142142    data->logo_sprite = new Sprite(data->logo, 0);
    143143    data->logo_sprite->position = vec3(640 / 2 - 380 / 2, 250, 10);
    144144    Ticker::Ref(data->logo_sprite);
    145145
    146     data->ground = Tiler::Register(PNG_TITLE_GROUND, ivec2(384, 80), ivec2(0), 1.0f);
     146    data->ground = Tiler::Register(PNG_TITLE_GROUND, ivec2(384, 80), ivec2(0), vec2(1.0f));
    147147    data->ground_pos = ivec2((bbox[1] - bbox[0]).xy / vec2(2, 4))
    148148                     - ivec2(192, 80);
    149149
    150     data->rocks = Tiler::Register(PNG_TITLE_ROCKS, ivec2(640, 155), ivec2(0), 1.0f);
     150    data->rocks = Tiler::Register(PNG_TITLE_ROCKS, ivec2(640, 155), ivec2(0), vec2(1.0f));
    151151    data->rocks_pos = ivec2((bbox[1] - bbox[0]).xy / vec2(2, 2))
    152152                    - ivec2(320, 240);
    153153
    154     data->title = Tiler::Register(PNG_TITLE, ivec2(384), ivec2(0), 1.0f);
    155     data->stars = Tiler::Register(PNG_STARS, ivec2(384, 144), ivec2(0), 1.0f);
    156     data->clouds = Tiler::Register(PNG_CLOUDS, ivec2(160, 32), ivec2(0), 1.0f);
    157     data->eagle.tiles = Tiler::Register(PNG_EAGLE, ivec2(16), ivec2(0), 1.0f);
     154    data->title = Tiler::Register(PNG_TITLE, ivec2(384), ivec2(0), vec2(1.0f));
     155    data->stars = Tiler::Register(PNG_STARS, ivec2(384, 144), ivec2(0), vec2(1.0f));
     156    data->clouds = Tiler::Register(PNG_CLOUDS, ivec2(160, 32), ivec2(0), vec2(1.0f));
     157    data->eagle.tiles = Tiler::Register(PNG_EAGLE, ivec2(16), ivec2(0), vec2(1.0f));
    158158    for (int n = 0; n < 6; n++)
    159159        data->anim[n] = Tiler::Register(PNG_TITLEANIM[n],
    160                                         animsize[n], ivec2(0), 1.0f);
     160                                        animsize[n], ivec2(0), vec2(1.0f));
    161161    for (int n = 0; n < 7; n++)
    162162        data->event[n] = Tiler::Register(PNG_TITLEEVENT[n],
    163                                          eventsize[n], ivec2(0), 1.0f);
     163                                         eventsize[n], ivec2(0), vec2(1.0f));
    164164    data->state = TitleData::IDLE;
    165165    data->period = TitleData::DAY;
  • trunk/src/font.cpp

    r1110 r1184  
    4747    sprintf(data->name, "<font> %s", path);
    4848
    49     data->tileset = Tiler::Register(path, ivec2(0), ivec2(16), 1.0f);
     49    data->tileset = Tiler::Register(path, ivec2(0), ivec2(16), vec2(1.0f));
    5050    data->size = data->tileset->GetSize(0);
    5151
  • trunk/src/map.cpp

    r1046 r1184  
    137137            /* This is a tileset image file. Associate it with firstgid. */
    138138            data->tilesets[data->ntilers] = Tiler::Register(str, ivec2(32),
    139                                                             ivec2(0), sqrtf(2));
     139                                               ivec2(0), vec2(1.0f, sqrtf(2)));
    140140            data->ntilers++;
    141141            //Log::Debug("new tiler %s\n", str);
  • trunk/src/tiler.cpp

    r863 r1184  
    4242
    4343TileSet *Tiler::Register(char const *path, ivec2 size, ivec2 count,
    44                          float dilate)
     44                         vec2 scale)
    4545{
    4646    int id = data->tilesets.MakeSlot(path);
     
    4949    if (!tileset)
    5050    {
    51         tileset = new TileSet(path, size, count, dilate);
     51        tileset = new TileSet(path, size, count, scale);
    5252        data->tilesets.SetEntity(id, tileset);
    5353    }
  • trunk/src/tiler.h

    r863 r1184  
    2929public:
    3030    static TileSet *Register(char const *path, ivec2 size, ivec2 count,
    31                         float dilate);
     31                             vec2 scale);
    3232    static void Deregister(TileSet *);
    3333};
  • trunk/src/tileset.cpp

    r1179 r1184  
    4343    int *tiles, ntiles;
    4444    ivec2 size, isize, count;
    45     float dilate, tx, ty;
     45    vec2 scale;
     46    float tx, ty;
    4647
    4748    Image *img;
     
    6162 */
    6263
    63 TileSet::TileSet(char const *path, ivec2 size, ivec2 count, float dilate)
     64TileSet::TileSet(char const *path, ivec2 size, ivec2 count, vec2 scale)
    6465  : data(new TileSetData())
    6566{
     
    9899    data->ty = (float)data->size.y / PotUp(data->isize.y);
    99100
    100     data->dilate = dilate;
     101    data->scale = scale;
    101102    data->ntiles = data->count.x * data->count.y;
    102103
     
    224225    float tx = data->tx * ((id & 0xffff) % data->count.x);
    225226    float ty = data->ty * ((id & 0xffff) / data->count.x);
    226     float dilate = data->dilate;
     227    vec2 scale = data->scale;
    227228
    228229    int dx = data->size.x;
     
    241242        float tmp[10];
    242243
    243         *vertex++ = tmp[0] = pos.x;
    244         *vertex++ = tmp[1] = dilate * (pos.y + dy);
    245         *vertex++ = tmp[2] = dilate * (pos.z + dz);
     244        *vertex++ = tmp[0] = scale.x * pos.x;
     245        *vertex++ = tmp[1] = scale.y * (pos.y + dy);
     246        *vertex++ = tmp[2] = scale.y * (pos.z + dz);
    246247        *texture++ = tmp[3] = tx;
    247248        *texture++ = tmp[4] = ty;
    248249
    249         *vertex++ = pos.x + dx;
    250         *vertex++ = dilate * (pos.y + dy);
    251         *vertex++ = dilate * (pos.z + dz);
     250        *vertex++ = scale.x * (pos.x + dx);
     251        *vertex++ = scale.y * (pos.y + dy);
     252        *vertex++ = scale.y * (pos.z + dz);
    252253        *texture++ = tx + data->tx;
    253254        *texture++ = ty;
    254255
    255         *vertex++ = tmp[5] = pos.x + dx;
    256         *vertex++ = tmp[6] = dilate * pos.y;
    257         *vertex++ = tmp[7] = dilate * pos.z;
     256        *vertex++ = tmp[5] = scale.x * (pos.x + dx);
     257        *vertex++ = tmp[6] = scale.y * pos.y;
     258        *vertex++ = tmp[7] = scale.y * pos.z;
    258259        *texture++ = tmp[8] = tx + data->tx;
    259260        *texture++ = tmp[9] = ty + data->ty;
     
    271272        *texture++ = tmp[9];
    272273
    273         *vertex++ = pos.x;
    274         *vertex++ = dilate * pos.y;
    275         *vertex++ = dilate * pos.z;
     274        *vertex++ = scale.x * pos.x;
     275        *vertex++ = scale.y * pos.y;
     276        *vertex++ = scale.y * pos.z;
    276277        *texture++ = tx;
    277278        *texture++ = ty + data->ty;
  • trunk/src/tileset.h

    r866 r1184  
    3232{
    3333public:
    34     TileSet(char const *path, ivec2 size, ivec2 count, float dilate);
     34    TileSet(char const *path, ivec2 size, ivec2 count, vec2 scale);
    3535    virtual ~TileSet();
    3636
Note: See TracChangeset for help on using the changeset viewer.