Browse Source

Antriebs Animationen hinzugefügt

Kolja Strohm 7 years ago
parent
commit
3eb2a0ba20
5 changed files with 68 additions and 6 deletions
  1. 4 1
      Asteroids/Asteroid.cpp
  2. 50 1
      Asteroids/Map.cpp
  3. 4 0
      Asteroids/Map.h
  4. 9 3
      Asteroids/Ship.cpp
  5. 1 1
      Asteroids/Ship.h

+ 4 - 1
Asteroids/Asteroid.cpp

@@ -4,6 +4,7 @@
 #include <TastaturEreignis.h>
 #include <TastaturEreignis.h>
 #include "Schuss.h"
 #include "Schuss.h"
 #include <iostream>
 #include <iostream>
+#include <Textur2D.h>
 
 
 // Inhalt der Asteroid Klasse aus Asteroid.h
 // Inhalt der Asteroid Klasse aus Asteroid.h
 // Konstruktor
 // Konstruktor
@@ -12,7 +13,9 @@ Asteroid::Asteroid( Model2DData *data, Bild *textur, Vec2< float > p, Vec2< floa
 	asteroid = new Model2D();
 	asteroid = new Model2D();
 	asteroid->setStyle( Model2D::Style::Sichtbar | Model2D::Style::Textur );
 	asteroid->setStyle( Model2D::Style::Sichtbar | Model2D::Style::Textur );
 	asteroid->setModel( data );
 	asteroid->setModel( data );
-	asteroid->setTextur( textur );
+    Textur2D *txt = new Textur2D();
+    txt->setTexturZ( textur );
+	asteroid->setTextur( txt );
 	asteroid->setDrehung( r );
 	asteroid->setDrehung( r );
 	asteroid->setSize( gr );
 	asteroid->setSize( gr );
 	mGröße = 0;
 	mGröße = 0;

+ 50 - 1
Asteroids/Map.cpp

@@ -10,6 +10,7 @@
 #include <Rahmen.h>
 #include <Rahmen.h>
 #include <Globals.h>
 #include <Globals.h>
 #include <AsynchronCall.h>
 #include <AsynchronCall.h>
+#include <Animation.h>
 
 
 // Inhalt der Map Klasse aus Map.h
 // Inhalt der Map Klasse aus Map.h
 // Konstruktor
 // Konstruktor
@@ -23,6 +24,30 @@ Map::Map( MinigameKlientV *klient )
     aTextur = new Bild*[ 7 ]();
     aTextur = new Bild*[ 7 ]();
     sData = new Model2DData*[ 2 ]();
     sData = new Model2DData*[ 2 ]();
     sTextur = new Bild*[ 2 ]();
     sTextur = new Bild*[ 2 ]();
+    // lade Flammen animation
+    LTDBDatei flammenStartLTDB;
+    flammenStartLTDB.setDatei( new Text( "data/Minigames/Asteroids/bilder/f_start.ltdb" ) );
+    flammenStartLTDB.leseDaten( 0 );
+    Animation2DData *flammenStart = new Animation2DData();
+    flammenStart->ladeAnimation( flammenStartLTDB.getThis() );
+    flammenStart->setFPS( 60 );
+    flammenStart->setWiederhohlend( 0 );
+    LTDBDatei flammenLTDB;
+    flammenLTDB.setDatei( new Text( "data/Minigames/Asteroids/bilder/f_burn.ltdb" ) );
+    Animation2DData *flammenBurn = new Animation2DData();
+    flammenBurn->ladeAnimation( flammenLTDB.getThis() );
+    flammenBurn->setFPS( 60 );
+    flammenBurn->setWiederhohlend( 1 );
+    flammenM = new Textur2D();
+    flammenM->addAnimationZ( flammenStart->getThis() );
+    flammenM->addAnimationZ( flammenBurn->getThis() );
+    flammenL = new Textur2D();
+    flammenL->addAnimationZ( flammenStart->getThis() );
+    flammenL->addAnimationZ( flammenBurn->getThis() );
+    flammenR = new Textur2D();
+    flammenR->addAnimationZ( flammenStart );
+    flammenR->addAnimationZ( flammenBurn );
+
     M2Datei m2d( "data/Minigames/Asteroids/models/asteroids.m2" );
     M2Datei m2d( "data/Minigames/Asteroids/models/asteroids.m2" );
     m2d.leseDaten();
     m2d.leseDaten();
     LTDBDatei td;
     LTDBDatei td;
@@ -96,6 +121,9 @@ Map::~Map()
         rGen->release();
         rGen->release();
     if( klient )
     if( klient )
         klient->release();
         klient->release();
+    flammenM->release();
+    flammenL->release();
+    flammenR->release();
 }
 }
 
 
 // nicht constant
 // nicht constant
@@ -227,7 +255,7 @@ void Map::reset( Text *zOptionen )
             tmp->release();
             tmp->release();
         }
         }
     }
     }
-    ship = new Ship( sData[ shipN ]->getThis(), sTextur[ shipN ]->getThis(), shipPos, shipSpeed, shipR );
+    ship = new Ship( sData[ shipN ]->getThis(), flammenM, flammenL, flammenR, sTextur[ shipN ]->getThis(), shipPos, shipSpeed, shipR );
 }
 }
 
 
 void Map::doMausEreignis( MausEreignis &me )
 void Map::doMausEreignis( MausEreignis &me )
@@ -245,23 +273,41 @@ void Map::doTastaturEreignis( TastaturEreignis &te )
         if( te.taste == 'w' || te.taste == 'W' || te.taste == T_Oben )
         if( te.taste == 'w' || te.taste == 'W' || te.taste == T_Oben )
         {
         {
             if( te.id == TE_Press )
             if( te.id == TE_Press )
+            {
                 tastenStände |= 1;
                 tastenStände |= 1;
+                flammenM->setAnimation( 0 );
+            }
             else
             else
+            {
                 tastenStände &= ~1;
                 tastenStände &= ~1;
+                flammenM->setAnimation( -1 );
+            }
         }
         }
         if( te.taste == 'd' || te.taste == 'D' || te.taste == T_Rechts )
         if( te.taste == 'd' || te.taste == 'D' || te.taste == T_Rechts )
         {
         {
             if( te.id == TE_Press )
             if( te.id == TE_Press )
+            {
                 tastenStände |= 2;
                 tastenStände |= 2;
+                flammenL->setAnimation( 0 );
+            }
             else
             else
+            {
                 tastenStände &= ~2;
                 tastenStände &= ~2;
+                flammenL->setAnimation( -1 );
+            }
         }
         }
         if( te.taste == 'a' || te.taste == 'A' || te.taste == T_Links )
         if( te.taste == 'a' || te.taste == 'A' || te.taste == T_Links )
         {
         {
             if( te.id == TE_Press )
             if( te.id == TE_Press )
+            {
                 tastenStände |= 4;
                 tastenStände |= 4;
+                flammenR->setAnimation( 0 );
+            }
             else
             else
+            {
                 tastenStände &= ~4;
                 tastenStände &= ~4;
+                flammenR->setAnimation( -1 );
+            }
         }
         }
         if( te.taste == T_Space )
         if( te.taste == T_Space )
         {
         {
@@ -429,6 +475,9 @@ bool Map::tick( double tickVal )
         DateiRemove( "data/Minigames/Asteroids/data/game.save" );
         DateiRemove( "data/Minigames/Asteroids/data/game.save" );
     }
     }
     cs.unlock();
     cs.unlock();
+    flammenM->tick( tickVal );
+    flammenL->tick( tickVal );
+    flammenR->tick( tickVal );
     return 1;
     return 1;
 }
 }
 
 

+ 4 - 0
Asteroids/Map.h

@@ -6,6 +6,7 @@
 #include "Ship.h"
 #include "Ship.h"
 #include "Asteroid.h"
 #include "Asteroid.h"
 #include <Random.h>
 #include <Random.h>
+#include <Textur2D.h>
 #include "../../../Include/KSGKlientV.h"
 #include "../../../Include/KSGKlientV.h"
 
 
 using namespace Framework;
 using namespace Framework;
@@ -22,6 +23,9 @@ private:
     Bild **sTextur;
     Bild **sTextur;
     LRahmen *kam;
     LRahmen *kam;
     LRahmen *map;
     LRahmen *map;
+    Textur2D *flammenM;
+    Textur2D *flammenL;
+    Textur2D *flammenR;
     int shipN;
     int shipN;
     int score;
     int score;
     int breite;
     int breite;

+ 9 - 3
Asteroids/Ship.cpp

@@ -6,15 +6,21 @@
 #include "Schuss.h"
 #include "Schuss.h"
 #include "Asteroid.h"
 #include "Asteroid.h"
 #include <iostream>
 #include <iostream>
+#include <Textur2D.h>
 
 
 // Inhalt der Ship Klasse aus Ship.h
 // Inhalt der Ship Klasse aus Ship.h
 // Konstruktor
 // Konstruktor
-Ship::Ship( Model2DData *data, Bild *textur, Vec2< float > p, Vec2< float > s, float r )
+Ship::Ship( Model2DData *data, Textur2D *zFlammenM, Textur2D *zFlammenL, Textur2D *zFlammenR, Bild *textur, Vec2< float > p, Vec2< float > s, float r )
 {
 {
 	ship = new Model2D();
 	ship = new Model2D();
 	ship->setStyle( Model2D::Style::Sichtbar | Model2D::Style::Textur );
 	ship->setStyle( Model2D::Style::Sichtbar | Model2D::Style::Textur );
-	ship->setModel( data );
-	ship->setTextur( textur );
+    ship->setModel( data );
+    Textur2D *txt = new Textur2D();
+    txt->setTexturZ( textur );
+	ship->setTextur( txt, "ship" );
+    ship->setTextur( zFlammenL->getThis(), "engine_l" );
+    ship->setTextur( zFlammenR->getThis(), "engine_r" );
+    ship->setTextur( zFlammenM->getThis(), "engine_m" );
 	ship->setDrehung( r );
 	ship->setDrehung( r );
 	pos = p;
 	pos = p;
 	speed = s;
 	speed = s;

+ 1 - 1
Asteroids/Ship.h

@@ -19,7 +19,7 @@ private:
 
 
 public:
 public:
 	// Konstruktor
 	// Konstruktor
-	Ship( Model2DData *data, Bild *textur, Vec2< float > p, Vec2< float > s, float r );
+	Ship( Model2DData *data, Textur2D *zFlammenM, Textur2D *zFlammenL, Textur2D *zFlammenR, Bild *textur, Vec2< float > p, Vec2< float > s, float r );
 	// Destruktor
 	// Destruktor
 	~Ship();
 	~Ship();
 	// nicht constant
 	// nicht constant