|
|
|
@ -497,6 +497,15 @@ bool check_collision(Body *one, Body *two, Vect *translation) {
@@ -497,6 +497,15 @@ bool check_collision(Body *one, Body *two, Vect *translation) {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void destroy_physics_collection(struct physics_collection *s) { |
|
|
|
|
for (int i = 0; i < s->numItems; i++) { |
|
|
|
|
free(s->items[i]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
free(s->items); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int get_floor_ceiling();
|
|
|
|
|
void next_level() { |
|
|
|
|
Vect v; |
|
|
|
|
v.x = 0; |
|
|
|
@ -507,7 +516,15 @@ void next_level() {
@@ -507,7 +516,15 @@ void next_level() {
|
|
|
|
|
player.physics->position.y = 0; |
|
|
|
|
player.physics->position = v; |
|
|
|
|
player.physics->next_position = v; |
|
|
|
|
|
|
|
|
|
// destroy_physics_collection(&world.uniques_index[ROOM_W]->room->ceil);
|
|
|
|
|
// destroy_physics_collection(&world.uniques_index[ROOM_W]->room->floor);
|
|
|
|
|
|
|
|
|
|
// still need to free world object
|
|
|
|
|
|
|
|
|
|
level++; |
|
|
|
|
get_floor_ceiling(); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int get_floor_ceiling() { |
|
|
|
@ -519,26 +536,27 @@ int get_floor_ceiling() {
@@ -519,26 +536,27 @@ int get_floor_ceiling() {
|
|
|
|
|
ceil.items = calloc(e.ceil.size - 1, sizeof(Body*)); |
|
|
|
|
|
|
|
|
|
floor.numItems = e.floor.size - 1; |
|
|
|
|
ceil.numItems = e.floor.size - 1; |
|
|
|
|
ceil.numItems = e.ceil.size - 1; |
|
|
|
|
|
|
|
|
|
for (int i = 0; i < e.floor.size-1; i++) { |
|
|
|
|
get_new_physics(&floor.items[i]); |
|
|
|
|
get_new_physics(&ceil.items[i]); |
|
|
|
|
Body *fseg = floor.items[i]; |
|
|
|
|
Body *cseg = floor.items[i]; |
|
|
|
|
Body *cseg = ceil.items[i]; |
|
|
|
|
|
|
|
|
|
fseg->position = *(Vect *)arlst_get(&e.floor, i); |
|
|
|
|
cseg->position = *(Vect *)arlst_get(&e.ceil, i); |
|
|
|
|
|
|
|
|
|
fseg->collision_poly_size = 4; |
|
|
|
|
cseg->collision_poly_size = 4; |
|
|
|
|
fseg->collision_poly = calloc(4, sizeof(Vect)); |
|
|
|
|
fseg->collision_shape = calloc(4, sizeof(Vect)); |
|
|
|
|
|
|
|
|
|
cseg->position = *(Vect *)arlst_get(&e.ceil, i); |
|
|
|
|
cseg->collision_poly_size = 4; |
|
|
|
|
cseg->collision_poly = calloc(4, sizeof(Vect)); |
|
|
|
|
cseg->collision_shape = calloc(4, sizeof(Vect)); |
|
|
|
|
|
|
|
|
|
Vect fthis = fseg->position; |
|
|
|
|
Vect cthis = cseg->position; |
|
|
|
|
|
|
|
|
|
Vect fnext = *(Vect *)arlst_get(&e.floor, i + 1); |
|
|
|
|
Vect cnext= *(Vect *)arlst_get(&e.ceil, i + 1); |
|
|
|
|
|
|
|
|
@ -548,8 +566,8 @@ int get_floor_ceiling() {
@@ -548,8 +566,8 @@ int get_floor_ceiling() {
|
|
|
|
|
double crise = cnext.y - cthis.y; |
|
|
|
|
double crun = cnext.x - cthis.x; |
|
|
|
|
|
|
|
|
|
double fdepth = fabs(frise) * 2 + 100;
|
|
|
|
|
double cdepth = -fabs(crise) * 2 + 100; |
|
|
|
|
double fdepth = -(fabs(frise) * 2 + 100);
|
|
|
|
|
double cdepth = fabs(crise) * 2 + 100; |
|
|
|
|
|
|
|
|
|
fseg->collision_shape[0].x = 0; |
|
|
|
|
fseg->collision_shape[0].y = 0; |
|
|
|
@ -561,7 +579,7 @@ int get_floor_ceiling() {
@@ -561,7 +579,7 @@ int get_floor_ceiling() {
|
|
|
|
|
fseg->collision_shape[2].y = frise + fdepth; |
|
|
|
|
|
|
|
|
|
fseg->collision_shape[3].x = 0; |
|
|
|
|
fseg->collision_shape[3].y = frise + cdepth; |
|
|
|
|
fseg->collision_shape[3].y = frise + fdepth; |
|
|
|
|
|
|
|
|
|
cseg->collision_shape[0].x = 0; |
|
|
|
|
cseg->collision_shape[0].y = 0; |
|
|
|
@ -570,10 +588,10 @@ int get_floor_ceiling() {
@@ -570,10 +588,10 @@ int get_floor_ceiling() {
|
|
|
|
|
cseg->collision_shape[1].y = crise; |
|
|
|
|
|
|
|
|
|
cseg->collision_shape[2].x = crun; |
|
|
|
|
cseg->collision_shape[2].y = crise + fdepth; |
|
|
|
|
cseg->collision_shape[2].y = crise + cdepth; |
|
|
|
|
|
|
|
|
|
cseg->collision_shape[3].x = 0; |
|
|
|
|
cseg->collision_shape[3].y = crise + fdepth; |
|
|
|
|
cseg->collision_shape[3].y = crise + cdepth; |
|
|
|
|
|
|
|
|
|
default_update_collision_poly(cseg); |
|
|
|
|
default_update_collision_poly(fseg); |
|
|
|
@ -1261,7 +1279,7 @@ void startgame(SDL_Renderer * ren) {
@@ -1261,7 +1279,7 @@ void startgame(SDL_Renderer * ren) {
|
|
|
|
|
logwrite(INFO, "STARTGAME"); |
|
|
|
|
get_input_map(); |
|
|
|
|
|
|
|
|
|
level = 0; |
|
|
|
|
level = 2; |
|
|
|
|
|
|
|
|
|
world = create_world(); |
|
|
|
|
|
|
|
|
|