mirror of
https://github.com/zoriya/Gamacon.git
synced 2026-06-02 11:45:23 +00:00
Collisions now uses floats
This commit is contained in:
@@ -10,10 +10,10 @@
|
||||
struct collision_component
|
||||
{
|
||||
gc_component base;
|
||||
int distance_down;
|
||||
int distance_top;
|
||||
int distance_left;
|
||||
int distance_right;
|
||||
float distance_down;
|
||||
float distance_top;
|
||||
float distance_left;
|
||||
float distance_right;
|
||||
};
|
||||
|
||||
extern const struct collision_component collision_component;
|
||||
+6
-6
@@ -15,8 +15,8 @@ typedef struct quadtree quadtree;
|
||||
|
||||
typedef struct qt_intrect
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
float x;
|
||||
float y;
|
||||
int h;
|
||||
int w;
|
||||
} qt_intrect;
|
||||
@@ -29,10 +29,10 @@ typedef struct qt_object
|
||||
|
||||
typedef struct qt_collision
|
||||
{
|
||||
int distance_left;
|
||||
int distance_right;
|
||||
int distance_top;
|
||||
int distance_down;
|
||||
float distance_left;
|
||||
float distance_right;
|
||||
float distance_top;
|
||||
float distance_down;
|
||||
} qt_collision;
|
||||
|
||||
struct quadtree
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
#include "systems/movable_system.h"
|
||||
#include <stddef.h>
|
||||
|
||||
#include "components/controllable_component.h"
|
||||
|
||||
static void update_entity(gc_engine *engine __attribute__((unused)), \
|
||||
void *system __attribute__((unused)), gc_entity *entity, float dtime)
|
||||
{
|
||||
@@ -31,8 +33,6 @@ void *system __attribute__((unused)), gc_entity *entity, float dtime)
|
||||
if (mov->velocity.y < 0)
|
||||
pos->position.y -= MIN(mov->velocity.y * -dtime, col->distance_down);
|
||||
else {
|
||||
// if (mov->velocity.y != 0)
|
||||
// printf("Velocity y: %4.0f, Moving up of %4.0f\n", mov->velocity.y, mov->velocity.y * dtime);
|
||||
pos->position.y += MIN(mov->velocity.y * dtime, col->distance_top);
|
||||
}
|
||||
if (col->distance_left == 0 || col->distance_right == 0)
|
||||
|
||||
Reference in New Issue
Block a user