Ver Fonte

Entlang von BArieren oder Map Rändern können sich Spieler jetzt weiter bewegen

Kolja Strohm há 4 anos atrás
pai
commit
7f1eba243e

+ 1 - 1
StickmanWorldOnline/Effect.cpp

@@ -37,7 +37,7 @@ bool Effect::istIntersectable() const
     return 1;
 }
 
-void Effect::move( double time )
+void Effect::move( Richtung r, double time )
 {}
 
 bool Effect::istGegenstandErlaubt( GegenstandTyp typ ) const

+ 1 - 1
StickmanWorldOnline/Effect.h

@@ -21,7 +21,7 @@ public:
     virtual bool istSpielerVerwundbar( Richtung r ) const;
     virtual bool istSpielerSichtbar( Team *zTeam ) const;
     virtual bool istIntersectable() const;
-    virtual void move( double time );
+    virtual void move( Richtung r, double time );
     virtual bool istGegenstandErlaubt( GegenstandTyp typ ) const;
     virtual void renderSpieler( Bild &rObj );
     virtual Resource *getCurrentResource();

+ 2 - 2
StickmanWorldOnline/Enterhaken.cpp

@@ -28,9 +28,9 @@ bool EnterhakenEffect::istSpielerBeweglich( Richtung r ) const
     return 0;
 }
 
-void EnterhakenEffect::move( double time )
+void EnterhakenEffect::move( Richtung ri, double time )
 {
-    if( time < 0 )
+    if( time < 0 || ri != r )
         return;
     if( state == 3 || state == 4 )
     {

+ 1 - 1
StickmanWorldOnline/Enterhaken.h

@@ -21,7 +21,7 @@ public:
     EnterhakenEffect( ResourceRegistry *zResources, Spieler *zSpieler, Richtung r );
     ~EnterhakenEffect();
     bool istSpielerBeweglich( Richtung r ) const override;
-    void move( double time ) override;
+    void move( Richtung r, double time ) override;
     bool tick( double time, Spiel *zSpiel ) override;
     bool istGegenstandErlaubt( GegenstandTyp typ ) const override;
     bool istSpielerVerwundbar( Richtung r ) const override;

+ 3 - 1
StickmanWorldOnline/Rolle.cpp

@@ -32,8 +32,10 @@ bool RolleEffect::istSpielerVerwundbar( Richtung r ) const
     return r == MITTE;
 }
 
-void RolleEffect::move( double time )
+void RolleEffect::move( Richtung ri, double time )
 {
+    if( r != ri )
+        return;
     switch( r )
     {
     case OBEN:

+ 1 - 1
StickmanWorldOnline/Rolle.h

@@ -13,7 +13,7 @@ public:
     ~RolleEffect();
     bool istSpielerBeweglich( Richtung r ) const override;
     bool istSpielerVerwundbar( Richtung r ) const override;
-    void move( double time ) override;
+    void move( Richtung r, double time ) override;
     bool istGegenstandErlaubt( GegenstandTyp typ ) const override;
     Resource *getCurrentResource() override;
 };

+ 12 - 8
StickmanWorldOnline/Spiel.cpp

@@ -215,17 +215,21 @@ void Spiel::tick()
             }
         }
     }
+    Richtung rs[] = { OBEN, RECHTS, UNTEN, LINKS };
     for( auto s = spieler.getIterator(); s; s++ )
     {
-        s->move( TICK );
-        if( s->getX() < 0 || s->getY() < 0 || s->getX() + s->getWidth() >= mapSize.x || s->getY() + s->getHeight() >= mapSize.y )
-            s->move( -TICK );
-        else
+        for( Richtung r : rs )
         {
-            for( auto b = barieren.getIterator(); b; b++ )
-            { // spieler - bariere intersection
-                if( b->hatStyle( Bariere::Style::Aktiv ) && ( b->zTeam() != s->zTeam() ) && b->intersectsWith( s ) )
-                    s->move( -TICK );
+            s->move( r, TICK );
+            if( s->getX() < 0 || s->getY() < 0 || s->getX() + s->getWidth() >= mapSize.x || s->getY() + s->getHeight() >= mapSize.y )
+                s->move( r, -TICK );
+            else
+            {
+                for( auto b = barieren.getIterator(); b; b++ )
+                { // spieler - bariere intersection
+                    if( b->hatStyle( Bariere::Style::Aktiv ) && ( b->zTeam() != s->zTeam() ) && b->intersectsWith( s ) )
+                        s->move( r, -TICK );
+                }
             }
         }
     }

+ 7 - 7
StickmanWorldOnline/Spieler.cpp

@@ -458,20 +458,20 @@ void Spieler::addGetroffen()
     getroffen++;
 }
 
-void Spieler::move( double zeit )
+void Spieler::move( Richtung r, double zeit )
 {
-    if( istAmLeben() )
+    if( istAmLeben() && istBeweglich( r ) )
     {
-        if( tastenStand[ 'w' ] && istBeweglich( OBEN ) )
+        if( tastenStand[ 'w' ] && r == OBEN )
             y -= laufTempo * (float)zeit;
-        if( tastenStand[ 'a' ] && istBeweglich( LINKS ) )
+        if( tastenStand[ 'a' ] && r == LINKS )
             x -= laufTempo * (float)zeit;
-        if( tastenStand[ 's' ] && istBeweglich( UNTEN ) )
+        if( tastenStand[ 's' ] && r == UNTEN )
             y += laufTempo * (float)zeit;
-        if( tastenStand[ 'd' ] && istBeweglich( RECHTS ) )
+        if( tastenStand[ 'd' ] && r == RECHTS )
             x += laufTempo * (float)zeit;
         for( auto e = effekte.getIterator(); e; e++ )
-            e->move( zeit );
+            e->move( r, zeit );
     }
 }
 

+ 1 - 1
StickmanWorldOnline/Spieler.h

@@ -108,7 +108,7 @@ public:
     void addKill();
     void addTreffer( Spiel *zSpiel );
     void addGetroffen();
-    void move( double zeit );
+    void move( Richtung r, double zeit );
     void wiederbelebung( Spiel *zSpiel );
     void tick( double zeit, Spiel *zSpiel );
     void render( Bild &rObj ) override;

+ 3 - 1
StickmanWorldOnline/Sturm.cpp

@@ -33,8 +33,10 @@ bool SturmEffect::istSpielerVerwundbar( Richtung r ) const
     return r != this->r;
 }
 
-void SturmEffect::move( double time )
+void SturmEffect::move( Richtung ri, double time )
 {
+    if( r != ri )
+        return;
     switch( r )
     {
     case OBEN:

+ 1 - 1
StickmanWorldOnline/Sturm.h

@@ -13,7 +13,7 @@ public:
     ~SturmEffect();
     bool istSpielerBeweglich( Richtung r ) const override;
     bool istSpielerVerwundbar( Richtung r ) const override;
-    void move( double time ) override;
+    void move( Richtung r, double time ) override;
     bool tick( double time, Spiel *zSpiel ) override;
     bool istGegenstandErlaubt( GegenstandTyp typ ) const override;
     Resource *getCurrentResource() override;