Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 3, 2013, 8:18:15 PM (12 years ago)
Author:
zifloria
Message:

End game screen. Eye candy. Gameplay tweaks

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/invaders/src/modules/invader/Invader.cc

    r9866 r9868  
    5959        RegisterObject(Invader);
    6060        this->center_ = 0;
     61        init();
     62        this->setHUDTemplate("InvaderHUD");
     63    }
    6164
    62         this->console_addEnemy = createConsoleCommand( "spawnEnemy", createExecutor( createFunctor(&Invader::spawnEnemy, this) ) );
    63         //this->context = context;
    64         this->setHUDTemplate("InvaderHUD");
    65 
     65    void Invader::init()
     66    {
     67        bEndGame = false;
    6668        lives = 3;
     69        // TODO:
    6770        level = 1;
    6871        point = 0;
    6972        multiplier = 1;
    7073        b_combo = false;
     74        // spawn enemy every 2 seconds
    7175        enemySpawnTimer.setTimer(2.0f, true, createExecutor(createFunctor(&Invader::spawnEnemy, this)));
    7276        comboTimer.setTimer(2.5f, true, createExecutor(createFunctor(&Invader::comboControll, this)));
    73     }
    74 
    75     Invader::~Invader()
    76     {
    7777    }
    7878
     
    9494            newPawn->setPlayer(player);
    9595            newPawn->level = level;
     96            // spawn enemy at random points in front of player.
    9697            newPawn->setPosition(player->getPosition() + Vector3(500 + 100 * i, 0, float(rand())/RAND_MAX * 400 - 200));
    9798        }
     
    101102    {
    102103        lives--;
    103         multiplier = 0;
    104         if (lives <= 0) end();
     104        multiplier = 1;
     105        // end the game in 30 seconds.
     106        if (lives <= 0)
     107            enemySpawnTimer.setTimer(30.0f, false, createExecutor(createFunctor(&Invader::end, this)));
    105108    };
    106109
     
    109112        if (b_combo)
    110113            multiplier++;
     114        // if no combo was performed before, reset multiplier
    111115        else
    112116            multiplier = 1;
     
    114118    }
    115119
    116     // inject custom player controller
    117  /**   void Invader::spawnPlayer(PlayerInfo* player)
    118     {
    119         assert(player);
    120 
    121         //player->startControl(new InvaderShip(this->center_->getContext() ) );
    122     }*/
    123 
    124120    void Invader::start()
    125121    {
     122        init();
    126123        // Set variable to temporarily force the player to spawn.
    127124        this->bForceSpawn_ = true;
     
    137134    }
    138135
     136
    139137    void Invader::end()
    140138    {
    141         orxout() << "STOP THE GAME, CHEATER!!!" << endl;
    142         // Call end for the parent class.
    143         // Deathmatch::end();
     139        // DON'T CALL THIS!
     140        //      Deathmatch::end();
     141        // It will misteriously crash the game!
     142        // Instead startMainMenu, this won't crash.
     143        GSLevel::startMainMenu();
    144144    }
    145145}
Note: See TracChangeset for help on using the changeset viewer.