Changeset 1200


Ignore:
Timestamp:
Apr 7, 2012, 11:55:36 PM (8 years ago)
Author:
sam
Message:

mrpigeon: implement a few animations for testing purposes.

Location:
trunk/mrpigeon
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/mrpigeon/mrpigeon.cpp

    r1198 r1200  
    2323MrPigeon::MrPigeon()
    2424{
    25     hudprogress = Tiler::Register("mrpigeon/gfx/HUD_timeline.png", ivec2(160,16), ivec2(0));
    26     hudarrow = Tiler::Register("mrpigeon/gfx/HUD_timelineArrow.png", ivec2(16,16), ivec2(0));
     25    hud_progress = Tiler::Register("mrpigeon/gfx/HUD_timeline.png", ivec2(160,16), ivec2(0));
     26    hud_arrow = Tiler::Register("mrpigeon/gfx/HUD_timelineArrow.png", ivec2(16,16), ivec2(0));
     27
     28    deco_campagneback = Tiler::Register("mrpigeon/gfx/DECO_campagneBack.png", ivec2(144,168), ivec2(0));
     29    deco_cityback = Tiler::Register("mrpigeon/gfx/DECO_cityBack3x.png", ivec2(96,96), ivec2(0));
     30    deco_citybackdefense = Tiler::Register("mrpigeon/gfx/DECO_cityBackDefense3X.png", ivec2(288,96), ivec2(0));
     31    deco_citybackpav = Tiler::Register("mrpigeon/gfx/DECO_cityBackPav3X.png", ivec2(192,96), ivec2(0));
     32    deco_floorrails = Tiler::Register("mrpigeon/gfx/DECO_floorRails3x.png", ivec2(72,24), ivec2(0));
     33
     34    pigeon_flying = Tiler::Register("mrpigeon/gfx/pigeon_flying.png", ivec2(16,16), ivec2(0)); /* 2 frames */
     35
     36    player_dashdown = Tiler::Register("mrpigeon/gfx/player_DashDown.png", ivec2(16,32), ivec2(0));
     37    player_death = Tiler::Register("mrpigeon/gfx/player_Fall.png", ivec2(16,32), ivec2(0));
     38    player_fall = Tiler::Register("mrpigeon/gfx/player_Jump.png", ivec2(16,32), ivec2(0));
     39    player_jump = Tiler::Register("mrpigeon/gfx/player_kickAir.png", ivec2(16,32), ivec2(0)); /* 3 frames */
     40    player_kickair = Tiler::Register("mrpigeon/gfx/player_kickFloor.png", ivec2(16,32), ivec2(0)); /* 6 frames */
     41    player_kickfloor = Tiler::Register("mrpigeon/gfx/player_WalkB.png", ivec2(16,32), ivec2(0)); /* 8 frames */
     42    player_walkb = Tiler::Register("mrpigeon/gfx/player_Walk.png", ivec2(16,32), ivec2(0)); /* 8 frames */
     43    player_walk = Tiler::Register("mrpigeon/gfx/player_WalkRaiseFist.png", ivec2(16,32), ivec2(0)); /* 8 frames */
     44    player_walkraisefist = Tiler::Register("mrpigeon/gfx/player_Death.png", ivec2(16,32), ivec2(0)); /* 7 frames */
     45
     46    totaltime = 0.0f;
     47    walktime = 0.0f;
     48    flytime = 0.0f;
     49    railtime = 0.0f;
     50    backtime = 0.0f;
    2751}
    2852
     
    3054{
    3155    WorldEntity::TickGame(deltams);
     56deltams *= 6.3478;
     57
     58    totaltime += deltams;
     59
     60    flytime += deltams;
     61    if (flytime > 400.0f)
     62        flytime -= 400.0f;
     63
     64    walktime += deltams;
     65    if (walktime > 700.0f)
     66        walktime -= 700.0f;
     67
     68    railtime += deltams;
     69    if (railtime > 1000.0f)
     70        railtime -= 1000.0f;
     71
     72    backtime += deltams;
     73    if (backtime > 5000.0f)
     74        backtime -= 5000.0f;
    3275}
    3376
     
    3679    WorldEntity::TickDraw(deltams);
    3780
    38     Scene::GetDefault()->AddTile(hudarrow, 0, ivec3(30, 8, 0), 0, vec2(3.0f));
    39     Scene::GetDefault()->AddTile(hudprogress, 0, ivec3(0, 0, 0), 0, vec2(3.0f));
     81    Video::SetClearColor(vec4(0.0f, 0.0f, 0.0f, 1.0f));
     82
     83    Scene::GetDefault()->AddTile(hud_progress, 0, ivec3(18, 3, 0), 0, vec2(3.0f));
     84
     85    int n = (int)(totaltime * 372 / 156000.0f);
     86    if (n > 372)
     87        n = 372;
     88    Scene::GetDefault()->AddTile(hud_arrow, 0, ivec3(48 + n, 18, 10), 0, vec2(3.0f));
     89
     90    for (int i = -(int)(backtime * 144 / 5000.0f); i < 512 + 144; i += 144)
     91        Scene::GetDefault()->AddTile(deco_campagneback, 0, ivec3(i, 288, 0), 0, vec2(1.0f));
     92    //for (int i = -(int)(backtime * 96 / 5000.0f); i < 512 + 96; i += 96)
     93    //    Scene::GetDefault()->AddTile(deco_cityback, 0, ivec3(i, 288, 0), 0, vec2(1.0f));
     94    //for (int i = -(int)(backtime * 288 / 5000.0f); i < 512 + 288; i += 288)
     95    //    Scene::GetDefault()->AddTile(deco_citybackdefense, 0, ivec3(i, 288, 0), 0, vec2(1.0f));
     96    //for (int i = -(int)(backtime * 192 / 5000.0f); i < 512 + 192; i += 192)
     97    //    Scene::GetDefault()->AddTile(deco_citybackpav, 0, ivec3(i, 288, 0), 0, vec2(1.0f));
     98
     99    for (int i = -(int)(railtime * 72 / 1000.0f); i < 512 + 72; i += 72)
     100        Scene::GetDefault()->AddTile(deco_floorrails, 0, ivec3(i, 57, 0), 0, vec2(1.0f));
     101
     102    Scene::GetDefault()->AddTile(pigeon_flying, (int)(flytime * 2 / 400.0f), ivec3(81, 147, 0), 0, vec2(3.0f));
     103
     104    Scene::GetDefault()->AddTile(player_walkb, (int)(walktime * 8 / 700.0f), ivec3(120, 81, 0), 0, vec2(3.0f));
    40105}
    41106
    42107MrPigeon::~MrPigeon()
    43108{
    44     Tiler::Deregister(hudprogress);
    45     Tiler::Deregister(hudarrow);
     109    Tiler::Deregister(hud_progress);
     110    Tiler::Deregister(hud_arrow);
     111
     112    Tiler::Deregister(deco_campagneback);
     113    Tiler::Deregister(deco_cityback);
     114    Tiler::Deregister(deco_citybackdefense);
     115    Tiler::Deregister(deco_citybackpav);
     116    Tiler::Deregister(deco_floorrails);
     117
     118    Tiler::Deregister(pigeon_flying);
     119
     120    Tiler::Deregister(player_dashdown);
     121    Tiler::Deregister(player_death);
     122    Tiler::Deregister(player_fall);
     123    Tiler::Deregister(player_jump);
     124    Tiler::Deregister(player_kickair);
     125    Tiler::Deregister(player_kickfloor);
     126    Tiler::Deregister(player_walkb);
     127    Tiler::Deregister(player_walk);
     128    Tiler::Deregister(player_walkraisefist);
    46129}
    47130
     
    49132{
    50133    Application app("MrPigeon", ivec2(512,384), 60.0f);
    51     new DebugFps(20, 20);
     134    new DebugFps(2, 370);
    52135    new MrPigeon();
    53136    app.ShowPointer(false);
  • trunk/mrpigeon/mrpigeon.h

    r1185 r1200  
    1616    virtual void TickDraw(float deltams);
    1717
    18     TileSet *hudprogress, *hudarrow;
     18    TileSet *hud_progress,
     19            *hud_arrow;
     20    TileSet *deco_campagneback,
     21            *deco_cityback,
     22            *deco_citybackdefense,
     23            *deco_citybackpav,
     24            *deco_floorrails;
     25    TileSet *pigeon_flying;
     26    TileSet *player_dashdown,
     27            *player_death,
     28            *player_fall,
     29            *player_jump,
     30            *player_kickair,
     31            *player_kickfloor,
     32            *player_walkb,
     33            *player_walk,
     34            *player_walkraisefist;
     35
     36    double totaltime;
     37    float walktime, flytime, railtime, backtime;
    1938};
    2039
Note: See TracChangeset for help on using the changeset viewer.