SDLPP: add collider IDs
This commit is contained in:
@@ -25,6 +25,15 @@ RectColider::RectColider( const Vec2D< double > &top_left,
|
||||
const Vec2D< double > &size )
|
||||
: CollisionPolygon( top_left ), _size( size ) {}
|
||||
|
||||
RectColider::RectColider( double x, double y, double w, double h, uint64_t id )
|
||||
: RectColider( { x, y }, { w, h }, id ) {}
|
||||
|
||||
RectColider::RectColider( const Vec2D< double > &top_left,
|
||||
const Vec2D< double > &size, uint64_t id )
|
||||
: RectColider( top_left, size ) {
|
||||
_id = id;
|
||||
}
|
||||
|
||||
bool RectColider::colidesWith( const SDLPP::CollisionPolygon &other ) const {
|
||||
if ( other.isCircle() ) {
|
||||
return other.colidesWith( *this );
|
||||
@@ -57,9 +66,11 @@ int RectColider::rightmost() const {
|
||||
isInfinite() * -1;
|
||||
}
|
||||
|
||||
void RectColider::updateCollision( int x, int y, int w, int h ) {
|
||||
void RectColider::updateCollision( int x, int y, int w, int h, uint64_t id ) {
|
||||
position = Vec2D< int >( original.getX() * w + x, original.getY() * h + y );
|
||||
_size_pixel = Vec2D< int >( width() * w, height() * h );
|
||||
if ( _id == static_cast< uint64_t >( -1 ) )
|
||||
_id = id;
|
||||
}
|
||||
|
||||
void RectColider::render( Renderer &renderer, const SDL_Color &color,
|
||||
|
||||
Reference in New Issue
Block a user