SOKOBAN

1/12

PROBST Yann

Objectif du projet:

2/12

  • parsing
  • structure
  • génération de la map
  • libncurses
  • gestion d'erreurs

Organisation

3/12

  • réflexion sur feuille
  • documentation
  • exemple
  • étape par étape

Problèmes et solutions

4/12

Découpage du projet:

5/12

        check_fich(av[1], &sokoban);
         if ((fp = fopen(av[1], "r")) == NULL)
            return (-1);
          sokoban.map = get_map(fp, map, sokoban.height, sokoban.width);
          end = my_sokoban(&sokoban);

Découpage du projet:

6/12

typedef struct  s_info
{
  char          **map;
  int           **ocoord;
  int           **xcoord;
  int           **pcoord;
  int           width;
  int           height;
  int           nbro;
  int           nbrx;
}               t_info;

Découpage du projet:

7/12


  mlc_xcoord(sokoban);
  while (i < sokoban->height)
    {
      j = 0;
      while (j < sokoban->width)
        {
          if (sokoban->map[i][j] == 'X')
            {
              sokoban->xcoord[b][0] = i;
              sokoban->xcoord[b][1] = j;
              b++;
            }
          j++;
        }
      i++;

Création de la map:

8/12

 while (sokoban->map[i][++j])
        {
          mvprintw(i, j, "%c", sokoban->map[i][j]);
        }

Mouvement:

9/12

int     move_up(t_info *sokoban, int player[2])
  if ((sokoban->map[player[0] - 1][player[1]]) == ' ')
    {
      sokoban->map[player[0]][player[1]] = ' ';
      player[0] -= k;
      sokoban->map[player[0]][player[1]] = 'P';
    }
  else if ((sokoban->map[player[0] - 1][player[1]]) == 'O')
    {
      sokoban->map[player[0]][player[1]] = ' ';
      player[0] -= k;
      sokoban->map[player[0]][player[1]] = 'P';
    }
  else if (sokoban->map[player[0] - 1][player[1]] == 'X')
      move_u(sokoban, player);

Bonus en couleur:

10/12

Points positifs et améliorations:

11/12

  • Nouvelles compétences
  • Conditions de mouvement
  • Plus de bonus

12/12

before the demonstration :)

deck

By Yann Probst