#include "Schuss.h" // Inhalt der Schuss Klasse aus Schuss.h // Konstruktor Schuss::Schuss( Vec2< float > pos, Vec2< float > speed ) { this->pos = pos; this->speed = speed; ref = 1; } // nicht constant bool Schuss::tick( double zeit ) { pos += speed * (float)zeit; return 1; } void Schuss::render( Bild &zRObj ) { zRObj.drawLinie( (Punkt)pos, (Punkt)( pos - speed / 10 ), 0xFFFFFFFF ); } // constant bool Schuss::istInM2( const Model2D &mdl ) const { return mdl.istPunktInnen( pos ) || mdl.istPunktInnen( pos - speed / 10 ); } void Schuss::save( Datei *zD ) const { zD->schreibe( (char*)&pos.x, 4 ); zD->schreibe( (char*)&pos.y, 4 ); zD->schreibe( (char*)&speed.x, 4 ); zD->schreibe( (char*)&speed.y, 4 ); } Vec2< float > Schuss::getPos() const { return pos; } // Reference Counting Schuss *Schuss::getThis() { ref++; return this; } Schuss *Schuss::release() { ref--; if( !ref ) delete this; return 0; }