12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- #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, Vertex &speed, float &rot, Vertex &hp ) const
- {
- if( mdl.istPunktInnen( pos ) )
- {
- if( mdl.zModel()->calcHitPoint( ( ( pos - this->speed / 10 ) - mdl.getPosition() ).rotation( -mdl.getDrehung() ) / mdl.getSize(), Vertex( this->speed / 10 ).rotation( -mdl.getDrehung() ), "", hp, speed, rot ) )
- {
- speed = speed.rotation( mdl.getDrehung() );
- return 1;
- }
- }
- return 0;
- }
- 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;
- }
|