예제 #1
0
int main()
{
//define this to send output to a text file (see locations.h)
#ifdef TEXTOUTPUT
  os.open("output.txt");
#endif

  //create a miner
  Miner Bob(ent_Miner_Bob);

  //create his wife
  MinersWife Elsa(ent_Elsa);

  Kitty Kitty(ent_cute_kitty);

  //run Bob and Elsa through a few Update calls
  for (int i=0; i<200; ++i)
  { 
   // Bob.Update();
    //Elsa.Update();
	  Kitty.Update();
    Sleep(800);
  }

  //wait for a keypress before exiting
  PressAnyKeyToContinue();

  return 0;
}
예제 #2
0
/**
 *
 *
 *  @author siegi44
 */
void dskCredits::Msg_PaintAfter()
{
    unsigned int time = VIDEODRIVER.GetTickCount() - startTime;

    if (time > PAGE_TIME)
    {
        ++this->itCurEntry;
        if (this->itCurEntry == entries.end())
            this->itCurEntry = entries.begin();
        this->startTime = VIDEODRIVER.GetTickCount();
    }

    // Frameratebegrenzer
    int bob_time = VIDEODRIVER.GetTickCount() - bobTime;
    int bob_prosec = 25;

    int bob_spawntime = VIDEODRIVER.GetTickCount() - bobSpawnTime;
    int bob_spawnprosec = 5;

    if(GAMEMANAGER.GetFPS() < 30)
        bob_spawnprosec = 0;
    else if(GAMEMANAGER.GetFPS() < 60)
        bob_spawnprosec = 1;
    else if(GAMEMANAGER.GetFPS() < 200)
        bob_spawnprosec = 2;

    // add new bob
    if ( bob_spawnprosec > 0 && bob_spawntime > (1000 / bob_spawnprosec) && (int)bobs.size() < (int)(50 + VIDEODRIVER.GetScreenWidth() / 2))
    {
        bobSpawnTime = VIDEODRIVER.GetTickCount();

        Bob b = Bob();
        b.animationStep = 0;
        b.speed = 1 + rand() % 4;

        // links oder rechts spawnen
        if(rand() % 2 == 0)
        {
            b.x = 0;
            b.direction = 3;
        }
        else
        {
            b.x = VIDEODRIVER.GetScreenWidth();
            b.direction = 6;
        }

        b.color = COLORS[rand() % PLAYER_COLORS_COUNT];
        unsigned int job = rand() % 29;

        // exclude "headless" bobs
        if (job == 8 || job == 9 || job == 12 || job == 18)
        {
            job = rand() % (WARE_TYPES_COUNT - 1);
            b.hasWare = true;
        }
        else
        {
            if(job == JOB_SCOUT)
                job = 35 + NATION_RTTR_TO_S2[rand() % 4] * 6;
            else if(job >= JOB_PRIVATE && job <= JOB_GENERAL)
                job = 30 + NATION_RTTR_TO_S2[rand() % 4] * 6 + job - JOB_PRIVATE;
            else
                job = JOB_CONSTS[job].jobs_bob_id;
            b.hasWare = false;
        }

        b.id = job;
        b.y = GetCtrl<ctrlButton>(0)->GetY() - 20 - rand() % 150;
        bobs.push_back(b);
    }

    // draw bobs
    for (std::list<Bob>::iterator bob = bobs.begin(); bob != bobs.end(); ++bob)
    {
        if (!bob->hasWare)
            LOADER.GetBobN("jobs")->Draw(bob->id, bob->direction, bob->isFat, bob->animationStep, bob->x, bob->y, bob->color);
        else
            LOADER.GetBobN("carrier")->Draw(bob->id, bob->direction, bob->isFat, bob->animationStep, bob->x, bob->y, bob->color);

        if( bob_time > (1000 / bob_prosec) )
        {
            bobTime = VIDEODRIVER.GetTickCount();

            bob->animationStep++;
            if (bob->animationStep > 7)
                bob->animationStep = 0;
            if (bob->direction == 3)
            {
                bob->x += bob->speed;
                if (bob->x > VIDEODRIVER.GetScreenWidth())
                    bob->direction = 6;
            }
            else if (bob->direction == 6)
            {
                bob->x -= bob->speed;
                if (bob->x < 0)
                    bob->direction = 3;
            }
        }
    }

    // Frameratebegrenzer aktualisieren
    if( bob_time > (1000 / bob_prosec) )
        bobTime = VIDEODRIVER.GetTickCount();

    // calculate text transparency
    unsigned transparency = 0xFF;

    if(time < FADING_TIME)
        transparency = 0xFF * time / FADING_TIME;
    if (time > PAGE_TIME - FADING_TIME)
        transparency = (0xFF - 0xFF * (time - (PAGE_TIME - FADING_TIME)) / FADING_TIME);

    if (time > PAGE_TIME)
        transparency = 0;

    transparency = transparency << 24;

    // draw text
    LargeFont->Draw(40, 100, itCurEntry->title, 0, (COLOR_RED & 0x00FFFFFF) | transparency);

    boost::array<unsigned int, 2> columnToY = {{150, 150}};

    for(std::list<CreditsEntry::Line>::iterator line = this->itCurEntry->lines.begin(); line != itCurEntry->lines.end(); ++line)
    {
        LargeFont->Draw(60 + line->column * 350, columnToY[line->column], line->line.c_str(), 0, (COLOR_YELLOW & 0x00FFFFFF) | transparency);
        columnToY[line->column] += LargeFont->getHeight() + 5;
    }

    LargeFont->Draw(40, columnToY[0] + 20, itCurEntry->lastLine, 0, (COLOR_RED & 0x00FFFFFF) | transparency);

    // draw picture
    glArchivItem_Bitmap* item = LOADER.GetImageN("credits", itCurEntry->picId);

    if (item)
        item->Draw(VIDEODRIVER.GetScreenWidth() - 300, 70, 0, 0, 0, 0, 0, 0, (COLOR_WHITE & 0x00FFFFFF) | transparency);
}