From 36b3c6c1600d6ade2884352a9321dc627f85e652 Mon Sep 17 00:00:00 2001
From: antoinemeyer5 <antoine.meyer54@gmail.com>
Date: Wed, 29 Jun 2022 13:45:23 +0200
Subject: [PATCH] nouvelle map, ajout de la balle

---
 travail_de_groupe/jeu_appren_par_renfo/map.txt    |  7 -------
 travail_de_groupe/jeu_appren_par_renfo/src/ball.c | 11 ++++++++++-
 travail_de_groupe/jeu_appren_par_renfo/src/ball.h | 15 ++++++++++-----
 travail_de_groupe/jeu_appren_par_renfo/src/main.c |  1 +
 travail_de_groupe/jeu_appren_par_renfo/src/map.h  |  2 +-
 .../jeu_appren_par_renfo/src/player.c             | 11 -----------
 .../jeu_appren_par_renfo/src/player.h             |  1 -
 7 files changed, 22 insertions(+), 26 deletions(-)

diff --git a/travail_de_groupe/jeu_appren_par_renfo/map.txt b/travail_de_groupe/jeu_appren_par_renfo/map.txt
index d5439ec..9fe6181 100644
--- a/travail_de_groupe/jeu_appren_par_renfo/map.txt
+++ b/travail_de_groupe/jeu_appren_par_renfo/map.txt
@@ -7,11 +7,4 @@
 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
-1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
-1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
-1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
-1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
-1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
-1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
-1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
\ No newline at end of file
diff --git a/travail_de_groupe/jeu_appren_par_renfo/src/ball.c b/travail_de_groupe/jeu_appren_par_renfo/src/ball.c
index 53710e5..5c73891 100644
--- a/travail_de_groupe/jeu_appren_par_renfo/src/ball.c
+++ b/travail_de_groupe/jeu_appren_par_renfo/src/ball.c
@@ -1,10 +1,19 @@
 #include "ball.h"
 
-//ball_t ball;
+ball_t ball;
 int trajectoireAntoine[NUMBERPOINT_TRAJEC][2];
 
 void initBall()
 {
+    ball.x = 5 * BLOCK_SIZE;
+    ball.y = 5 * BLOCK_SIZE;
+    ball.z = player.h/BLOCK_SIZE;
+    ball.h = 0.5 * BLOCK_SIZE;
+    ball.w = 0.5 * BLOCK_SIZE;    
+    ball.isHit = 0;
+    ball.angle = -pi;
+    ball.speed = 0;
+
 }
 
 float defineAngle(int canonX, int canonY, int xDropPoint, int yDropPoint)
diff --git a/travail_de_groupe/jeu_appren_par_renfo/src/ball.h b/travail_de_groupe/jeu_appren_par_renfo/src/ball.h
index ded489c..2f22f9a 100644
--- a/travail_de_groupe/jeu_appren_par_renfo/src/ball.h
+++ b/travail_de_groupe/jeu_appren_par_renfo/src/ball.h
@@ -6,6 +6,8 @@
 #include <stdio.h>
 #include <math.h>
 
+#include "render.h"
+
 #define NUMBERPOINT_TRAJEC 50
 
 typedef enum
@@ -16,14 +18,17 @@ typedef enum
 
 typedef struct ball
 {
-    int x;
-    int y;
-    int z;
+    float x;
+    float y;
+    float z;
+    int h;
+    int w;
+    int isHit;
     float angle;
-    float speed;
+    int speed;
 } ball_t;
 
-//extern ball_t ball;
+extern ball_t ball;
 extern int trajectoireAntoine[NUMBERPOINT_TRAJEC][2];
 
 void initBall();
diff --git a/travail_de_groupe/jeu_appren_par_renfo/src/main.c b/travail_de_groupe/jeu_appren_par_renfo/src/main.c
index 37ab948..6a04d46 100644
--- a/travail_de_groupe/jeu_appren_par_renfo/src/main.c
+++ b/travail_de_groupe/jeu_appren_par_renfo/src/main.c
@@ -14,6 +14,7 @@ int main(){
     //printMap();
     initPlayer();
     initKeys();
+    initBall();
 
     mainLoop();
 
diff --git a/travail_de_groupe/jeu_appren_par_renfo/src/map.h b/travail_de_groupe/jeu_appren_par_renfo/src/map.h
index 0ba0db5..13c7cf8 100644
--- a/travail_de_groupe/jeu_appren_par_renfo/src/map.h
+++ b/travail_de_groupe/jeu_appren_par_renfo/src/map.h
@@ -5,7 +5,7 @@
 
 
 #define MAP_WIDTH 31
-#define MAP_HEIGHT 17
+#define MAP_HEIGHT 10
 
 
 extern int map[MAP_HEIGHT][MAP_WIDTH];
diff --git a/travail_de_groupe/jeu_appren_par_renfo/src/player.c b/travail_de_groupe/jeu_appren_par_renfo/src/player.c
index df20975..1e399c4 100644
--- a/travail_de_groupe/jeu_appren_par_renfo/src/player.c
+++ b/travail_de_groupe/jeu_appren_par_renfo/src/player.c
@@ -1,11 +1,8 @@
 #include "player.h"
 
 player_t player;
-
 player_t ennemy;
 
-player_t ball;
-
 int *landingPoint;
 int *lastHitPoint;
 
@@ -21,10 +18,6 @@ void initPlayer()
     ennemy.x = 20 * BLOCK_SIZE;
     ennemy.y = 10 * BLOCK_SIZE;
     ennemy.angle = -pi;
-    ball.h = 0.5 * BLOCK_SIZE;
-    ball.w = 0.5 * BLOCK_SIZE;
-    ball.x = 10 * BLOCK_SIZE;
-    ball.y = 10 * BLOCK_SIZE;
     player.speed = 1;
     player.isMoving = 0;
     player.HPMax = 3;
@@ -34,10 +27,6 @@ void initPlayer()
     player.deltax = 1;
     player.deltay = 0;
     player.viewAngle = 0;
-    ball.z = player.h/BLOCK_SIZE;
-    ball.isHit = 0;
-    ball.speed = 0;
-    ball.angle = -pi;
 }
 
 int *generateLandingPoint()
diff --git a/travail_de_groupe/jeu_appren_par_renfo/src/player.h b/travail_de_groupe/jeu_appren_par_renfo/src/player.h
index 11c624b..6e59c1a 100644
--- a/travail_de_groupe/jeu_appren_par_renfo/src/player.h
+++ b/travail_de_groupe/jeu_appren_par_renfo/src/player.h
@@ -36,7 +36,6 @@ typedef struct player{
 
 extern player_t player;
 extern player_t ennemy;
-extern player_t ball;
 
 void initPlayer();
 void managePlayer();
-- 
GitLab