SPARK  0.1.0
A general purpose game engine written in C++.
Loading...
Searching...
No Matches
spark::core::components::Collider Class Reference

A component representing a square collider. More...

#include <Collider.h>

Inheritance diagram for spark::core::components::Collider:
spark::core::Component spark::rtti::HasRtti spark::core::components::DynamicCollider spark::core::components::StaticCollider

Public Member Functions

math::Vector4< float > bounds () const
 Gets the bounds of the rectangle in screen space.
 
bool collidesWith (const Collider &other) const
 Checks if the collider is colliding with another collider.
 
- Public Member Functions inherited from spark::core::Component
 Component (GameObject *parent)
 Instantiates a new Component.
 
 Component (const Component &other)=delete
 
 Component (Component &&other) noexcept=default
 
Componentoperator= (const Component &other)=delete
 
Componentoperator= (Component &&other) noexcept=default
 
const lib::Uuiduuid () const
 Gets the UUID of the component.
 
GameObjectgameObject ()
 Gets the GameObject that the component is attached to.
 
const GameObjectgameObject () const
 Gets the GameObject that the component is attached to.
 
virtual void render () const
 Renders the component.
 
virtual void onAttach ()
 Method called when the component is attached to a GameObject.
 
virtual void onUpdate (float dt)
 Method called on every frame.
 
virtual void onDetach ()
 Method called when the component is detached from a GameObject.
 
- Public Member Functions inherited from spark::rtti::HasRtti
 HasRtti (const HasRtti &other)=default
 
 HasRtti (HasRtti &&other) noexcept=default
 
HasRttioperator= (const HasRtti &other)=default
 
HasRttioperator= (HasRtti &&other) noexcept=default
 
virtual RttiBaserttiInstance () const =0
 

Protected Member Functions

 Collider (GameObject *parent, math::Rectangle< float > rectangle)
 

Detailed Description

A component representing a square collider.

Note
This component is not meant to be used directly, use StaticCollider or DynamicCollider instead.

Member Function Documentation

◆ bounds()

math::Vector4< float > spark::core::components::Collider::bounds ( ) const
inlinenodiscard

Gets the bounds of the rectangle in screen space.

Returns
A spark::math::Vector4<float> containing the bounds of the rectangle. [xMin, yMin, xMax, yMax]

◆ collidesWith()

bool spark::core::components::Collider::collidesWith ( const Collider & other) const
inlinenodiscard

Checks if the collider is colliding with another collider.

Parameters
otherThe other collider to check for collision.
Returns
true if the colliders are colliding, false otherwise.