Changeset 336


Ignore:
Timestamp:
Feb 2, 2011, 6:43:38 PM (10 years ago)
Author:
sam
Message:

Repack title animations to save some space. Can be done even better.

Location:
trunk/monsterz
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/monsterz/title.cpp

    r334 r336  
    5656};
    5757
     58static int2 const animsize[] =
     59{
     60    int2(384, 384),
     61    int2(284, 81),
     62    int2(38, 146),
     63    int2(29, 137),
     64    int2(284, 82),
     65    int2(384, 384),
     66};
     67
     68static int2 const animpos[] =
     69{
     70    int2(0, 0),
     71    int2(65, 255),
     72    int2(239, 168),
     73    int2(248, 168),
     74    int2(63, 255),
     75    int2(0, 0),
     76};
     77
     78static int2 const eventsize[] =
     79{
     80    int2(143, 16),
     81    int2(68, 49),
     82    int2(17, 29),
     83    int2(50, 80),
     84    int2(237, 238),
     85    int2(59, 53),
     86    int2(140, 15),
     87};
     88
     89static int2 const eventpos[] =
     90{
     91    int2(0, 322),
     92    int2(316, 286),
     93    int2(246, 245),
     94    int2(279, 173),
     95    int2(42, 101),
     96    int2(231, 154),
     97    int2(0, 322),
     98};
     99
    58100/*
    59101 * Public Title class
     
    68110    data->title = Tiler::Register(PNG_TITLE, 384, 384, 1.0f);
    69111    for (int n = 0; n < 6; n++)
    70         data->anim[n] = Tiler::Register(PNG_TITLEANIM[n], 384, 384, 1.0f);
     112        data->anim[n] = Tiler::Register(PNG_TITLEANIM[n],
     113                                        animsize[n].x, animsize[n].y, 1.0f);
    71114    for (int n = 0; n < 7; n++)
    72         data->event[n] = Tiler::Register(PNG_TITLEEVENT[n], 384, 384, 1.0f);
     115        data->event[n] = Tiler::Register(PNG_TITLEEVENT[n],
     116                                         eventsize[n].x, eventsize[n].y, 1.0f);
    73117    data->state = TitleData::IDLE;
    74118    data->period = TitleData::DAY;
     
    187231    Entity::TickDraw(deltams);
    188232
    189     int tiler = data->title;
     233    /* The background, always here. */
     234    int backid = (int)data->period;
     235    Scene::GetDefault()->AddTile((data->title << 16) | backid, 24, 72, 1, 0);
     236
     237    /* Maybe an animation? */
     238    int tiler = 0;
    190239    int id = 0;
     240    int2 pos;
    191241
    192242    switch (data->state)
    193243    {
    194244    case TitleData::IDLE:
    195         id = (int)data->period;
    196245        break;
    197246    case TitleData::ANIM:
    198247        tiler = data->anim[data->animid];
     248        pos = animpos[data->animid];
     249        pos.y = 384 - animsize[data->animid].y - pos.y; // Hack
    199250        id = data->nframes - 1 - (data->nframes * data->timer / data->length);
    200251        if (id < 0) id = 0;
     
    203254    case TitleData::EVENT:
    204255        tiler = data->event[data->animid];
     256        pos = eventpos[data->animid];
     257        pos.y = 384 - eventsize[data->animid].y - pos.y; // Hack
    205258        id = data->nframes - 1 - (data->nframes * data->timer / data->length);
    206259        if (id < 0) id = 0;
     
    208261        break;
    209262    }
    210 
    211     Scene::GetDefault()->AddTile((tiler << 16) | id, 24, 72, 1, 0);
     263    if (tiler)
     264        Scene::GetDefault()->AddTile((tiler << 16) | id, 24 + pos.x, 72 + pos.y, 1, 0);
     265
     266    /* The logo, on top of the rest. */
    212267    Scene::GetDefault()->AddTile((data->logo << 16) | 0, 26, 250, 2, 0);
    213268}
Note: See TracChangeset for help on using the changeset viewer.