123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- #include "DeadPlayer.h"
- #include "../Define.h"
- #include <Textur2D.h>
- #include <Bild.h>
- DeadPlayer::DeadPlayer( Model2DData *mda, Model2DData *mdb, Vertex posa, Vertex posb, Vertex speedA, Vertex speedB, float curRotA, float curRotB, float rotA, float rotB, Textur2D *zTextur )
- : Object2D()
- {
- m2a = new Model2DObject();
- m2a->setModel( mda );
- m2a->setPosition( posa );
- m2a->setTextur( dynamic_cast<Textur2D *>( zTextur->getThis() ) );
- m2a->setDrehung( curRotA );
- m2a->setSpeed( speedA );
- m2a->setDrehungSpeed( rotA );
- m2b = new Model2DObject();
- m2b->setModel( mdb );
- m2b->setPosition( posb );
- m2b->setTextur( dynamic_cast<Textur2D *>( zTextur->getThis() ) );
- m2b->setDrehung( curRotB );
- m2b->setSpeed( speedB );
- m2b->setDrehungSpeed( rotB );
- alpha = 255;
- setCollision( 0 );
- save();
- }
- DeadPlayer::~DeadPlayer()
- {
- m2a->release();
- m2b->release();
- }
- void DeadPlayer::render( Mat3< float > &kamMat, Bild &zRObj, const char *kamName )
- {
- zRObj.setAlpha( (unsigned char)alpha );
- m2a->render( kamMat, zRObj, kamName );
- m2b->render( kamMat, zRObj, kamName );
- zRObj.releaseAlpha();
- }
- bool DeadPlayer::tick( const WeltInfo &info, double zeit )
- {
- m2a->tick( info, zeit );
- m2b->tick( info, zeit );
- alpha -= zeit * 15;
- if( alpha < 0 )
- alpha = 0;
- return 1;
- }
- Rect2< float > DeadPlayer::getBoundingBox() const
- {
- Rect2< float > r1 = m2a->getBoundingBox();
- Rect2< float > r2 = m2b->getBoundingBox();
- Rect2< float > r;
- r.topLeft.x = min( r1.topLeft.x, r2.topLeft.x );
- r.topLeft.y = min( r1.topLeft.y, r2.topLeft.y );
- r.bottomRight.x = max( r1.bottomRight.x, r2.bottomRight.x );
- r.bottomRight.y = max( r1.bottomRight.y, r2.bottomRight.y );
- return r;
- }
- bool DeadPlayer::isFinished() const
- {
- return alpha == 0;
- }
- void DeadPlayer::save()
- {
- alt.alpha = alpha;
- alt.posA = m2a->getPosition();
- alt.speedA = m2a->getSpeed();
- alt.rotA = m2a->getDrehung();
- alt.rotSA = m2a->getDrehungSpeed();
- alt.posB = m2b->getPosition();
- alt.speedB = m2b->getSpeed();
- alt.rotB = m2b->getDrehung();
- alt.rotSB = m2b->getDrehungSpeed();
- }
- void DeadPlayer::load()
- {
- alpha = alt.alpha;
- m2a->setPosition( alt.posA );
- m2a->setSpeed( alt.speedA );
- m2a->setDrehung( alt.rotA );
- m2a->setDrehungSpeed( alt.rotSA );
- m2b->setPosition( alt.posB );
- m2b->setSpeed( alt.speedB );
- m2b->setDrehung( alt.rotB );
- m2b->setDrehungSpeed( alt.rotSB );
- }
|