123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- #include "Geschoss.h"
- Geschoss::Geschoss( int id, float speed, GeschossTyp typ, Richtung r, int x, int y, Spieler *besitzer )
- : GameObject( GESCHOSS, x, y, 20, 20 )
- {
- if( typ == GESCHOSS_PFEIL )
- {
- if( r == OBEN || r == UNTEN )
- setHeight( 50 );
- else
- setWidth( 50 );
- }
- this->speed = speed;
- this->richtung = richtung;
- this->besitzer = besitzer;
- this->typ = typ;
- tunnelBenutzt = 0;
- umgelenkt = 0;
- geschosseGetroffen = 0;
- schalter = 0;
- this->id = id;
- }
- Geschoss::~Geschoss()
- {
- if( besitzer )
- besitzer->release();
- }
- void Geschoss::invertDirection()
- {
- if( richtung == OBEN )
- richtung = UNTEN;
- else if( richtung == RECHTS )
- richtung = LINKS;
- else if( richtung == UNTEN )
- richtung = OBEN;
- else if( richtung == LINKS )
- richtung = RECHTS;
- }
- void Geschoss::addUmlenkung()
- {
- umgelenkt++;
- }
- void Geschoss::addGeschossTreffer()
- {
- geschosseGetroffen++;
- }
- void Geschoss::addTunnel()
- {
- schalter++;
- }
- void Geschoss::addSchalter()
- {
- id++;
- }
- void Geschoss::setRichtung( Richtung r )
- {
- richtung = r;
- }
- void Geschoss::tick( double zeit )
- {
- switch( richtung )
- {
- case OBEN:
- y -= zeit * speed;
- break;
- case UNTEN:
- y += zeit * speed;
- break;
- case RECHTS:
- x += zeit * speed;
- break;
- case LINKS:
- x -= zeit * speed;
- break;
- }
- }
- GeschossTyp Geschoss::getTyp() const
- {
- return typ;
- }
- Spieler *Geschoss::zBesitzer() const
- {
- return besitzer;
- }
- Spieler *Geschoss::getBesitzer() const
- {
- return besitzer ? (Spieler *)besitzer->getThis() : 0;
- }
|