www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/03/25/20:43:06

Date: Tue, 25 Mar 1997 19:29:58 -0600 (CST)
From: Andrew Deren <aderen AT eecs DOT uic DOT edu>
To: Lee Simons <lee AT dialin DOT co DOT uk>
cc: djgpp AT delorie DOT com
Subject: Re: C++ Class Help
In-Reply-To: <199703252129.VAA02177@post.dialin.co.uk>
Message-ID: <Pine.SUN.3.95.970325192755.25918A-100000@ernie.eecs.uic.edu>
MIME-Version: 1.0

Why don't you use a loop to initialize all palyers

#define NUM_PALYERS 1000
Player data[1000];
for (int i=0; i<NUM_PLAYERS; i++){
data[i].SetSpeed(99);
data[i].SetSkill(100);
}


On Tue, 25 Mar 1997, Lee Simons wrote:

> Hi,
> 
> I'm writing a football game, and as in real life football there are lots of
> players.
> I'm going to create and object array of a class Player.  This class will
> hold information about the players, such as skill, speed etc.  It will also
> hold the players position in xyz space and it's personal functions, for
> telling the program what its skill is, shooting, passing, and player AI.
> 
> I want to declare the array, like so:
> 
> Player data[1000]; // 1000 players in data array =)
> 
> But, the problem is, I don't want to use loads of functions to set the
> player's data. Like:
> 
> data[0].SetSkill(100);
> data[0].SetSpeed(99);
> 
> etc..
> 
> I would like to be able to do a:
> 
> data[0](100, 99)
> 
> sort of thing.  Where 100 is the skill as shown in the other example, and
> 99 is the speed.
> 
> Thanks a lot in advance.
> 
> Lee
> 

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019