still wip

This commit is contained in:
2026-06-17 14:36:14 -04:00
parent 3c5019bb46
commit f580ced394
5 changed files with 43 additions and 2 deletions

View File

@@ -4,5 +4,36 @@
#include "collision.h"
void checkCollision(){
for(int i; s)
float playerx=0.0;
float playery=0.0;
float plrsize=0.0;
for (int i = 0; i < MAX_ENTITIES; i++){
Entity *e = &entities[i];
if (!e->active)
continue;
if(e->isPlayer == false){
float objposx=e->position.x;
//float objposy=e->position.y;
float objsize=e->size;
if(playerx-(plrsize/2)<objposx+(objsize/2) && playerx-(plrsize/2)>objposx-(objsize/2)){
ApplyForce(
e,
(Vector2){1000, 1000}
);
ApplyForce(
player,
(Vector2){-1000, 1000}
);
}
}
else{
playerx=e->position.x;
playery=e->position.y;
if(playery==playery)
plrsize=e->size;
}
}
}

8
src/collision.h Normal file
View File

@@ -0,0 +1,8 @@
#ifndef COLLISION_H
#define COLLISION_H
// FUNction declaration! yay!!!
// run by main.c constantly to allow player input.
void checkCollision();
#endif

View File

@@ -78,6 +78,7 @@ int main(void)
{
// allow player to be controlled, fit everything within the size of the screen
UpdatePlayerControls();
checkCollision();
UpdateEntities(dt, screenWidth);
simTime += dt;