|
@@ -10,58 +10,58 @@
|
|
|
|
|
|
// Inhalt der Ship Klasse aus Ship.h
|
|
// Inhalt der Ship Klasse aus Ship.h
|
|
// Konstruktor
|
|
// Konstruktor
|
|
-Ship::Ship( Model2DData *data, Vec2< float > p, Vec2< float > s, float r )
|
|
|
|
|
|
+Ship::Ship( Model2DData* data, Vec2< float > p, Vec2< float > s, float r )
|
|
: Model2DObject()
|
|
: Model2DObject()
|
|
{
|
|
{
|
|
- for( auto i = data->polygons->getIterator(); i; i++ )
|
|
|
|
|
|
+ for( const Polygon2D& i : *data->polygons )
|
|
{
|
|
{
|
|
- if( i._.name->istGleich( "engine_l" ) )
|
|
|
|
|
|
+ if( i.name->istGleich( "engine_l" ) )
|
|
{
|
|
{
|
|
- stL = *i._.schwerpunkt;
|
|
|
|
|
|
+ stL = *i.schwerpunkt;
|
|
Vertex l, r;
|
|
Vertex l, r;
|
|
for( int j = 0; j < 4; j++ )
|
|
for( int j = 0; j < 4; j++ )
|
|
{
|
|
{
|
|
- if( i._.tKordinaten->get( j ).y == 1.f )
|
|
|
|
|
|
+ if( i.tKordinaten->get( j ).y == 1.f )
|
|
{
|
|
{
|
|
- if( i._.tKordinaten->get( j ).x == 0.f )
|
|
|
|
- l = i._.vertex->get( j );
|
|
|
|
- if( i._.tKordinaten->get( j ).x == 1.f )
|
|
|
|
- r = i._.vertex->get( j );
|
|
|
|
|
|
+ if( i.tKordinaten->get( j ).x == 0.f )
|
|
|
|
+ l = i.vertex->get( j );
|
|
|
|
+ if( i.tKordinaten->get( j ).x == 1.f )
|
|
|
|
+ r = i.vertex->get( j );
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- kL = ( ( l + ( r - l ) * 0.5 ) - stL );
|
|
|
|
|
|
+ kL = ((l + (r - l) * 0.5) - stL);
|
|
}
|
|
}
|
|
- if( i._.name->istGleich( "engine_r" ) )
|
|
|
|
|
|
+ if( i.name->istGleich( "engine_r" ) )
|
|
{
|
|
{
|
|
- stR = *i._.schwerpunkt;
|
|
|
|
|
|
+ stR = *i.schwerpunkt;
|
|
Vertex l, r;
|
|
Vertex l, r;
|
|
for( int j = 0; j < 4; j++ )
|
|
for( int j = 0; j < 4; j++ )
|
|
{
|
|
{
|
|
- if( i._.tKordinaten->get( j ).y == 1.f )
|
|
|
|
|
|
+ if( i.tKordinaten->get( j ).y == 1.f )
|
|
{
|
|
{
|
|
- if( i._.tKordinaten->get( j ).x == 0.f )
|
|
|
|
- l = i._.vertex->get( j );
|
|
|
|
- if( i._.tKordinaten->get( j ).x == 1.f )
|
|
|
|
- r = i._.vertex->get( j );
|
|
|
|
|
|
+ if( i.tKordinaten->get( j ).x == 0.f )
|
|
|
|
+ l = i.vertex->get( j );
|
|
|
|
+ if( i.tKordinaten->get( j ).x == 1.f )
|
|
|
|
+ r = i.vertex->get( j );
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- kR = ( ( l + ( r - l ) * 0.5 ) - stR );
|
|
|
|
|
|
+ kR = ((l + (r - l) * 0.5) - stR);
|
|
}
|
|
}
|
|
- if( i._.name->istGleich( "engine_m" ) )
|
|
|
|
|
|
+ if( i.name->istGleich( "engine_m" ) )
|
|
{
|
|
{
|
|
- stM = *i._.schwerpunkt;
|
|
|
|
|
|
+ stM = *i.schwerpunkt;
|
|
Vertex l, r;
|
|
Vertex l, r;
|
|
for( int j = 0; j < 4; j++ )
|
|
for( int j = 0; j < 4; j++ )
|
|
{
|
|
{
|
|
- if( i._.tKordinaten->get( j ).y == 1.f )
|
|
|
|
|
|
+ if( i.tKordinaten->get( j ).y == 1.f )
|
|
{
|
|
{
|
|
- if( i._.tKordinaten->get( j ).x == 0.f )
|
|
|
|
- l = i._.vertex->get( j );
|
|
|
|
- if( i._.tKordinaten->get( j ).x == 1.f )
|
|
|
|
- r = i._.vertex->get( j );
|
|
|
|
|
|
+ if( i.tKordinaten->get( j ).x == 0.f )
|
|
|
|
+ l = i.vertex->get( j );
|
|
|
|
+ if( i.tKordinaten->get( j ).x == 1.f )
|
|
|
|
+ r = i.vertex->get( j );
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- kM = ( ( l + ( r - l ) * 0.5 ) - stM );
|
|
|
|
|
|
+ kM = ((l + (r - l) * 0.5) - stM);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
rSpeed = 0;
|
|
rSpeed = 0;
|
|
@@ -79,7 +79,7 @@ Ship::~Ship()
|
|
#define sgn( x ) x < 0 ? -1 : 1
|
|
#define sgn( x ) x < 0 ? -1 : 1
|
|
|
|
|
|
// nicht constant
|
|
// nicht constant
|
|
-bool Ship::istGetroffen( Schuss *zSchuss )
|
|
|
|
|
|
+bool Ship::istGetroffen( Schuss* zSchuss )
|
|
{
|
|
{
|
|
if( getMasse() < 40 * 40 )
|
|
if( getMasse() < 40 * 40 )
|
|
return 0;
|
|
return 0;
|
|
@@ -91,14 +91,14 @@ bool Ship::istGetroffen( Schuss *zSchuss )
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
|
|
-void Ship::setTexture( Textur2D *zFlammenM, Textur2D *zFlammenL, Textur2D *zFlammenR, Bild *textur )
|
|
|
|
|
|
+void Ship::setTexture( Textur2D* zFlammenM, Textur2D* zFlammenL, Textur2D* zFlammenR, Bild* textur )
|
|
{
|
|
{
|
|
- Textur2D *txt = new Textur2D();
|
|
|
|
|
|
+ Textur2D* txt = new Textur2D();
|
|
txt->setTexturZ( textur );
|
|
txt->setTexturZ( textur );
|
|
setTextur( txt, "ship" );
|
|
setTextur( txt, "ship" );
|
|
- setTextur( dynamic_cast<Textur2D *>( zFlammenL->getThis() ), "engine_l" );
|
|
|
|
- setTextur( dynamic_cast<Textur2D *>( zFlammenR->getThis() ), "engine_r" );
|
|
|
|
- setTextur( dynamic_cast<Textur2D *>( zFlammenM->getThis() ), "engine_m" );
|
|
|
|
|
|
+ setTextur( dynamic_cast<Textur2D*>(zFlammenL->getThis()), "engine_l" );
|
|
|
|
+ setTextur( dynamic_cast<Textur2D*>(zFlammenR->getThis()), "engine_r" );
|
|
|
|
+ setTextur( dynamic_cast<Textur2D*>(zFlammenM->getThis()), "engine_m" );
|
|
}
|
|
}
|
|
|
|
|
|
void Ship::setPRS( Vec2< float > p, Vec2< float > s, float r, float rSpeed )
|
|
void Ship::setPRS( Vec2< float > p, Vec2< float > s, float r, float rSpeed )
|
|
@@ -114,19 +114,19 @@ void Ship::setTastenst
|
|
tastenstände = ts;
|
|
tastenstände = ts;
|
|
}
|
|
}
|
|
|
|
|
|
-bool Ship::tick( const WeltInfo &info, double zeit )
|
|
|
|
|
|
+bool Ship::tick( const WeltInfo& info, double zeit )
|
|
{
|
|
{
|
|
- if( ( tastenstände | 1 ) == tastenstände )
|
|
|
|
|
|
+ if( (tastenstände | 1) == tastenstände )
|
|
{
|
|
{
|
|
impuls( getWorldPos( stM ), getWorldDir( kM ) * (float)zeit * 10 );
|
|
impuls( getWorldPos( stM ), getWorldDir( kM ) * (float)zeit * 10 );
|
|
}
|
|
}
|
|
- if( ( tastenstände | 2 ) == tastenstände )
|
|
|
|
|
|
+ if( (tastenstände | 2) == tastenstände )
|
|
{
|
|
{
|
|
- impuls( getWorldPos( stL ), getWorldDir( kL ) * ( (float)zeit * 10 ) );
|
|
|
|
|
|
+ impuls( getWorldPos( stL ), getWorldDir( kL ) * ((float)zeit * 10) );
|
|
}
|
|
}
|
|
- if( ( tastenstände | 4 ) == tastenstände )
|
|
|
|
|
|
+ if( (tastenstände | 4) == tastenstände )
|
|
{
|
|
{
|
|
- impuls( getWorldPos( stR ), getWorldDir( kR ) * ( (float)zeit * 10 ) );
|
|
|
|
|
|
+ impuls( getWorldPos( stR ), getWorldDir( kR ) * ((float)zeit * 10) );
|
|
}
|
|
}
|
|
speed /= 1.01f;
|
|
speed /= 1.01f;
|
|
rSpeed /= 1.01f;
|
|
rSpeed /= 1.01f;
|
|
@@ -134,18 +134,18 @@ bool Ship::tick( const WeltInfo &info, double zeit )
|
|
}
|
|
}
|
|
|
|
|
|
// constant
|
|
// constant
|
|
-void Ship::save( Datei *zD ) const
|
|
|
|
|
|
+void Ship::save( Datei* zD ) const
|
|
{
|
|
{
|
|
- zD->schreibe( (char *)&position.x, 4 );
|
|
|
|
- zD->schreibe( (char *)&position.y, 4 );
|
|
|
|
- zD->schreibe( (char *)&speed.x, 4 );
|
|
|
|
- zD->schreibe( (char *)&speed.y, 4 );
|
|
|
|
|
|
+ zD->schreibe( (char*)&position.x, 4 );
|
|
|
|
+ zD->schreibe( (char*)&position.y, 4 );
|
|
|
|
+ zD->schreibe( (char*)&speed.x, 4 );
|
|
|
|
+ zD->schreibe( (char*)&speed.y, 4 );
|
|
float r = getDrehung();
|
|
float r = getDrehung();
|
|
- zD->schreibe( (char *)&r, 4 );
|
|
|
|
- zD->schreibe( (char *)&rSpeed, 4 );
|
|
|
|
|
|
+ zD->schreibe( (char*)&r, 4 );
|
|
|
|
+ zD->schreibe( (char*)&rSpeed, 4 );
|
|
}
|
|
}
|
|
|
|
|
|
-Schuss *Ship::getSchuss() const
|
|
|
|
|
|
+Schuss* Ship::getSchuss() const
|
|
{
|
|
{
|
|
Vertex pos = position;
|
|
Vertex pos = position;
|
|
Vertex sp = Vec2<float>( cos( getDrehung() ), sin( getDrehung() ) ) * 200 + getSpeed();
|
|
Vertex sp = Vec2<float>( cos( getDrehung() ), sin( getDrehung() ) ) * 200 + getSpeed();
|