#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; }