Need help!
Need help!
So, I am recreating a game that I made in VB.Net before but my problem is that I don't know how can I create an array of keyedsurfaces and how do you initialize it if I am not mistaken chili showed it in some tut but I can't remember for sure and I'm not trying to create animated thing but just array of enemies.
Re: Need help!
Not sure if i understand the question. If you just want to create an array and initialize it.
What is a keyedsurface? How are the enemies defined, as a structure?
Code: Select all
Enemy enemiesArray[ numberOfEnemies ];
//Initialize it in a for loop.
for( int i = 0; i < numberOfEnemies; i++ )
{
enemiesArray[ i ] = //Whatever you want...
}
Musi
There are 10 types of people that understand binary.
Those that do, and those that don't.
There are 10 types of people that understand binary.
Those that do, and those that don't.
Re: Need help!
Yea, sorry my question was not very clear but I'm trying to create a game where theres enemies scrolling from top and you are in the bottom and you must shoot all the enemies, so I got to the point where I have the player and one enemy but I want multiple enemies to come from the top... I hope I made the question clearerMusi wrote:Not sure if i understand the question. If you just want to create an array and initialize it.What is a keyedsurface? How are the enemies defined, as a structure?Code: Select all
Enemy enemiesArray[ numberOfEnemies ]; //Initialize it in a for loop. for( int i = 0; i < numberOfEnemies; i++ ) { enemiesArray[ i ] = //Whatever you want... }
Re: Need help!
You want multiple enemies at the same time? Or only 1 at the time?
If you want multiple units then use the method Musi is showing you.
It's the method that Chili teaches in his videos ( I think lesson 12-13-14, something around there ).
I had a pretty hard time understanding that concept at first too.
But basically all that loop does for you is making multiple 'unique' entities because each of them has a different 'sub-name' ( [ index ] ) that is defined by the array index number.
So, in example.... if you want 3 entities... you make 3 unique entities of the same type by looping the entity (accessing) by index:
This creates multiple entities like entity[0], entity[1] and entity[2]. The amount depends on the value you assigned to "numberOfTargets" which is defined by yourself at first, ( see video Beginner Lesson 13: http://www.youtube.com/watch?v=rcx3VbSv0yI ).
And every time your frame is reloaded (like 60 times a second or '60 fps') this loop reads the entity array again. So then you can do all kind of freaky things with it because they all have the unique-subname.
You can make one disappear by making it collide with another, or with your target-reticle or whatever, or you could simply redefine the current location of an entity (make them move). All because they are seperate entities because of this array definition.
Isn't that beautiful
* Edit : Typos
If you want multiple units then use the method Musi is showing you.
It's the method that Chili teaches in his videos ( I think lesson 12-13-14, something around there ).
I had a pretty hard time understanding that concept at first too.
But basically all that loop does for you is making multiple 'unique' entities because each of them has a different 'sub-name' ( [ index ] ) that is defined by the array index number.
So, in example.... if you want 3 entities... you make 3 unique entities of the same type by looping the entity (accessing) by index:
Code: Select all
for( int index = 0; index < numberOfTargets; index++)
{
entity[ index ] = /* make them whatever you like */ ;
}
And every time your frame is reloaded (like 60 times a second or '60 fps') this loop reads the entity array again. So then you can do all kind of freaky things with it because they all have the unique-subname.
You can make one disappear by making it collide with another, or with your target-reticle or whatever, or you could simply redefine the current location of an entity (make them move). All because they are seperate entities because of this array definition.
Isn't that beautiful
* Edit : Typos
Re: Need help!
Okay, Thanks for help!natox1986 wrote:You want multiple enemies at the same time? Or only 1 at the time?
If you want multiple units then use the method Musi is showing you.
It's the method that Chili teaches in his videos ( I think lesson 12-13-14, something around there ).
I had a pretty hard time understanding that concept at first too.
But basically all that loop does for you is making multiple 'unique' entities because each of them has a different 'sub-name' ( [ index ] ) that is defined by the array index number.
So, in example.... if you want 3 entities... you make 3 unique entities of the same type by looping the entity (accessing) by index:This creates multiple entities like entity[0], entity[1] and entity[2]. The amount depends on the value you assigned to "numberOfTargets" which is defined by yourself at first, ( see video Beginner Lesson 13: http://www.youtube.com/watch?v=rcx3VbSv0yI ).Code: Select all
for( int index = 0; index < numberOfTargets; index++) { entity[ index ] = /* make them whatever you like */ ; }
And every time your frame is reloaded (like 60 times a second or '60 fps') this loop reads the entity array again. So then you can do all kind of freaky things with it because they all have the unique-subname.
You can make one disappear by making it collide with another, or with your target-reticle or whatever, or you could simply redefine the current location of an entity (make them move). All because they are seperate entities because of this array definition.
Isn't that beautiful
* Edit : Typos
Re: Need help!
No problem, I hope it helps... if you don't understand parts of it, just check out the video again.Vellelzza wrote:Okay, Thanks for help!
If you still have issues then, just ask!