Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Health

Author
Message
Xan25
15
Years of Service
User Offline
Joined: 4th Mar 2009
Location:
Posted: 5th Mar 2009 02:55
I have run up against a wall in my coding. I'm trying to think of the best way to give my cloned enemies 3 or 4 HP (only one or two). When I think to use a variable it either gets to be to much code, or it effects all my sprites.
I was just wondering if anyone had a suggestion on a good way to do it.
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 5th Mar 2009 18:49
You use an array or equivalent, not a single variable.

A very simple example:


Xan25
15
Years of Service
User Offline
Joined: 4th Mar 2009
Location:
Posted: 6th Mar 2009 01:27
I know this is a dumb question, but when it comes to coding arrays are my weak point, I just don't understand them, so would you mind breaking down the parts of the code snippet you showed me?
you don't have to if you don't want to.
Thanks
AlexI
19
Years of Service
User Offline
Joined: 31st Dec 2004
Location: UK
Posted: 6th Mar 2009 15:21
An array is number of items held with in one varible.

For example a basket of fruit has ten items

char* Fruit[10];

Each fruit has a name

Fruit[0]="Apple";
Fruit[1]="Orange";

an so on.

Hayer
18
Years of Service
User Offline
Joined: 4th Nov 2005
Location: Norway
Posted: 6th Mar 2009 15:30
If you dont understand arrays u can just forget programming more advanced things then "Hello world".

do some google search for a tutorial

Keep it simple.
Questions? Mail me
silenus
15
Years of Service
User Offline
Joined: 4th Mar 2009
Location:
Posted: 6th Mar 2009 15:47
in this example:
char* Fruit[10];

the first item is the "0": Fruit[0]
the last item is the "9": Fruit[9]
when u count from 0 to 9, u got 10 items.

and if u wanna fill your basket automatically:

for (i=0,i<10,i++)
{
Fruit[i]= "Apple";
}
Xan25
15
Years of Service
User Offline
Joined: 4th Mar 2009
Location:
Posted: 6th Mar 2009 18:15
Thank you very much.

Login to post a reply

Server time is: 2024-09-30 19:22:29
Your offset time is: 2024-09-30 19:22:29