Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2D.cc @ 11593

Last change on this file since 11593 was 11593, checked in by vyang, 8 years ago

MiniGameTest Minigame erstellt → Kopie von DodgeRace, Namen von Asteroid zu Asteroid 2D geaendert, da schon eine Klasse mit dem selben Namen existiert

File size: 2.5 KB
RevLine 
[11593]1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *                    > www.orxonox.net <
4 *
5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
11 *   of the License, or (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
22 *   Author:
23 *      Florian Zinggeler
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29/**
30    @file Asteroids2D.cc
31    @brief Implementation of the Asteroids2D class.
32*/
33
34#include "Asteroids2D.h"
35#include "Asteroids2DShip.h" // Necessary for getPlayer function. Do NOT include this in Header!
36#include "core/CoreIncludes.h"
37
38
39namespace orxonox
40{
41    RegisterUnloadableClass(Asteroids2D);
42
43    Asteroids2D::Asteroids2D(Context* context) : Deathmatch(context)
44    {
45        RegisterObject(Asteroids2D);
46        this->bEndGame = false;
47
48    }
49
50    void Asteroids2D::tick(float dt)
51    {
52
53        SUPER(Asteroids2D, tick, dt);
54    }
55
56    Asteroids2DShip* Asteroids2D::getPlayer()
57    {
58        if (player == nullptr)
59        {
60            for (Asteroids2DShip* ship : ObjectList<Asteroids2DShip>())
61            {
62                player = ship;
63            }
64        }
65        return player;
66    }
67
68    void Asteroids2D::start()
69    {
70        orxout() << "start" << endl;
71       
72        // Set variable to temporarily force the player to spawn.
73        this->bForceSpawn_ = false;
74
75        if (this->center_ == nullptr)  // abandon mission!
76        {
77            orxout(internal_error) << "Asteroids2D: No Centerpoint specified." << endl;
78            GSLevel::startMainMenu();
79            return;
80        }
81        // Call start for the parent class.
82        Deathmatch::start();
83    }
84
85    void Asteroids2D::end()
86    {
87        // DON'T CALL THIS!
88        //      Deathmatch::end();
89        // It will misteriously crash the game!
90        // Instead startMainMenu, this won't crash.
91        orxout() << "Asteroids2D Game has ended" << endl;
92        GSLevel::startMainMenu();
93    }
94}
Note: See TracBrowser for help on using the repository browser.