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

core: tick methods now use seconds, like any sane system.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/mrpigeon/mrpigeon.cpp

    r1300 r1310  
    5656}
    5757
    58 void MrPigeon::TickGame(float deltams)
     58void MrPigeon::TickGame(float seconds)
    5959{
    60     WorldEntity::TickGame(deltams);
     60    WorldEntity::TickGame(seconds);
    6161
    62     totaltime += deltams;
     62    totaltime += seconds;
    6363
    64     if (totaltime > 100000.0f)
     64    if (totaltime > 100.0f)
    6565    {
    6666        speed = 1.8f;
     
    6868        active_deco_width = 192;
    6969    }
    70     else if (totaltime > 49000.0f)
     70    else if (totaltime > 49.0f)
    7171    {
    7272        speed = 1.5f;
     
    7474        active_deco_width = 288;
    7575    }
    76     else if (totaltime > 18000.0f)
     76    else if (totaltime > 18.0f)
    7777    {
    7878        speed = 1.2f;
     
    8787    }
    8888
    89     deltams *= GetSpeed();
     89    seconds *= GetSpeed();
    9090
    9191    /* Delete enemies that went past us */
     
    100100
    101101    /* Spawn enemies if necessary */
    102     spawntime += deltams;
    103     if (spawntime > 600.0f)
     102    spawntime += seconds;
     103    if (spawntime > .6f)
    104104    {
    105105        if (RandF(1.0f) < 0.2f)
    106             spawntime -= 300.0f;
    107         spawntime -= 600.0f;
     106            spawntime -= .3f;
     107        spawntime -= .6f;
    108108        for (int i = 0; i < 10; i++)
    109109        {
     
    112112                if (RandF(1.0f) < 0.4f)
    113113                    enemies[i] = new BlueEnemy(this);
    114                 else if (totaltime > 9000.0f && RandF(1.0f) < 0.3f)
     114                else if (totaltime > 9.0f && RandF(1.0f) < 0.3f)
    115115                    enemies[i] = new RedEnemy(this);
    116116
     
    123123
    124124    /* Scroll background etc. */
    125     railtime = fmod(railtime + deltams, 1000.0f);;
    126     backtime = fmod(backtime + deltams, 10000.0f / 288 * active_deco_width);;
     125    railtime = fmod(railtime + seconds, 1.0f);;
     126    backtime = fmod(backtime + seconds, 10.0f / 288 * active_deco_width);;
    127127
    128128    ivec3 buttons = Input::GetMouseButtons();
     
    140140}
    141141
    142 void MrPigeon::TickDraw(float deltams)
     142void MrPigeon::TickDraw(float seconds)
    143143{
    144     WorldEntity::TickDraw(deltams);
     144    WorldEntity::TickDraw(seconds);
    145145
    146146    Video::SetClearColor(vec4(0.0f, 0.0f, 0.0f, 1.0f));
     
    148148    Scene::GetDefault()->AddTile(hud_progress, 0, ivec3(18, 3, 0), 0, vec2(3.0f));
    149149
    150     int n = (int)(totaltime * 372 / 156000.0f);
     150    int n = (int)(totaltime * 372 / 156.0f);
    151151    if (n > 372)
    152152        n = 372;
    153153    Scene::GetDefault()->AddTile(hud_arrow, 0, ivec3(48 + n, 18, 10), 0, vec2(3.0f));
    154154
    155     for (int i = -(int)(backtime * 288 / 5000.0f); i < 512 + active_deco_width; i += active_deco_width)
     155    for (int i = -(int)(backtime * 288 / 5.0f); i < 512 + active_deco_width; i += active_deco_width)
    156156        Scene::GetDefault()->AddTile(active_deco, 0, ivec3(i, 300, 0), 0, vec2(1.0f));
    157157
    158     for (int i = -(int)(railtime * 72 / 1000.0f); i < 512 + 72; i += 72)
     158    for (int i = -(int)(railtime * 72 / 1.0f); i < 512 + 72; i += 72)
    159159        Scene::GetDefault()->AddTile(deco_floorrails, 0, ivec3(i, 57, 0), 0, vec2(1.0f));
    160160}
Note: See TracChangeset for help on using the changeset viewer.