more robust data collection
This commit is contained in:
@@ -5,44 +5,39 @@
|
||||
#include "player.h"
|
||||
|
||||
void checkCollision(){
|
||||
float playerx=0.0;
|
||||
float playery=0.0;
|
||||
float plrsize=0.0;
|
||||
objdet[MAX_ENTITIES][4];
|
||||
|
||||
//array structure:
|
||||
// [entitiy #1][entity obj,x,y,size]
|
||||
// [entitiy #2][entity obj,x,y,size]
|
||||
// etc...
|
||||
|
||||
for (int i = 0; i < MAX_ENTITIES; i++){
|
||||
Entity *e = &entities[i];
|
||||
|
||||
if (!e->active)
|
||||
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){10000, 1000}
|
||||
);
|
||||
if(dir){
|
||||
ApplyForce(
|
||||
player,
|
||||
(Vector2){(curhorvel*3), 1000}
|
||||
);
|
||||
}
|
||||
else{
|
||||
}
|
||||
objdet[i][0]=e;
|
||||
objdet[i][1]=e->position.x;
|
||||
objdet[i][2]=e->position.y;
|
||||
objdet[i][3]=e->size;
|
||||
}
|
||||
for(int u=0; u<=MAX_ENTITIES; u++){
|
||||
for(int j=0; u<=MAX_ENTITIES; u++){
|
||||
if(u!=j){
|
||||
if(objdet[u][1]<objdet[j][1]){
|
||||
ApplyForce(
|
||||
player,
|
||||
(Vector2){-(curhorvel*3), 1000}
|
||||
);
|
||||
objdet[u][0],
|
||||
(Vector2){10000, 0}
|
||||
);
|
||||
ApplyForce(
|
||||
objdet[j][0],
|
||||
(Vector2){-10000, 0}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
playerx=e->position.x;
|
||||
playery=e->position.y;
|
||||
if(playery==playery)
|
||||
|
||||
plrsize=e->size;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user