Schuss.cpp 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. #include "Schuss.h"
  2. // Inhalt der Schuss Klasse aus Schuss.h
  3. // Konstruktor
  4. Schuss::Schuss( Vec2< float > pos, Vec2< float > speed )
  5. : Object2D()
  6. {
  7. setPosition( pos );
  8. setSpeed( speed );
  9. ref = 1;
  10. }
  11. // nicht constant
  12. void Schuss::render( Mat3< float > &kamMat, Bild &zRObj, const char *kamName )
  13. {
  14. zRObj.drawLinie( (Punkt)(kamMat * position), (Punkt)( kamMat * (position - speed / 10) ), 0xFFFFFFFF );
  15. }
  16. // constant
  17. Rect2< float > Schuss::getBoundingBox() const
  18. {
  19. auto rect = Rect2< float >();
  20. rect.topLeft.x = min( position.x, ( position - this->speed / 10 ).x );
  21. rect.topLeft.y = min( position.y, ( position - this->speed / 10 ).y );
  22. rect.bottomRight.x = max( position.x, ( position - this->speed / 10 ).x );
  23. rect.bottomRight.y = max( position.y, ( position - this->speed / 10 ).y );
  24. return rect;
  25. }
  26. void Schuss::save( Datei *zD ) const
  27. {
  28. zD->schreibe( (char*)&position.x, 4 );
  29. zD->schreibe( (char*)&position.y, 4 );
  30. zD->schreibe( (char*)&speed.x, 4 );
  31. zD->schreibe( (char*)&speed.y, 4 );
  32. }