| Well, here is what I have so far as far as code, or at least what I have tested in compiles and runs.
EGAD!!! Cut and paste works terrible here! Or is there another way to post code?
Thanks!
Cheawick.
//simplega.cpp
#include<dos.h> //for the clear screen function
#include<stdio.h>
#include<stdlib.h>
#include<time.h> //for random
#include<iostream.h>
#define VIDEO 0x10 //video interrupt for clear screen
#define COLS 80 //screen width for clear screen
#define ROWS 25 //screen rows for clear screen
void cls(void); //for the clear screen function
void locate(int col,int row); //for the clear screen
void randomgen(void); //random number generator
//not sure if it is correctly defined in order to pass
//values back to the calling functions
int rnd(int range);
void seedrnd(void);
int main()
{
cls(); //clear the screen
cout<<"This is a non-interactive simple game named SIMPLEGA\n";
cout<<"When the enter key is pressed, six units called Cores will be generated.\n";
cout<<"\nThe following are the three type classes that make up a Core.\n";
//display body, target, and attack including the 3 possible values of each
//example: body= life 20, life 25, life 30 >not needing this exact format<
//example: target= random core, core with high life, core with low life
//example: attack= damage 10, damage 12, damage 15
//wait for enter key
//create six random generated cores
//display the stats of the six cores
//cout<<"\nPress enter when ready to battle.\n";
//wait for enter key
//step 1: determine target of each core excluding themselves from the list
//step 2: determine damage to each core
//step 3: determine any dead cores
//step 4: update and display core stats storing new values for each core life
//step 5: wait for enter key
//step 6: nullify dead cores from list and determine active cores
//step 7: return to step 1 until one or all cores dead
//when core=1 or 0 display rounds and core stats
randomgen(); //does not belong here, just using it to check prog flow
cout<<"\nThe program has ended.\n"; //the true end of the program indicator
return 0;
}
void cls(void) //for clear screen function
{
union REGS regs;
regs.h.ah=0x06; //func 6, scroll window
regs.h.al=0x00; //clear screen
regs.h.bh=0x07; //make screen "blank"
regs.h.ch=0x00; //upper left row
regs.h.cl=0x00; //upper left column
regs.h.dh=ROWS-1; //lower right row
regs.h.dl=COLS-1; //lower right column
int86(VIDEO,®s,®s);
locate(0,0); //home the cursor
}
void locate(int col,int row) //for clear screen function
{
union REGS regs;
regs.h.ah=0x02; //vid func 2, move cursor
regs.h.bh=0x00; //video screen (always 0)
regs.h.dh=row; //cursor's row position
regs.h.dl=col; //cursor's col position
int86(VIDEO,®s,®s);
}
/*NOTE TO SELF!!! MAY NEED TO CHANGE THE STATIC NUMBER IN THE FOR STATEMENT
TO A VARIABLE TO ALLOW OTHER FUNCTIONS (SUCH AS EACH CLASS AND DAMAGE ROLLS)
THE ABILITY TO PASS THEIR OWN VALUES ON. PROBABLY HAVE TO INITIALIZE THE VALUE
OF THE VARIABLE BACK TO 0 BEFORE ASSIGNING IT A NEW VALUE.*/
void randomgen()
{
int x;
seedrnd();
//display 6 numbers
for(x=0;x<6;x++) //THIS SIX IS SET FOR THE CORES MAY NEED CHANGE
printf("%i\t",rnd(3));
}
int rnd(int range)
{
int r;
r=rand()%range+1 ; //spit out random number, I added the +1 for no zeros
return(r);
}
void seedrnd(void)
{
srand((unsigned)time(NULL));
} |