12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- #include "Pixel.h"
- #include <Bild.h>
- Pixel::Pixel( Vertex pos, Vertex speed, float ep, int id )
- : Object2D()
- {
- setPosition( pos );
- setSpeed( speed );
- this->ep = ep;
- pixelId = id;
- collision = false;
- save();
- }
- bool Pixel::tick( const WeltInfo &info, double zeit )
- {
- ep -= (float)zeit;
- return __super::tick( info, zeit ) || 1;
- }
- void Pixel::render( Mat3< float > &kamMat, Bild &zRObj, const char *kamName )
- {
- Mat3< float > mat = kamMat * getObjectMatrix();
- Vertex p = mat * Vertex( 0, 0 );
- Vertex p2 = mat * Vertex( ep / 5, 0 );
- zRObj.fillCircle( (int)p.x, (int)p.y, (int)( p2 - p ).getLength() + 1, 0xFFFFFFFF );
- }
- Rect2< float > Pixel::getBoundingBox() const
- {
- Rect2< float > r = Rect2< float >();
- r.topLeft.x = -(ep / 5 + 1);
- r.topLeft.y = -(ep / 5 + 1);
- r.bottomRight.x = ep / 5 + 1;
- r.bottomRight.y = ep / 5 + 1;
- r.topLeft = getWorldPos( r.topLeft );
- r.bottomRight = getWorldPos( r.bottomRight );
- return r;
- }
- float Pixel::getEp() const
- {
- return ep;
- }
- int Pixel::getId() const
- {
- return pixelId;
- }
- void Pixel::save()
- {
- backup.pos = getPosition();
- backup.speed = getSpeed();
- backup.rotation = getDrehung();
- backup.rSpeed = getDrehungSpeed();
- backup.oldEp = ep;
- }
- void Pixel::load()
- {
- setPosition( backup.pos );
- setSpeed( backup.speed );
- setDrehung( backup.rotation );
- setDrehungSpeed( backup.rSpeed );
- ep = backup.oldEp;
- }
|