summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--clld.c31
1 files changed, 17 insertions, 14 deletions
diff --git a/clld.c b/clld.c
index 6303d3d..4dd7a46 100644
--- a/clld.c
+++ b/clld.c
@@ -13,16 +13,17 @@
#include <stdio.h>
#endif
-/* Get the direction of a collision. */
-uint8_t isleft = 0;
-uint8_t isright = 0;
-uint8_t istop = 0;
-uint8_t isbottom = 0;
-uint8_t isinfloor_x = 0;
-uint8_t isinfloor_y = 0;
-
uint8_t get_coldir(uint8_t flt, uint8_t col_type, int hmpeak, struct colis *cursor, struct colis *floor) {
uint8_t coldir = 0;
+
+ /* Get the direction of a collision. */
+ uint8_t isleft = 0;
+ uint8_t isright = 0;
+ uint8_t istop = 0;
+ uint8_t isbottom = 0;
+
+ uint8_t isinfloor_x = 0;
+ uint8_t isinfloor_y = 0;
uint8_t isinfloor_left = 0;
uint8_t isinfloor_right = 0;
uint8_t isinfloor_top = 0;
@@ -145,9 +146,10 @@ uint8_t get_coldir(uint8_t flt, uint8_t col_type, int hmpeak, struct colis *curs
/* Tile Heightmap Collision. */
void thm(int hmpeak, struct colis *cursor, struct colis *floor) {
int newy = 0;
- cursor->clx = (cursor->a2 > floor->a1-cursor->xvel-1 && cursor->b2 > floor->b1) && (cursor->a1 < (floor->a2-cursor->w)-cursor->xvel+1 && cursor->b1 < floor->b2);
- cursor->cly = (cursor->b2 >= floor->b1-cursor->yvel && cursor->a2 >= floor->a1) && (cursor->b1 <= floor->b2-cursor->yvel && cursor->a1 <= floor->a2);
- uint8_t coldir = get_coldir(0, THM, hmpeak, cursor, floor);
+ uint8_t coldir = get_coldir(0, THM , hmpeak, cursor, floor);
+ uint8_t isinfloor = get_coldir(0, AABB, hmpeak, cursor, floor);
+ cursor->clx = (isinfloor & 3) == 3;
+ cursor->cly = (isinfloor & 12) == 12;
if (cursor->clx && (cursor->a2-floor->a1 < 0 || cursor->a2-floor->a1 > floor->w)) {
switch (coldir & 3) {
case 1: cursor->pos.x = (floor->pos.x-cursor->xvel)-cursor->w-1; break;
@@ -187,9 +189,10 @@ void thm(int hmpeak, struct colis *cursor, struct colis *floor) {
/* Floating point Tile Heightmap Collision. */
void fthm(int hmpeak, struct colis *cursor, struct colis *floor) {
int newy = 0;
- cursor->clx = (cursor->c2 > floor->c1-cursor->xvel-1 && cursor->d2 > floor->d1) && (cursor->c1 < (floor->c2-cursor->w)-cursor->xvel+1 && cursor->d1 < floor->d2);
- cursor->cly = (cursor->d2 >= floor->d1-cursor->yvel && cursor->c2 >= floor->c1) && (cursor->d1 <= floor->d2-cursor->yvel && cursor->c1 <= floor->c2);
- uint8_t coldir = get_coldir(1, THM, hmpeak, cursor, floor);
+ uint8_t coldir = get_coldir(0, THM , hmpeak, cursor, floor);
+ uint8_t isinfloor = get_coldir(0, AABB, hmpeak, cursor, floor);
+ cursor->clx = (isinfloor & 3) == 3;
+ cursor->cly = (isinfloor & 12) == 12;
if (cursor->clx && cursor->c2-floor->c1 < -1 || cursor->c2-floor->c1 > floor->w) {
switch (coldir & 3) {