Operation Null Mind 0.4.1
A 2D roguelike top down shooter game made with SDL2
 
Loading...
Searching...
No Matches
colliders.c File Reference

Collision detection system. More...

#include <colliders.h>
#include <stdio.h>

Functions

void Collider_Start ()
 [Start] Initializes the Colliders array.
 
void Collider_Register (Collider *collider, void *owner)
 [Start] Registers a collider to the Colliders array.
 
bool Collider_Check (Collider *collider, ColliderCheckResult *checkResult)
 [PostUpdate] Checks if a collider is intersecting with any of its collider layers.
 
void Collider_Reset (Collider *collider)
 Deactivates a collider and resets its properties.
 

Variables

Collider * ColliderList [MAX_COLLIDABLES]
 
int ColliderCount = 0
 

Detailed Description

Collision detection system.

Provides functionality for hitbox-based collision detection between game objects with layer-based filtering.

Author
Mango
Date
2025-03-02

Function Documentation

◆ Collider_Check()

bool Collider_Check ( Collider *  collider,
ColliderCheckResult *  checkResult 
)

[PostUpdate] Checks if a collider is intersecting with any of its collider layers.

Check for collisions with a collider.

This function checks for collision between a collider and everything else in the ColliderList array. Any colliders whose layer is not in the input collider's collidesWith section will be ignored.

Parameters
colliderThe input collider
checkResultThe checkResult of the collider, which includes 2 members: checkResult.objects: an array of detected colliders checkResult.count: number of collisions detected
Returns
true if collision detected, false otherwise

◆ Collider_Register()

void Collider_Register ( Collider *  collider,
void *  owner 
)

[Start] Registers a collider to the Colliders array.

Register a collider with the collision manager.

This is so that every colliders can be checked by each other.

Parameters
colliderA pointer to the collider struct. For example: &player.state.collider
ownerA pointer to the owner of the collider. For example: &player

◆ Collider_Reset()

void Collider_Reset ( Collider *  collider)

Deactivates a collider and resets its properties.

Deactivates a collider.

Parameters
colliderThe collider to reset

◆ Collider_Start()

void Collider_Start ( )

[Start] Initializes the Colliders array.

Initialize the collision manager.

Variable Documentation

◆ ColliderCount

int ColliderCount = 0

◆ ColliderList

Collider* ColliderList[MAX_COLLIDABLES]