1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- #include "Umlenkung.h"
- Umlenkung::Umlenkung( int id, int x, int y, int breite, int height, Richtung richtung, int maxAbklingzeit, bool drehend, bool aktiv )
- : GameObject( x, y, breite, height )
- {
- this->id = id;
- this->richtung = richtung;
- this->maxAbklingzeit = maxAbklingzeit;
- this->drehend = drehend;
- this->aktiv = aktiv;
- benutzt = 0;
- abklingzeitVerbleibend = 0;
- }
- void Umlenkung::setMaxAbklingzeit( int sekunden )
- {
- this->maxAbklingzeit = sekunden;
- }
- void Umlenkung::setAktiv( bool aktiv )
- {
- this->aktiv = aktiv;
- }
- void Umlenkung::setDrehend( bool drehend )
- {
- this->drehend = drehend;
- }
- void Umlenkung::setRichtung( Richtung r )
- {
- this->richtung = r;
- }
- void Umlenkung::addBenutzt()
- {
- benutzt++;
- if( drehend )
- {
- switch( richtung )
- {
- case OBEN:
- richtung = RECHTS;
- break;
- case RECHTS:
- richtung = UNTEN;
- break;
- case UNTEN:
- richtung = LINKS;
- break;
- case LINKS:
- richtung = OBEN;
- }
- }
- abklingzeitVerbleibend = maxAbklingzeit;
- }
- void Umlenkung::tick( double time )
- {
- if( abklingzeitVerbleibend > 0 )
- {
- abklingzeitVerbleibend -= time;
- if( abklingzeitVerbleibend < 0 )
- abklingzeitVerbleibend = 0;
- }
- }
- bool Umlenkung::isAktive() const
- {
- return aktiv;
- }
- bool Umlenkung::hatAbklingzeit() const
- {
- return abklingzeitVerbleibend > 0;
- }
- bool Umlenkung::istDrehend() const
- {
- return drehend;
- }
- int Umlenkung::getMaxAbklingzeit() const
- {
- return maxAbklingzeit;
- }
- Richtung Umlenkung::getRichtung() const
- {
- return richtung;
- }
|