Changeset 424


Ignore:
Timestamp:
Feb 7, 2011, 10:29:35 PM (10 years ago)
Author:
sam
Message:

Add the eagle animation.

Location:
trunk/monsterz
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/monsterz/Makefile.am

    r383 r424  
    1717      gfx/titleevent0.png gfx/titleevent1.png gfx/titleevent2.png \
    1818      gfx/titleevent3.png gfx/titleevent4.png gfx/titleevent5.png \
    19       gfx/titleevent6.png
     19      gfx/titleevent6.png gfx/titleclouds.png gfx/titlestars.png \
     20      gfx/titleeagle.png
    2021WAV = sound/applause.wav sound/boing.wav sound/click.wav sound/ding.wav \
    2122      sound/duh.wav sound/grunt.wav sound/laugh.wav sound/pop.wav \
  • trunk/monsterz/monsterz.h

    r422 r424  
    2121static char const * const PNG_CLOUDS = "monsterz/gfx/titleclouds.png";
    2222static char const * const PNG_STARS = "monsterz/gfx/titlestars.png";
     23static char const * const PNG_EAGLE = "monsterz/gfx/titleeagle.png";
    2324static char const * const PNG_TITLEANIM[] =
    2425{
     
    5152static int const MAX_PIECES = 12;
    5253
     54/* Duration of an eagle flight */
     55static int const DURATION_EAGLE = 3000;
     56
    5357/* Minimal duration of the idle loop */
    5458static int const DELAY_IDLE = 300;
  • trunk/monsterz/title.cpp

    r422 r424  
    3131
    3232private:
    33     int title, stars, clouds, logo;
     33    int title, stars, clouds, eagle, logo;
    3434    int anim[6];
    3535    int event[7];
     
    5555    float2 cloudspeed[5];
    5656
    57     float timer, length;
     57    int eagley;
     58
     59    float timer, length, eagletimer;
    5860    int nframes, animid;
    5961};
     
    114116    data->stars = Tiler::Register(PNG_STARS, 384, 144, 1.0f);
    115117    data->clouds = Tiler::Register(PNG_CLOUDS, 160, 32, 1.0f);
     118    data->eagle = Tiler::Register(PNG_EAGLE, 16, 16, 1.0f);
    116119    for (int n = 0; n < 6; n++)
    117120        data->anim[n] = Tiler::Register(PNG_TITLEANIM[n],
     
    124127    data->nextperiod = TitleData::DAY;
    125128    data->timer = RandF(2000.0f, 3000.0f);
     129    data->eagletimer = RandF(DURATION_EAGLE, 4 * DURATION_EAGLE);
    126130
    127131    for (int n = 0; n < 5; n++)
     
    130134        data->cloudspeed[n] = RandF(-0.01f, 0.01f);
    131135    }
     136
     137    data->eagley = 140 + rand() % 40;
    132138
    133139    position = int3(24, 72, 1);
     
    143149
    144150    data->timer -= deltams;
     151    data->eagletimer -= deltams;
    145152
    146153    /* Probability of playing an animation given the current period */
     
    164171    {
    165172    case TitleData::IDLE:
     173        if (data->eagletimer < 0.0f)
     174        {
     175            data->eagletimer = RandF(DURATION_EAGLE, 4 * DURATION_EAGLE);
     176            data->eagley = 140 + rand() % 40;
     177        }
    166178        if (data->timer > 0.0f)
    167179            break;
     
    276288    }
    277289
     290    /* Maybe an eagle? */
     291    if (data->eagletimer >= 0.0f)
     292    {
     293        int eagleid = (int)(data->eagletimer / 100) % 6;
     294        if (data->period != TitleData::DAY)
     295            eagleid += 6;
     296        float phase = sinf(data->eagletimer * (2.0f * M_PI / 100 / 6));
     297        int x = (DURATION_EAGLE - data->eagletimer) * 384 / DURATION_EAGLE;
     298        int y = data->eagley + 5.0f * sinf(phase);
     299        Scene::GetDefault()->AddTile((data->eagle << 16) | eagleid,
     300                                     24 + x, 72 + y, 3, 0);
     301    }
     302
    278303    /* Maybe an animation? */
    279304    int tiler = 0;
     
    321346    Tiler::Deregister(data->stars);
    322347    Tiler::Deregister(data->clouds);
     348    Tiler::Deregister(data->eagle);
    323349    for (int n = 0; n < 6; n++)
    324350        Tiler::Deregister(data->anim[n]);
Note: See TracChangeset for help on using the changeset viewer.