merge
This commit is contained in:
11
Makefile
11
Makefile
@@ -1,7 +1,7 @@
|
|||||||
# Variable
|
# Variable
|
||||||
CC = gcc
|
CC = gcc
|
||||||
CFLAGS = -Wall -Wextra $(shell pkg-config --cflags --libs sdl2)
|
CFLAGS = -Wall -Wextra $(shell pkg-config --cflags --libs sdl2)
|
||||||
OBJ = main.o function.o
|
OBJ = main.o function.o display.o
|
||||||
TARGET = sokoban
|
TARGET = sokoban
|
||||||
|
|
||||||
all: $(TARGET)
|
all: $(TARGET)
|
||||||
@@ -9,11 +9,14 @@ all: $(TARGET)
|
|||||||
$(TARGET): $(OBJ)
|
$(TARGET): $(OBJ)
|
||||||
$(CC) $(CFLAGS) $(OBJ) -o $(TARGET)
|
$(CC) $(CFLAGS) $(OBJ) -o $(TARGET)
|
||||||
|
|
||||||
main.o : main.c
|
main.o : main.c function.h
|
||||||
$(CC) $(CFLAGS) -c main.c
|
$(CC) $(CFLAGS) -c main.c
|
||||||
|
|
||||||
function.o : function.c
|
function.o : function.c function.h
|
||||||
$(CC) $(CFLAGS) -c function
|
$(CC) $(CFLAGS) -c function.c
|
||||||
|
|
||||||
|
display.o: display.c display.h
|
||||||
|
$(CC) $(CFLAGS) -c display.c
|
||||||
|
|
||||||
clean :
|
clean :
|
||||||
rm -f $(OBJ) $(TARGET)
|
rm -f $(OBJ) $(TARGET)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include "display.h"
|
||||||
|
|
||||||
void screenDisplay( unsigned short int **tab,int size)
|
void screenDisplay( unsigned short int **tab,int size)
|
||||||
{
|
{
|
||||||
@@ -8,6 +9,7 @@ void screenDisplay( unsigned short int **tab,int size)
|
|||||||
{
|
{
|
||||||
printf("%hu ",tab[i][j]);
|
printf("%hu ",tab[i][j]);
|
||||||
}
|
}
|
||||||
|
puts("");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
7
display.h
Normal file
7
display.h
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
#ifndef DISPLAY_H
|
||||||
|
#define DISPLAY_H
|
||||||
|
|
||||||
|
void screenDisplay( unsigned short int **tab,int size);
|
||||||
|
|
||||||
|
#endif // !DISPLAY_H
|
||||||
|
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
unsigned short int **creatArea2D(const unsigned int N)
|
unsigned short int **creatArea2D(const unsigned int N)
|
||||||
{
|
{
|
||||||
unsigned short int **tab2d;
|
unsigned short int **tab2d;
|
||||||
tab2d = malloc(sizeof(unsigned short int* ) * N);
|
tab2d = calloc(N, sizeof(unsigned short int* ));
|
||||||
if (tab2d == NULL)
|
if (tab2d == NULL)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -18,7 +18,7 @@ unsigned short int **creatArea2D(const unsigned int N)
|
|||||||
int i;
|
int i;
|
||||||
for (i = 0; i < N && !fail; ++i)
|
for (i = 0; i < N && !fail; ++i)
|
||||||
{
|
{
|
||||||
tab2d[i] = malloc(sizeof(unsigned short int) * N);
|
tab2d[i] = calloc(N, sizeof(unsigned short int));
|
||||||
if (tab2d[i] == NULL)
|
if (tab2d[i] == NULL)
|
||||||
{
|
{
|
||||||
fail = true;
|
fail = true;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#ifdef FONCTION_H
|
#ifndef FONCTION_H
|
||||||
#define FONCTION_H
|
#define FONCTION_H
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|||||||
4
main.c
4
main.c
@@ -1,9 +1,11 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "function.h"
|
#include "function.h"
|
||||||
|
#include "display.h"
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
unsigned short int **tab2d=creatArea2D(5);
|
unsigned short int **tab2d = creatArea2D(5);
|
||||||
|
screenDisplay(tab2d, 5);
|
||||||
printf("main\n");
|
printf("main\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user