1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <conio.h>
#define LIGNES 20
#define COLONNES 40
#define SOL ' '
#define ARAIGNEE 207
//Déclaration structure héros//
struct Heros
{
int Corps, Intellect, Esprit, Or, Endurance, Habilete;
char Nom[20];
};
typedef struct Heros sHeros;
//Déclaration structure Monstre//
struct Monstre
{
char Symbol;
char* Espece;
int Endurance, Habilete, Degats;
};
typedef struct Monstre sMob;
//declaration procédure de combat//
void combat(sHeros unJoueur, sMob unTableauDeMobs[LIGNES][COLONNES], int Coordonnee1, int Coordonnee2);
int main()
{
//Declaration personnage//
sHeros Player;
//Introduction//
printf("\n Nom du personnage : ");
scanf("%s",Player.Nom);
system("cls");
printf("\n Bienvenue %s.\n",Player.Nom);
printf(" Une fois dans le donjon, tapez ? pour une liste des commandes, \n ainsi qu'une legende.\n");
fflush(stdin);
getchar();
system("cls");
//Attribution des caracteristiques//
Player.Or=0;
srand(time(NULL));
Player.Corps= 10 + rand()%7;
Player.Intellect= 10 + rand()%7;
Player.Esprit= 10 + rand()%7;
Player.Endurance=(Player.Corps)*2+Player.Esprit;
Player.Habilete=((Player.Corps)*2+Player.Esprit+Player.Intellect)/4;
//Déclaration des types de monstres//
sMob VIDE={SOL,"Vide",0,0,0};
sMob SPID={ARAIGNEE,"Araignee",3,10,3};
//Map de monstres//
sMob MobMap[LIGNES][COLONNES]=
{
...... //Je vous épargne le tableau, il est très long et n'apporte rien ici//
}
return(0);
}
//Sous programme de combat//
void combat(sHeros joueur, sMob map[LIGNES][COLONNES], int x, int y)
{
int jo,jm;
srand(time(NULL));
jo=joueur.Habilete + rand()%6 + rand()%6;
jm=(map[x][y].Habilete) + rand()%6 + rand()%6;
if (jm>jo)
{
*joueur.Endurance = (joueur.Endurance-map[x][y].Degats);
printf("%s vous attaque et vous a blesse.", map[x][y].Espece);
}
if (jo>jm)
{
*map[x][y].Endurance = (map[x][y].Endurance-2);
printf("Vous avez touché %s.", map[x][y].Espece);
}
if (jo=jm)
{
printf("%s vous a rate, et vous ne touchez pas %s non plus.", map[x][y].Espece, map[x][y].Espece);
}
} |
Partager