#include #include #include #include #include #include #include #include #include #include #include "hash.h" #include "structure.h" #include "base.h" #include "entities.h" #include "proj.h" #include "move.h" // ---------------------------------------------------------------------------------------------------- // double sensitivity = 0.06 ; double fov = 90.0 ; double speed = 0.22 ; double min_dist = 0.7 ; // ---------------------------------------------------------------------------------------------------- // int player_hp ; bool stop_evetything; double camx ; double camy ; double camz ; double rot_hz ; double rot_vt ; double tan_fov ; int draw_type ; int fade_dmg ; bool has_changed ; void init_csts() { camx = 2.0 ; camy = 5.0 ; camz = 2.0 ; rot_hz = 0.0 ; rot_vt = 0.0 ; draw_type = 0 ; player_hp = 1000 ; fade_dmg = 0; stop_evetything = false ; tan_fov = tan((fov * 3.14159 / 180.0) / 2.0) ; } void set_player_coords(int old_chx, int old_chy) { for(int k = 0; k < current_room->tps_size; k++) { if(current_room->tps[k]->dest_chx == old_chx && current_room->tps[k]->dest_chy == old_chy) { if(true) { camx = current_room->tps[k]->hitbox->x + current_room->tps[k]->hitbox->w/2.0; camy = current_room->tps[k]->hitbox->y + current_room->tps[k]->hitbox->h +1.5; camz = current_room->tps[k]->hitbox->z + current_room->tps[k]->hitbox->d/2.0; } return ; } } } bool is_colliding(float dtime) { for(int k = 0; k < current_room->map_size; k++) { double dist = distance_pt_cube_0_3d(camx, camy, camz, current_room->map[k]) ; if(dist <= min_dist) { return true ; } } for(int k = 0; k < current_room->tps_size; k++) { double dist = distance_pt_cube_0_3d(camx, camy, camz, current_room->tps[k]->hitbox) ; if(dist <= min_dist) { int old_chx = player_chx ; int old_chy = player_chy ; player_chx = current_room->tps[k]->dest_chx ; player_chy = current_room->tps[k]->dest_chy ; current_room = hashtbl_find_opt(visited, player_chx, player_chy); set_player_coords(old_chx, old_chy); //resetProj(); return true ; } } for(int k = 0; k < current_room->ent_len; k++) { double dist = distance_pt_cube_0_3d(camx, camy, camz, current_room->ents[k].pos) ; if(dist <= min_dist) { if(current_room->ents[k].onHit != NULL) { (*current_room->ents[k].onHit)(dtime, current_room->ents[k].hitpoints, ¤t_room->ents[k].damage, &(*(current_room->ents[k].pos))); if(*(current_room->ents[k].hitpoints) <= 0) { if(current_room->ents[k].onDeath != NULL) { (*current_room->ents[k].onDeath)(dtime); } remove_entity(¤t_room->ents, ¤t_room->ent_memlen, ¤t_room->ent_len, k); } } return true ; } } return false ; }