Skip to content
Snippets Groups Projects
Commit fa25bd96 authored by Marie AUDOUARD's avatar Marie AUDOUARD
Browse files

Add hitbox for real

parent 78e8a369
No related branches found
No related tags found
No related merge requests found
#include "hitbox.hpp"
bool hitbox::is_in_hitbox(vec3 pos) {
for (int i = 0; i < N; i++) {
if (norm(pos - pos[i]) < r[i]) return true;
}
return false;
}
void hitbox::initialize_bat(double scale, vec3 posB, vec3 posWL, vec3 posWR)
{
N = 3;
pos.resize(N);
r.resize(N);
pos[0] = posB;
r[0] = 1 * scale;
pos[1] = posWL;
r[1] = 0.5 * scale;
pos[2] = posWR;
r[2] = 0.5 * scale;
}
void hitbox::update_bat(vec3 posB, vec3 posWL, vec3 posWR) {
pos[0] = posB;
pos[1] = posWL;
pos[2] = posWR;
}
\ No newline at end of file
#pragma once
#include "cgp/cgp.hpp"
using namespace cgp;
struct hitbox {
int N;
std::vector<vec3> pos;
std::vector<double> r;
void initialize_bat(double scale, vec3 posB, vec3 posWL, vec3 posWR);
void update_bat(vec3 posB, vec3 posWL, vec3 posWR);
bool is_in_hitbox(vec3 pos);
};
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment