diff options
| author | esquizo <esquizo+noreply@esquizo.net> | 2026-05-17 12:02:56 -0300 |
|---|---|---|
| committer | esquizo <esquizo+noreply@esquizo.net> | 2026-05-17 12:02:56 -0300 |
| commit | 97702f11ea016ca2e395f71f03c3fc3a2ee929ca (patch) | |
| tree | 20380f895ee422c48b970c7da5b921e046e35da4 /libphysics/event.c | |
| parent | 5c6b3c19172948cf2e1800a9333cfcd858ee829c (diff) | |
adicionado libphysics
Diffstat (limited to 'libphysics/event.c')
| -rw-r--r-- | libphysics/event.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/libphysics/event.c b/libphysics/event.c new file mode 100644 index 0000000..da836f6 --- /dev/null +++ b/libphysics/event.c @@ -0,0 +1,44 @@ +#include <vecmath.h> +#include <physics.h> +#include <stdlib.h> + +#include "dat.h" + +#define EVENT_POOL_SIZE 2048 + +static CollisionEvent event[EVENT_POOL_SIZE]; +static int eventi, evente, events; + +int +phxenqevent(CollisionEvent *ev) +{ + if(events == EVENT_POOL_SIZE) + return 0; + + event[evente] = *ev; + evente = (evente + 1) % EVENT_POOL_SIZE; + events++; + + return 1; +} + +int +phxdeqevent(CollisionEvent *ev) +{ + CollisionEvent *evv; + if(events == 0) + return 0; + + evv = event + eventi; + eventi = (eventi + 1) % EVENT_POOL_SIZE; + + *ev = *evv; + events--; + return 1; +} + +int +phxnextcollevent(CollisionEvent *ev) +{ + return phxdeqevent(ev); +} |
