int in_floor(struct Rectangle *rect)
{
for (int i = 0; i < stages[level].platform_count; i++) {
- if (CheckCollisionRecs(*rect, stages[level].platforms[i].rect)) { return 1; };
+ if (CheckCollisionRecs(*rect, stages[level].platforms[i].rect)) {
+ if (!(stages[level].platforms[i].rect.y == rect->y + rect->height)) {// this would mean rect is just sitting on top of it
+ return 1; //we dont want it to return 1 if they're just on the floor
+ };
+ };
};
return 0;
}
{
p->rect.x += stepx;
p->rect.y += stepy;
- if (!on_floor(&p->rect) && in_floor(&p->rect)) {
+ if (in_floor(&p->rect)) {
p->rect.x -= stepx; p->rect.y -= stepy;
for (;i < steps_phys; i++) {
if (stepx > 0) {p->rect.x += 1; if (in_floor(&p->rect)) { p->rect.x-=1; };} else if (stepx < 0) {p->rect.x -= 1; if (in_floor(&p->rect)) { p->rect.x+=1; };};