Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
dddba186cd
@ -19,6 +19,7 @@ int IAEngine(PLAYER * player1, PLAYER * player2)
|
|||||||
{
|
{
|
||||||
//Player 1 est le joueur, player 2 le bot
|
//Player 1 est le joueur, player 2 le bot
|
||||||
if((player1 != NULL) & (player2 !=NULL))
|
if((player1 != NULL) & (player2 !=NULL))
|
||||||
|
char Race[20];
|
||||||
{
|
{
|
||||||
//On récupère les positions des 2 joueurs . L'IA sait où est le joueur
|
//On récupère les positions des 2 joueurs . L'IA sait où est le joueur
|
||||||
int Player1PositionX = player1->PositionX;
|
int Player1PositionX = player1->PositionX;
|
||||||
|
@ -2,17 +2,92 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "fileHandler.h"
|
#include "fileHandler.h"
|
||||||
#include <SDL2/SDL_thread.h>
|
|
||||||
#include <SDL2/SDL_mutex.h>
|
|
||||||
|
|
||||||
int initResources(tilesList) {
|
int initResources() {
|
||||||
resOpen();
|
//resOpen();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void genNewArena(int w, int h, ARENA_TILE* a[][]) {
|
ARENA_H_TILE* createHTile(ARENA_H_TILE* prevHTile) {
|
||||||
a = malloc(sizeof(ARENA_TILE) * w * h);
|
ARENA_H_TILE* tile_h = NULL;
|
||||||
|
|
||||||
|
if (prevHTile == NULL) {
|
||||||
|
tile_h = calloc(1,sizeof(ARENA_H_TILE)); //Using calloc because of resetting all memory allocated to 0
|
||||||
|
tile_h->type_id = 0;
|
||||||
|
tile_h->isGround = 1;
|
||||||
|
tile_h->canBeMined = 0;
|
||||||
|
tile_h->nextRow = NULL;
|
||||||
|
tile_h->nextColumn = NULL;
|
||||||
|
|
||||||
|
return tile_h;
|
||||||
|
} else if (prevHTile != NULL) {
|
||||||
|
tile_h = calloc(1,sizeof(ARENA_H_TILE));
|
||||||
|
prevHTile->nextRow = tile_h;
|
||||||
|
tile_h->type_id = 0;
|
||||||
|
tile_h->isGround = 1;
|
||||||
|
tile_h->canBeMined = 0;
|
||||||
|
tile_h->nextRow = NULL;
|
||||||
|
tile_h->nextColumn = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
ARENA_W_TILE* createWTile(ARENA_H_TILE* prevHTile, ARENA_W_TILE* prevWTile) {
|
||||||
|
ARENA_W_TILE* tile_w = NULL;
|
||||||
|
|
||||||
|
if (prevHTile != NULL && prevWTile == NULL) {
|
||||||
|
tile_w = calloc(1,sizeof(ARENA_W_TILE));
|
||||||
|
prevHTile->nextColumn = tile_w;
|
||||||
|
tile_w->type_id = 0;
|
||||||
|
tile_w->isGround = 1;
|
||||||
|
tile_w->canBeMined = 0;
|
||||||
|
tile_w->nextColumn = NULL;
|
||||||
|
|
||||||
|
return tile_w;
|
||||||
|
} else if (prevHTile == NULL && prevWTile != NULL) {
|
||||||
|
tile_w = calloc(1,sizeof(ARENA_W_TILE));
|
||||||
|
prevWTile->nextColumn = tile_w;
|
||||||
|
tile_w->type_id = 0;
|
||||||
|
tile_w->isGround = 1;
|
||||||
|
tile_w->canBeMined = 0;
|
||||||
|
tile_w->nextColumn = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
ARENA_H_TILE* genNewArena(int w, int h) {
|
||||||
|
ARENA_H_TILE* arenaOrigin = NULL;
|
||||||
|
ARENA_H_TILE* TmpCursor_h = NULL;
|
||||||
|
ARENA_W_TILE* TmpCursor_w = NULL;
|
||||||
|
int i,j;
|
||||||
|
|
||||||
|
for(i=0;i<h;i++){
|
||||||
|
if (i==0) {
|
||||||
|
arenaOrigin = createHTile(NULL);
|
||||||
|
TmpCursor_h = arenaOrigin;
|
||||||
|
} else {
|
||||||
|
createHTile(TmpCursor_h);
|
||||||
|
}
|
||||||
|
|
||||||
|
for(j=0;j<w;j++){
|
||||||
|
if (j==0) {
|
||||||
|
TmpCursor_w = createWTile(TmpCursor_h, NULL);
|
||||||
|
} else {
|
||||||
|
createWTile(NULL, TmpCursor_w);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (j!=0) TmpCursor_w = TmpCursor_w->nextColumn;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i!=0) TmpCursor_h = TmpCursor_h->nextRow;
|
||||||
|
}
|
||||||
|
|
||||||
|
return arenaOrigin;
|
||||||
|
}
|
||||||
|
|
||||||
|
int deleteArena(ARENA_H_TILE* genNewArena) {
|
||||||
|
|
||||||
for
|
|
||||||
}
|
}
|
||||||
|
@ -9,16 +9,25 @@ typedef struct items{
|
|||||||
//texture?
|
//texture?
|
||||||
int isFlat;
|
int isFlat;
|
||||||
int minedId;
|
int minedId;
|
||||||
struct items;
|
struct items *nextItem;
|
||||||
}ITEMS;
|
}ITEMS;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
typedef struct a_tile{
|
typedef struct arena_h_tile{ //Rows chained list
|
||||||
int type_id;
|
int type_id;
|
||||||
//texture?
|
//texture?
|
||||||
int isFlat;
|
int isGround;
|
||||||
int canBeMined;
|
int canBeMined;
|
||||||
//struct a_tile nextTile;
|
struct arena_h_tile *nextRow;
|
||||||
}ARENA_TILE;
|
struct arena_w_tile *nextColumn;
|
||||||
|
}ARENA_H_TILE;
|
||||||
|
|
||||||
|
typedef struct arena_w_tile{ //Columns chained list
|
||||||
|
int type_id;
|
||||||
|
//texture?
|
||||||
|
int isGround;
|
||||||
|
int canBeMined;
|
||||||
|
struct arena_w_tile *nextColumn;
|
||||||
|
}ARENA_W_TILE;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
5
main.c
5
main.c
@ -10,6 +10,11 @@
|
|||||||
#include "SDL2/SDL.h"
|
#include "SDL2/SDL.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include "logHelper.h"
|
||||||
|
#include "SDL2/SDL.h"
|
||||||
|
#include "SDL2/SDL_thread.h"
|
||||||
|
#include "SDL2/SDL_mutex.h"
|
||||||
|
#include "arenaEngine.h"
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
|
@ -9,7 +9,7 @@ void initDisplayLib() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int createMainWindows() {
|
int createGameMenuWindows() {
|
||||||
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
|
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
|
||||||
printf("Erreur chargement librairie SDL ! %s\n",SDL_GetError());
|
printf("Erreur chargement librairie SDL ! %s\n",SDL_GetError());
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
@ -23,3 +23,4 @@ int createMainWindows() {
|
|||||||
SDL_Quit();
|
SDL_Quit();
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user