about summary refs log tree commit diff
path: root/src/simulator/rendering.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/simulator/rendering.c')
-rw-r--r--src/simulator/rendering.c20
1 files changed, 8 insertions, 12 deletions
diff --git a/src/simulator/rendering.c b/src/simulator/rendering.c
index 05a93f4..f94700b 100644
--- a/src/simulator/rendering.c
+++ b/src/simulator/rendering.c
@@ -1,5 +1,4 @@
 #include "rendering.h"
-#include "SDL_stdinc.h"
 #include "../game.h"
 
 #include <SDL2/SDL.h>
@@ -161,34 +160,31 @@ void render_agent(SDL_Renderer *renderer, Agent agent) {
 }
 
 void render_game(SDL_Renderer *renderer, const Game *game) {
-  for (size_t i = 0; i < AGENTS_COUNT; ++i) {
-    render_agent(renderer, game->agents[i]);
-  }
 
   // Render Foods
   const int indices[] = {0, 1, 2, 0, 3, 2};
   for(int y = 0; y < BOARD_HEIGHT; ++y) {
     for (int x = 0; x < BOARD_WIDTH; ++x) {
-      if (game->foods_map[y][x]) {
+      int env = game->env_map[y][x];
+      if (env == ENV_MAP_FOOD) {
         SDL_Vertex *vertices = sdl_draw_food_diamond(y, x);
         scc(SDL_RenderGeometry(renderer, NULL, vertices, 4, indices, 6));
         free(vertices); // sdl_draw_food_diamond's malloc
       }
 
-      if (game->walls_map[y][x]) {
+      if (game->env_map[y][x] == ENV_MAP_WALL) {
         SDL_Rect rect = {// Check why int floorf
                          (int)floorf(x * CELL_WIDTH),
                          (int)floorf(y * CELL_HEIGHT),
                          (int)floorf(CELL_WIDTH), (int)floorf(CELL_HEIGHT)};
         SDL_SetRenderDrawColor(renderer, HEX_COLOR(WALL_COLOR));
         SDL_RenderFillRect(renderer, &rect);
+      } else if(env >= ENV_MAP_AGENTS) {
+        int agent_index = env - ENV_MAP_AGENTS;
+        if (game->agents[agent_index].health > 0) {
+          render_agent(renderer, game->agents[agent_index]);
+        }
       }
     }
   }
-
-  // Render Walls
-  for (size_t i = 0; i < WALLS_COUNT; ++i) {
-
-  }
-
 }