|  | |  |
04-27-2004, 02:06 AM
|
#1 (permalink)
| | Regular Contributor
Join Date: Dec 2003 Location: Mary Esther, FL
Posts: 189
| array tutorials? Can anyone point out some good tutorials on initializing and using arrays and matrices?
Thanks! |
| |
04-27-2004, 06:28 PM
|
#2 (permalink)
| | [code][/code] enforcer
Join Date: Mar 2003 Location: Netherlands
Posts: 1,544
| Just about every tutorial on the net or in a book covers arrrays. Is there something in particular you want to know?
__________________ |
| |
04-28-2004, 02:22 AM
|
#3 (permalink)
| | Regular Contributor
Join Date: Dec 2003 Location: Mary Esther, FL
Posts: 189
| Thanks for the reply!
I'm trying to figure out how to write an array (or matrice) that will hold three different values and can be rewritten (or perhaps better to say updated).
It's part of a "game" (if you could call such a non-interactive thing such). If you want to see what code I have so far I'll email it to you, I'd wager it is too large to post here.
Thanks! |
| |
04-28-2004, 02:25 AM
|
#4 (permalink)
| | Regular Contributor
Join Date: Dec 2003 Location: Mary Esther, FL
Posts: 189
| Oops! I forgot to mention that there are six different instances(?)of the three values running at the same time. |
| |
04-28-2004, 04:46 AM
|
#5 (permalink)
| | [code][/code] enforcer
Join Date: Mar 2003 Location: Netherlands
Posts: 1,544
| It's ok. As long as you realize that pointer handling and array handling goes hand in hand.
__________________ |
| |
04-28-2004, 09:10 AM
|
#6 (permalink)
| | Regular Contributor
Join Date: Dec 2003 Location: Mary Esther, FL
Posts: 189
| Umm. Pointer handling? I've heard of pointers, but never encounter their use as of until now. Would you be so kind as to elighten me on this subject?
Cheawick... |
| |
04-28-2004, 04:27 PM
|
#7 (permalink)
| | [code][/code] enforcer
Join Date: Mar 2003 Location: Netherlands
Posts: 1,544
| Well, not "hand in hand" perse. Although they are related.
__________________ |
| |
04-29-2004, 02:32 AM
|
#8 (permalink)
| | Regular Contributor
Join Date: Dec 2003 Location: Mary Esther, FL
Posts: 189
| 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));
} |
| |
04-29-2004, 02:33 AM
|
#9 (permalink)
| | Regular Contributor
Join Date: Dec 2003 Location: Mary Esther, FL
Posts: 189
| Never mind about the appearance issue, I see it looks better than on the posting board.
Cheawick. |
| |
04-29-2004, 03:54 AM
|
#10 (permalink)
| | Newbie
Join Date: Jun 2002 Location: Denmark
Posts: 1,726
| just write [ code] [/ code] around what you want kept with the required indentation. |
| |
04-29-2004, 04:07 AM
|
#11 (permalink)
| | Regular Contributor
Join Date: Dec 2003 Location: Mary Esther, FL
Posts: 189
| I'm assuming you mean [ code] at the beginning and [/ code] at the end? Yes? |
| |
04-29-2004, 05:26 AM
|
#12 (permalink)
| | [code][/code] enforcer
Join Date: Mar 2003 Location: Netherlands
Posts: 1,544
| Quote: Originally posted by cheawick I'm assuming you mean [ code] at the beginning and [/ code] at the end? Yes? | Yes. Try it. Just edit your post and insert them.
Just a tip: learn to place comments above the line of code. Not to the right of it.
Besides that, you are using a pure (16 bit) dos program, calling in86. These days Win32 api calls are used. I have VC versions so I cannot check out your code, since later VC versions don't generate pure DOS programs.
But if you like to move on with pure dos programs then here is a some reading for you: 256 color programming
Good luck!
__________________
Last edited by Valmont; 04-29-2004 at 11:12 AM.
|
| |
04-29-2004, 03:14 PM
|
#13 (permalink)
| | Moderator
Join Date: May 2002 Location: us.ca
Posts: 4,532
|
__________________ Mike |
| |
04-29-2004, 03:43 PM
|
#14 (permalink)
| | Regular Contributor
Join Date: Dec 2003 Location: Mary Esther, FL
Posts: 189
| Sorry SDE, but I don't understand the "--split--" and link below it. The link brings me back to my last post here. Did I miss something? |
| |
04-29-2004, 07:45 PM
|
#15 (permalink)
| | [code][/code] enforcer
Join Date: Mar 2003 Location: Netherlands
Posts: 1,544
| He is new sde  .
Anyway, what problems do you have with DevCPP? Did you download it from my site?
Check out THIS THREAD and see how it goes.
You also asked a question about the full potential of C++ and platform independent programming. First of all, ansi C++ does not know about platforms (like Windows XP), so that problem is solved straight away. Certainly when studying as a novice, you won't be bothered by platforms much (console programs).
But first check out the link I gave you (above) and try to move on from there.
__________________ |
| | | Thread Tools | | | | Display Modes | Linear Mode |
Posting Rules
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is Off | | | All times are GMT -8. The time now is 12:36 AM. |
Copyright © 2000-2008, Milano Interactive Web Hosting provided by Portal 360 Web Hosting |  | |