Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 04-27-2004, 02:06 AM   #1 (permalink)
cheawick
Regular Contributor
 
cheawick's Avatar
 
Join Date: Dec 2003
Location: Mary Esther, FL
Posts: 189
cheawick is on a distinguished road
Question array tutorials?

Can anyone point out some good tutorials on initializing and using arrays and matrices?
Thanks!
cheawick is offline   Reply With Quote
Old 04-27-2004, 06:28 PM   #2 (permalink)
Valmont
[code][/code] enforcer
 
Valmont's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 1,544
Valmont is on a distinguished road
Just about every tutorial on the net or in a book covers arrrays. Is there something in particular you want to know?
__________________
Valmont is offline   Reply With Quote
Old 04-28-2004, 02:22 AM   #3 (permalink)
cheawick
Regular Contributor
 
cheawick's Avatar
 
Join Date: Dec 2003
Location: Mary Esther, FL
Posts: 189
cheawick is on a distinguished road
Question

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!
cheawick is offline   Reply With Quote
Old 04-28-2004, 02:25 AM   #4 (permalink)
cheawick
Regular Contributor
 
cheawick's Avatar
 
Join Date: Dec 2003
Location: Mary Esther, FL
Posts: 189
cheawick is on a distinguished road
Oops! I forgot to mention that there are six different instances(?)of the three values running at the same time.
cheawick is offline   Reply With Quote
Old 04-28-2004, 04:46 AM   #5 (permalink)
Valmont
[code][/code] enforcer
 
Valmont's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 1,544
Valmont is on a distinguished road
It's ok. As long as you realize that pointer handling and array handling goes hand in hand.
__________________
Valmont is offline   Reply With Quote
Old 04-28-2004, 09:10 AM   #6 (permalink)
cheawick
Regular Contributor
 
cheawick's Avatar
 
Join Date: Dec 2003
Location: Mary Esther, FL
Posts: 189
cheawick is on a distinguished road
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...
cheawick is offline   Reply With Quote
Old 04-28-2004, 04:27 PM   #7 (permalink)
Valmont
[code][/code] enforcer
 
Valmont's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 1,544
Valmont is on a distinguished road
Well, not "hand in hand" perse. Although they are related.
__________________
Valmont is offline   Reply With Quote
Old 04-29-2004, 02:32 AM   #8 (permalink)
cheawick
Regular Contributor
 
cheawick's Avatar
 
Join Date: Dec 2003
Location: Mary Esther, FL
Posts: 189
cheawick is on a distinguished road
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,&regs,&regs);
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,&regs,&regs);
}

/*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));
}
cheawick is offline   Reply With Quote
Old 04-29-2004, 02:33 AM   #9 (permalink)
cheawick
Regular Contributor
 
cheawick's Avatar
 
Join Date: Dec 2003
Location: Mary Esther, FL
Posts: 189
cheawick is on a distinguished road
Never mind about the appearance issue, I see it looks better than on the posting board.

Cheawick.
cheawick is offline   Reply With Quote
Old 04-29-2004, 03:54 AM   #10 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,726
redhead is on a distinguished road
just write [ code] [/ code] around what you want kept with the required indentation.
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Old 04-29-2004, 04:07 AM   #11 (permalink)
cheawick
Regular Contributor
 
cheawick's Avatar
 
Join Date: Dec 2003
Location: Mary Esther, FL
Posts: 189
cheawick is on a distinguished road
I'm assuming you mean [ code] at the beginning and [/ code] at the end? Yes?
cheawick is offline   Reply With Quote
Old 04-29-2004, 05:26 AM   #12 (permalink)
Valmont
[code][/code] enforcer
 
Valmont's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 1,544
Valmont is on a distinguished road
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.
Valmont is offline   Reply With Quote
Old 04-29-2004, 03:14 PM   #13 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,532
sde is on a distinguished road
-- split --

http://codenewbie.com/forum/t1876.html
__________________
Mike
sde is offline   Reply With Quote
Old 04-29-2004, 03:43 PM   #14 (permalink)
cheawick
Regular Contributor
 
cheawick's Avatar
 
Join Date: Dec 2003
Location: Mary Esther, FL
Posts: 189
cheawick is on a distinguished road
Quote:
Originally posted by sde
-- split --

http://codenewbie.com/forum/t1876.html
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?
cheawick is offline   Reply With Quote
Old 04-29-2004, 07:45 PM   #15 (permalink)
Valmont
[code][/code] enforcer
 
Valmont's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 1,544
Valmont is on a distinguished road
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.
__________________
Valmont is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
working with Array Goong MS Technologies ( ASP, VB, C#, .NET ) 3 07-22-2004 01:14 PM
breaking down an array from a form metazai PHP 12 07-09-2004 07:18 AM
tutorials suggestion inkedmn Feedback 2 03-19-2004 12:12 AM
array max num Apodysophilia Java 9 04-10-2003 07:36 AM
adding to an array in php sde PHP 1 06-12-2002 12:04 PM


All times are GMT -8. The time now is 12:36 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0 RC8 ©2007, Crawlability, Inc.





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting