Эх сурвалжийг харах

Antriebs Animationen hinzugefügt

Kolja Strohm 6 жил өмнө
parent
commit
3eb2a0ba20

+ 4 - 1
Asteroids/Asteroid.cpp

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

+ 50 - 1
Asteroids/Map.cpp

@@ -10,6 +10,7 @@
 #include <Rahmen.h>
 #include <Globals.h>
 #include <AsynchronCall.h>
+#include <Animation.h>
 
 // Inhalt der Map Klasse aus Map.h
 // Konstruktor
@@ -23,6 +24,30 @@ Map::Map( MinigameKlientV *klient )
     aTextur = new Bild*[ 7 ]();
     sData = new Model2DData*[ 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" );
     m2d.leseDaten();
     LTDBDatei td;
@@ -96,6 +121,9 @@ Map::~Map()
         rGen->release();
     if( klient )
         klient->release();
+    flammenM->release();
+    flammenL->release();
+    flammenR->release();
 }
 
 // nicht constant
@@ -227,7 +255,7 @@ void Map::reset( Text *zOptionen )
             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 )
@@ -245,23 +273,41 @@ void Map::doTastaturEreignis( TastaturEreignis &te )
         if( te.taste == 'w' || te.taste == 'W' || te.taste == T_Oben )
         {
             if( te.id == TE_Press )
+            {
                 tastenStände |= 1;
+                flammenM->setAnimation( 0 );
+            }
             else
+            {
                 tastenStände &= ~1;
+                flammenM->setAnimation( -1 );
+            }
         }
         if( te.taste == 'd' || te.taste == 'D' || te.taste == T_Rechts )
         {
             if( te.id == TE_Press )
+            {
                 tastenStände |= 2;
+                flammenL->setAnimation( 0 );
+            }
             else
+            {
                 tastenStände &= ~2;
+                flammenL->setAnimation( -1 );
+            }
         }
         if( te.taste == 'a' || te.taste == 'A' || te.taste == T_Links )
         {
             if( te.id == TE_Press )
+            {
                 tastenStände |= 4;
+                flammenR->setAnimation( 0 );
+            }
             else
+            {
                 tastenStände &= ~4;
+                flammenR->setAnimation( -1 );
+            }
         }
         if( te.taste == T_Space )
         {
@@ -429,6 +475,9 @@ bool Map::tick( double tickVal )
         DateiRemove( "data/Minigames/Asteroids/data/game.save" );
     }
     cs.unlock();
+    flammenM->tick( tickVal );
+    flammenL->tick( tickVal );
+    flammenR->tick( tickVal );
     return 1;
 }
 

+ 4 - 0
Asteroids/Map.h

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

+ 9 - 3
Asteroids/Ship.cpp

@@ -6,15 +6,21 @@
 #include "Schuss.h"
 #include "Asteroid.h"
 #include <iostream>
+#include <Textur2D.h>
 
 // Inhalt der Ship Klasse aus Ship.h
 // 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->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 );
 	pos = p;
 	speed = s;

+ 1 - 1
Asteroids/Ship.h

@@ -19,7 +19,7 @@ private:
 
 public:
 	// 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
 	~Ship();
 	// nicht constant