1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- #include "Laser.h"
- #include "Karte.h"
- // Inhalt der Laser Klasse aus Laser.h
- // Konstruktor
- Laser::Laser( int id, Vec2< double > pos, Vec2< double > speed, int sNum, double intensity )
- {
- this->id = id;
- this->pos = pos;
- this->speed = speed;
- this->sNum = sNum;
- this->intensity = intensity;
- ref = 1;
- }
- // nicht constant
- void Laser::tick( double tickVal, Karte *zMap )
- {
- pos += speed * tickVal;
- Vec2< int > gr = zMap->getSize();
- if( pos.x < 0 )
- pos.x += gr.x;
- if( pos.y < 0 )
- pos.y += gr.y;
- if( pos.x >= gr.x )
- pos.x -= gr.x;
- if( pos.y >= gr.y )
- pos.y -= gr.y;
- intensity -= tickVal * 2;
- }
- // constant
- int Laser::getId() const
- {
- return id;
- }
- int Laser::getSpieler() const
- {
- return sNum;
- }
- Vec2< double > Laser::getPos() const
- {
- return pos;
- }
- Vec2< double > Laser::getSpeed() const
- {
- return speed;
- }
- double Laser::getIntensity() const
- {
- return intensity;
- }
- // Reference Counting
- Laser *Laser::getThis()
- {
- ref++;
- return this;
- }
- Laser *Laser::release()
- {
- ref--;
- if( !ref )
- delete this;
- return 0;
- }
|