Skip to content
Snippets Groups Projects
Commit f2a824f8 authored by maberet's avatar maberet
Browse files

Ajout des structures monster et player

parent a8572d25
No related branches found
No related tags found
No related merge requests found
#include "monster.h"
monster_t monster;
int markov[SIZEMARKOV][SIZEMARKOV];
void initMonster (){
monster.x= (rand()%((MAPSIZEX-3)/2)+16)*CELLSIZE;
monster.y= (rand()%(MAPSIZEY-2))*CELLSIZE;
monster.state= PEACEFULL;
monster.healthPoint= 3;
monster.speed=1;
monster.angle=0;
//monster.dammage
}
void readMarkovFromFile(char * filename){
FILE * fp;
int i, j;
fp = fopen(filename, "r");
if(fp == NULL){
printf("Error opening file\n");
exit(1);
}
for(i = 0; i < SIZEMARKOV; i++){
for(j = 0; j < SIZEMARKOV; j++){
fscanf(fp, "%d", &markov[i][j]);
}
}
fclose(fp);
}
#ifndef MONSTER_H
#define MONSTER_H
#include <stdlib.h>
#include <time.h>
#include <stdio.h>
#define ANGRY 1
#define PEACEFULL 0
#define SIZEMARKOV 4
typedef enum {
false,true
}booleen_t;
typedef struct monster {
int x ;
int y;
int healthPoint;
int stateMarkov;
int state;
int speed;
float angle;
}monster_t;
extern monster_t monster;
void initMonster ()
void readMarkovFromFile(char * filename);
#endif
\ No newline at end of file
#include "player.h"
player_t player;
void initPlayer(){
player.x= 8*CELLSIZE;
player.y= 8*CELLSIZE;
player.speed = 1;
player.isMoving = 0;
player.HPMax = 3;
player.currentHP = player.HPMax;
player.coins = 0;
player.angle=0;
}
\ No newline at end of file
#ifndef PLAYER_H
#define PLAYER_H
#define PLAYER_UP 0
#define PLAYER_DOWN 1
#define PLAYER_LEFT 2
#define PLAYER_RIGHT 3
typedef struct player{
int x;
int y;
int speed;
int isMoving;
int direction;
int HPMax;
int currentHP;
int coins;
float angle;
} player_t;
extern player_t player;
#endif
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment