123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174 |
- #pragma once
- #include <queue>
- #include <functional>
- #include "Array.h"
- #include "Mat3.h"
- #include "Punkt.h"
- #include "Rect2.h"
- namespace Framework
- {
- typedef Vec2< float > Vertex;
- class Bild;
- struct WeltInfo
- {
- float airResistance;
- bool hasSize;
- bool circular;
- Punkt size;
- };
- class Object2D : public virtual ReferenceCounter
- {
- protected:
- std::queue< std::function< void() > > actions;
- Vertex position;
- Vertex speed;
- float rSpeed;
- float rotation;
- float size;
- bool collision;
- public:
- DLLEXPORT Object2D();
- DLLEXPORT virtual ~Object2D();
-
- DLLEXPORT void postAction( std::function< void() > action );
-
-
-
- DLLEXPORT void explosion( Vertex worldPos, float intensity );
-
-
-
-
- DLLEXPORT virtual void impuls( Vertex start, Vertex speed, float strength = 1.f );
-
-
- DLLEXPORT void setSpeed( Vertex speed );
-
-
-
- DLLEXPORT void setSpeed( float x, float y );
-
-
- DLLEXPORT void setPosition( Vertex pos );
-
-
-
- DLLEXPORT void setPosition( float x, float y );
-
-
- DLLEXPORT void setDrehungSpeed( float ds );
-
-
- DLLEXPORT void setDrehung( float drehung );
-
-
- DLLEXPORT void addDrehung( float drehung );
-
-
- DLLEXPORT void setSize( float size );
-
-
- DLLEXPORT void addSize( float size );
-
-
- DLLEXPORT void setCollision( bool handle );
-
- DLLEXPORT virtual bool handleCollision( Object2D *obj );
-
-
- DLLEXPORT virtual bool tick( const WeltInfo &info, double zeit );
-
-
-
-
- virtual void render( Mat3< float > &kamMat, Bild &zRObj, const char *ignoreTransparentFlag ) = 0;
-
-
-
- DLLEXPORT virtual bool istPunktInnen( Vertex p, bool ignoreTransparentFlag = 0 ) const;
-
-
-
-
- DLLEXPORT virtual bool istLinieInnen( Vertex a, Vertex b, bool ignoreTransparentFlag = 0 ) const;
-
-
-
-
- DLLEXPORT virtual bool istModelInnen( const Object2D *zObj, Vertex *sp = 0, bool end = 0, bool ignoreTransparent = 0 ) const;
-
- DLLEXPORT Mat3< float > getObjectMatrix() const;
-
- DLLEXPORT Mat3< float > getInverseObjectMatrix() const;
-
-
- DLLEXPORT Vertex getObjectPos( Vertex worldPos ) const;
-
-
- DLLEXPORT Vertex getObjectDir( Vertex worldDir ) const;
-
-
- DLLEXPORT Vertex getWorldPos( Vertex objectPos ) const;
-
-
- DLLEXPORT Vertex getWorldDir( Vertex objectDir ) const;
-
- DLLEXPORT Vertex getSpeed() const;
-
- DLLEXPORT Vertex getPosition() const;
-
- DLLEXPORT float getDrehungSpeed() const;
-
- DLLEXPORT float getDrehung() const;
-
- DLLEXPORT float getSize() const;
-
- DLLEXPORT virtual Rect2< float > getBoundingBox() const = 0;
-
-
-
-
-
- DLLEXPORT virtual bool calcHitPoint( Vertex pos, Vertex dir, Vertex &hitpoint ) const;
-
- DLLEXPORT virtual float getLuftWiederstand() const;
-
- DLLEXPORT virtual float getMasse() const;
-
-
- DLLEXPORT bool canCollide();
- };
- class Welt2D : public virtual ReferenceCounter
- {
- private:
- RCArray< Object2D > *objects;
- WeltInfo info;
- void render( Mat3< float > &kamMat, Punkt size, Bild &zRObj, int xOffset, int yOffset, const char *kamName );
- public:
- DLLEXPORT Welt2D();
- DLLEXPORT ~Welt2D();
- DLLEXPORT void setAirResistance( float resistance );
- DLLEXPORT void setSize( int width, int height );
- DLLEXPORT void setSize( bool hasSize );
- DLLEXPORT void setCircular( bool circular );
- DLLEXPORT Object2D *zObjectAt( int x, int y, bool ignoreTransparentFlag = 0 );
- DLLEXPORT Object2D *getObjectAt( int x, int y, bool ignoreTransparentFlag = 0 );
- DLLEXPORT void addObject( Object2D *obj );
- DLLEXPORT void removeObject( Object2D *zObj );
- DLLEXPORT void removeAll();
- DLLEXPORT void explosion( Vertex worldPos, float intensity, float maxRad );
- DLLEXPORT void impuls( Vertex worldPos, Vertex worldDir );
- DLLEXPORT bool tick( double zeit );
- DLLEXPORT void render( Mat3< float > &kamMat, Punkt size, Bild &zRObj, const char *kamName );
- DLLEXPORT const WeltInfo &getWorldInfo() const;
- DLLEXPORT Iterator< Object2D * > getMembers();
- };
- }
|