I like ARPG games,e.g. Baldur' Gate.
In the game,at first you must roll to decide your character's 6 attribute.It use 3 dices which each has 6 sides.
We can write a program to realize it.
It's a simple program,but every thing comes from simple.Code:#include<stdio.h> #include<time.h> #include<stdlib.h> main() { int i=0,attr[6]; /* the array use to save 6 attribute*/ int rand_num; /*use to save the random numerical value */ randomize(); /*Init-random number*/ do { rand_num=random(6)+1; attr[i]=rand_num*3; ++i; }while(i<6); /*The "do...while" use to save the attribute value to array*/ for(i=0;i<6;i++){printf("%d",attr[i]);} }
We can expand it ,also can make more functions.
[code][/code]tagged by Salem



LinkBack URL
About LinkBacks



