Commit 7a0d812e authored by Paul GEORGES's avatar Paul GEORGES
Browse files

Amélioration Hitbox

parent 28eff848
......@@ -61,12 +61,12 @@ bool detecter_collision_perso(ListeP L, ListeE *LE, SDL_Rect rect, int degats, i
while(L != NULL){
ax1 = rect.x;
ax2 = rect.x + rect.w ;
bx1 = L->data.pos.x;
bx2 = L->data.pos.x + L->data.pos.w;
bx1 = L->data.pos.x - 0.3 * L->data.pos.w;
bx2 = L->data.pos.x + 0.6 * L->data.pos.w;
ay1 = rect.y;
ay2 = rect.y;
by1 = L->data.pos.y;
by2 = L->data.pos.y + L->data.pos.h;
by1 = L->data.pos.y - 0.3 * L->data.pos.h;
by2 = L->data.pos.y + 0.6 * L->data.pos.h;
if(ax1 < bx2 && ax2 > bx1 && ay1 < by2 && ay2 > by1 && L->data.ennemi){
L->data.vie -= degats;
......
......@@ -65,7 +65,7 @@ int main(int argc, char *argv[])
fond = charger_image("sprites/fond.png", ecran, -1, -1, -1);
perso = charger_image("sprites/perso/handgun/idle/survivor_idle.png", ecran, 255, 255, 255);
sprites[0] = perso;
perso = charger_image("sprites/ennemis/zombie/move/zombie_move.png", ecran, 255, 255, 255);
perso = charger_image("sprites/ennemis/zombie/move/zombie_moveV2.png", ecran, 0, 0, -1);
sprites[1] = perso;
perso = charger_image("sprites/effets/blood/blood_hitv3.png", ecran, 0, 0, -1);
sprites[2] = perso;
......
......@@ -17,6 +17,7 @@ Perso nouveau_joueur(SDL_Renderer *renderer, SDL_Texture **sprites){
p.vie = 100;
p.degats = 25;
p.vitesse = 4;
p.yMax = 0;
p.tir = false;
p.ennemi = false;
p.animFlip = 1;
......@@ -30,16 +31,17 @@ Perso nouvel_ennemi_1(SDL_Renderer *renderer, SDL_Texture **sprites){
//gnre des coordonnes de spawn alatoires(provisoire)
p.pos.x = rand()%100 + 0;
p.pos.y = rand()%700 + 0;
p.pos.w = 60;
p.pos.h = 60;
p.pos.w = 50;
p.pos.h = 50;
p.srcrect.x = 0;
p.srcrect.y = 0;
p.srcrect.w = 288;
p.srcrect.h = 311;
p.srcrect.w = 229;
p.srcrect.h = 259;
p.angle = 0;
p.vie = 100;
p.degats = 10;
p.vitesse = 2;
p.yMax = 4403;
p.tir = false;
p.ennemi = true;
p.animFlip = 1;
......@@ -127,14 +129,14 @@ void angle_joueur(Perso *p, float mouseX, float mouseY){
void angle_ennemi(Perso *p){
float angle;
angle = atan2( 350 - (p->pos.y + 20), 500 - (p->pos.x + 20));
angle = atan2(350 - (p->pos.y + 20), 500 - (p->pos.x + 20));
p->angle = angle;
return;
}
void animer_perso(Perso *p){
p->srcrect.y += p->srcrect.h * p->animFlip;
if(p->srcrect.y > 4976|| p->srcrect.y < 0){
if(p->srcrect.y >= p->yMax|| p->srcrect.y < 0){
p->animFlip = -p->animFlip;
p->srcrect.y += p->srcrect.h * p->animFlip;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment