diff --git a/travail_de_groupe/jeu_appren_par_renfo/src/gest_event.c b/travail_de_groupe/jeu_appren_par_renfo/src/gest_event.c index 2275efbec66f03609d9abc0fa5d17e8b0b9db394..ae9b39dcf3c477c9e5f1f16ee091715d18d470da 100644 --- a/travail_de_groupe/jeu_appren_par_renfo/src/gest_event.c +++ b/travail_de_groupe/jeu_appren_par_renfo/src/gest_event.c @@ -3,6 +3,14 @@ int Keys[NB_KEYS]; +void initKeys(){ + int i; + for(i = 0; i < NB_KEYS; i++) + { + Keys[i] = 0; + } +} + void gestMenu(){ SDL_Event event; while (SDL_PollEvent(&event)){ diff --git a/travail_de_groupe/jeu_appren_par_renfo/src/gest_event.h b/travail_de_groupe/jeu_appren_par_renfo/src/gest_event.h index 90f0faa8a6597eff6af0e58c13c42ca7a3cd64a4..9256d7dd965c715db4fa68367bbcd0e589793475 100644 --- a/travail_de_groupe/jeu_appren_par_renfo/src/gest_event.h +++ b/travail_de_groupe/jeu_appren_par_renfo/src/gest_event.h @@ -10,5 +10,6 @@ extern int Keys[NB_KEYS]; void *EventLoop(void *arg); +void initKeys(); #endif \ No newline at end of file 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 ac05036e66735a4cdcbe30b8ebc7ffcf21111139..01189fd475b3db8e7dd26bdf4a5ddeea764dc816 100644 --- a/travail_de_groupe/jeu_appren_par_renfo/src/main.c +++ b/travail_de_groupe/jeu_appren_par_renfo/src/main.c @@ -10,6 +10,7 @@ int main(){ readMapFromFile("map.txt"); printMap(); initPlayer(); + initKeys(); mainLoop(); 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 f46be1b9db2b84fcc4e4b81f24c27ec87b13f551..5296dbc64f44966c1d67324279ea357389cb9ea0 100644 --- a/travail_de_groupe/jeu_appren_par_renfo/src/player.c +++ b/travail_de_groupe/jeu_appren_par_renfo/src/player.c @@ -3,16 +3,16 @@ player_t player; void initPlayer(){ - player.x= 4*BLOCK_SIZE; - player.y= 4*BLOCK_SIZE; + player.x= 6*BLOCK_SIZE; + player.y= 6*BLOCK_SIZE; player.speed = 1; player.isMoving = 0; player.HPMax = 3; player.currentHP = player.HPMax; player.coins = 0; player.angle=0; - player.deltax = cos(player.angle); - player.deltay = -sin(player.angle); + player.deltax = 0; + player.deltay = 1; player.viewAngle = 0; } diff --git a/travail_de_groupe/jeu_appren_par_renfo/src/render.c b/travail_de_groupe/jeu_appren_par_renfo/src/render.c index 3a271bdfa4fb593bdf21cdcc0347128aacb88e0e..6768e8e95bde263e2332a43c4dcb4d037ca71c5b 100644 --- a/travail_de_groupe/jeu_appren_par_renfo/src/render.c +++ b/travail_de_groupe/jeu_appren_par_renfo/src/render.c @@ -29,13 +29,13 @@ SDL_Texture * loadTexture(char * path) { void initRays(){ int i; rays = malloc(sizeof(int*) * 2 * NB_RAYS); - for (i = 0; i < NB_RAYS; i++){ + for (i = 0; i < NB_RAYS * 2; i++){ rays[i] = malloc(sizeof(int) * 2); } } void addRayToList(int x, int y){ - if (raysListLength < NB_RAYS){ + if (raysListLength < 2 * NB_RAYS){ *rays[raysListLength] = x; *(rays[raysListLength] + 1) = y; raysListLength++; @@ -44,7 +44,7 @@ void addRayToList(int x, int y){ void resetRayList(){ int i; - for (i = 0; i < NB_RAYS; i++){ + for (i = 0; i < 2 * NB_RAYS; i++){ *rays[i] = 0; *(rays[i] + 1) = 0; } @@ -332,6 +332,7 @@ void drawRays(int map[][MAP_WIDTH]){ drawRayColumn(ra, distT, r, foundTransparentWallV, direction, htexture); // draw the ray in the minimap addRayToList(rx, ry); + addRayToList(rx2, ry2); } } @@ -378,7 +379,7 @@ void drawMap2D(int map[][MAP_WIDTH]){ rect.x = 0; } SDL_SetRenderDrawColor(renderer, 255, 255, 0, 255); - for (i = 0; i < NB_RAYS; i++){ + for (i = 0; i < raysListLength; i++){ SDL_RenderDrawLine(renderer, player.x * CELL_SIZE / BLOCK_SIZE , player.y * CELL_SIZE / BLOCK_SIZE, rays[i][0] * CELL_SIZE / BLOCK_SIZE, rays[i][1] * CELL_SIZE / BLOCK_SIZE); } SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);