forked from Derailedzack/Client-C-Version
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEntityCollisionTest.c
More file actions
74 lines (65 loc) · 2.1 KB
/
EntityCollisionTest.c
File metadata and controls
74 lines (65 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*
* EntityCollisionTest.c
*
* Created on: Aug 3, 2020
* Author: admin
*/
#include"EntityCollisionTest.h"
#define CUTE_C2_IMPLEMENTATION
#include"cute_c2.h"
void Collsion_init(){
bb2.max = c2V(16.0,0.0f);
bb2.min = c2V(-16.0,0.0f);
Collision_Entity_Data = malloc(sizeof(EntityData));
Collision_Entity_Data->Entity_ID = 1;
Collision_Entity_Data->posX = 1.0f;
Collision_Entity_Data->posY = -1.0f;
Collision_Entity_Data->Entity_Size.height = 32;
Collision_Entity_Data->Entity_Size.width = 32;
}
void Collision_draw(){
if(Current_window == GL){
glRectf(2.0f,0.0f,-4.0f,0.0f);
glBegin(GL_POLYGON);
glColor3f(0.0f,0.0f,1.0f);
glVertex3f(0.25f + Collision_Entity_Data->posX,0.25f + Collision_Entity_Data->posY,0.25f);
glVertex3f(-0.25 + Collision_Entity_Data->posX,0.25f + Collision_Entity_Data->posY,0.25f);
glVertex3f(-0.25f + Collision_Entity_Data->posX,-0.25f + Collision_Entity_Data->posY,-0.25f);
glSecondaryColor3f(9.0f,2.0f,1.0f);
glVertex3f(0.25f + Collision_Entity_Data->posX,-0.25f + Collision_Entity_Data->posY,0.25f);
glVertex3f(0.25f + Collision_Entity_Data->posX,0.25f + Collision_Entity_Data->posY,-0.25f);
glRotatef(0.0f + 10.0f,0.25f + Collision_Entity_Data->posX,-0.25f + Collision_Entity_Data->posY,0.0f);
//glVertex3f(0.5f,-0.5f,0.5f);
glEnd();
/*glBegin(GL_POLYGON);
glColor3f(1.0f,1.0f,1.0f);
glVertex3f(2.0f,2.0f,2.0f);
glVertex3f(-2.0f,2.0f,2.0f);
glVertex3f(-2.0f,2.0f,-2.0f);
glVertex3f(-2.0f,0.0f,-2.0f);
glVertex3f(0.25f,0.25f,0.25f);
glVertex3f(-0.25f,0.0f,0.25f);
glVertex3f(-0.25f,0.25f,-0.25f);
glVertex3f(-0.25f,-0.25f,-0.25f);
glVertex3f(1.0f,1.0f,1.0f);
glEnd();*/
}else if(Current_window == SDL){
}
}
void Collision_redraw(){
Collision_draw();
}
bool CollisionTest_Func(EntityData* entity1,EntityData* entity2){
if(entity1 == NULL && entity2 == NULL){
return false;
}
// if(entity1->Entity_BB == NULL && entity2->Entity_BB){
// return false;
// }else{
int collision = c2AABBtoAABB(entity1->Entity_BB,entity2->Entity_BB);
if(collision){
return true;
}
// }
return false;
}