Bläddra i källkod

Geschosse treffen nun auch den eigenen Spieler

Kolja Strohm 4 år sedan
förälder
incheckning
0a5012b0cf

+ 0 - 1
StickmanWorldOnline/Enterhaken.cpp

@@ -6,7 +6,6 @@ EnterhakenEffect::EnterhakenEffect( ResourceRegistry *zResources, Spieler *zSpie
     : Effect( zSpieler, 1.5f + ( 1.5f / 100.f ) * zSpieler->getAbklingZeitVerringerung() )
 {
     this->r = r;
-    timeLeft = 3;
     maxTime = timeLeft;
     state = 0;
     ehpx = zSpieler->getX() + zSpieler->getWidth() / 2;

+ 1 - 1
StickmanWorldOnline/GameObject.h

@@ -22,7 +22,7 @@ public:
     void setY( float y );
     void setWidth( float width );
     void setHeight( float height );
-    bool intersectsWith( GameObject *zObj );
+    virtual bool intersectsWith( GameObject *zObj );
     virtual void render( Bild &rObj );
     float getX() const;
     float getY() const;

+ 11 - 0
StickmanWorldOnline/Geschoss.cpp

@@ -14,6 +14,7 @@ Geschoss::Geschoss( ResourceRegistry *zResources, int id, float speed, GeschossT
     geschosseGetroffen = 0;
     schalter = 0;
     texturScale = 1;
+    intersectWithOwner = 1;
     this->id = id;
     setTyp( typ );
 }
@@ -179,6 +180,16 @@ void Geschoss::tick( double zeit )
     }
 }
 
+bool Geschoss::intersectsWith( GameObject *zObj )
+{
+    if( zObj == besitzer && intersectWithOwner )
+    {
+        intersectWithOwner &= GameObject::intersectsWith( zObj );
+        return 0;
+    }
+    return GameObject::intersectsWith( zObj );
+}
+
 GeschossTyp Geschoss::getTyp() const
 {
     return typ;

+ 2 - 0
StickmanWorldOnline/Geschoss.h

@@ -21,6 +21,7 @@ private:
     int schalter;
     int currentImage;
     double nextImage;
+    bool intersectWithOwner;
     int id;
     ResourceRegistry *resources;
 
@@ -37,6 +38,7 @@ public:
     void setTyp( GeschossTyp typ );
     void setRichtung( Richtung r );
     void tick( double zeit );
+    bool intersectsWith( GameObject *zObj ) override;
     GeschossTyp getTyp() const;
     Spieler *zBesitzer() const;
     Spieler *getBesitzer() const;

+ 1 - 1
StickmanWorldOnline/Spiel.cpp

@@ -378,7 +378,7 @@ void Spiel::tick()
                     // geschoss - spieler intersection
                     for( auto s = spieler.getIterator(); s; s++ )
                     {
-                        if( s->istAmLeben() && s != g->zBesitzer() && g->intersectsWith( s ) )
+                        if( s->istAmLeben() && g->intersectsWith( s ) )
                         {
                             switch( g->getTyp() )
                             {