Fixed camera
This commit is contained in:
@@ -81,36 +81,36 @@ void playerInteraction(entity_t *entity) {
|
||||
// Copy to max
|
||||
glm_vec2_copy(interactBox.min, interactBox.max);
|
||||
|
||||
// Size of the hitbox
|
||||
vec2 halfSize = {
|
||||
TILESET_ENTITIES.tileWidth * PLAYER_INTERACTION_SIZE * 0.5f,
|
||||
TILESET_ENTITIES.tileHeight * PLAYER_INTERACTION_SIZE * 0.5f
|
||||
};
|
||||
// // Size of the hitbox
|
||||
// vec2 halfSize = {
|
||||
// 1 * PLAYER_INTERACTION_SIZE * 0.5f,
|
||||
// 1 * PLAYER_INTERACTION_SIZE * 0.5f
|
||||
// };
|
||||
|
||||
// Subtract from min, add to max.
|
||||
glm_vec2_sub(interactBox.min, halfSize, interactBox.min);
|
||||
glm_vec2_add(interactBox.max, halfSize, interactBox.max);
|
||||
// // Subtract from min, add to max.
|
||||
// glm_vec2_sub(interactBox.min, halfSize, interactBox.min);
|
||||
// glm_vec2_add(interactBox.max, halfSize, interactBox.max);
|
||||
|
||||
// For each entity
|
||||
entity_t *start = ENTITIES;
|
||||
entity_t *end = &ENTITIES[ENTITY_COUNT];
|
||||
vec2 otherSize = { TILESET_ENTITIES.tileWidth, TILESET_ENTITIES.tileHeight };
|
||||
physicsbox_t otherBox;
|
||||
physicsboxboxresult_t result;
|
||||
// // For each entity
|
||||
// entity_t *start = ENTITIES;
|
||||
// entity_t *end = &ENTITIES[ENTITY_COUNT];
|
||||
// vec2 otherSize = { 1, 1 };
|
||||
// physicsbox_t otherBox;
|
||||
// physicsboxboxresult_t result;
|
||||
|
||||
do {
|
||||
if(start->type != ENTITY_TYPE_NPC) continue;
|
||||
// do {
|
||||
// if(start->type != ENTITY_TYPE_NPC) continue;
|
||||
|
||||
// Setup other box.
|
||||
glm_vec2_copy(start->position, otherBox.min);
|
||||
glm_vec2_copy(start->position, otherBox.max);
|
||||
glm_vec2_sub(otherBox.min, otherSize, otherBox.min);
|
||||
glm_vec2_add(otherBox.min, otherSize, otherBox.max);
|
||||
// // Setup other box.
|
||||
// glm_vec2_copy(start->position, otherBox.min);
|
||||
// glm_vec2_copy(start->position, otherBox.max);
|
||||
// glm_vec2_sub(otherBox.min, otherSize, otherBox.min);
|
||||
// glm_vec2_add(otherBox.min, otherSize, otherBox.max);
|
||||
|
||||
physicsBoxCheckBox(interactBox, otherBox, &result);
|
||||
if(!result.hit) continue;
|
||||
// physicsBoxCheckBox(interactBox, otherBox, &result);
|
||||
// if(!result.hit) continue;
|
||||
|
||||
printf("Interacted with entity at (%.2f, %.2f)\n", start->position[0], start->position[1]);
|
||||
break;
|
||||
} while(++start != end);
|
||||
// printf("Interacted with entity at (%.2f, %.2f)\n", start->position[0], start->position[1]);
|
||||
// break;
|
||||
// } while(++start != end);
|
||||
}
|
||||
Reference in New Issue
Block a user