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.

Author
Message
btecbuddies
21
Years of Service
User Offline
Joined: 21st Oct 2002
Location: United Kingdom
Posted: 16th Dec 2002 17:19
I am doing a game like the swarm and I am trying to get the individual enemys to move on there own and am having no luck. Can anyone here help me with my problem. Thanks in advance.
The Darthster
21
Years of Service
User Offline
Joined: 25th Sep 2002
Location: United Kingdom
Posted: 17th Dec 2002 00:56
How are you trying to move the enemies at the moment? To get a lot of enemies to move independently, I'd use an array of position, and maybe rotation data. The advantage of an array is that you can also get all the enemies to move together. You simply create an array, enemy(20,4), and into the second dimension of the array you put various attributes:

(note I'm using i as a standard index, i must be replaced with a number corresponding to the array index of the enemy or a looping variable)

enemy(i,0) is the x position of the enemy
enemy(i,1) is the z position
enemy(i,2) is the y rotation
enemy(i,3) is a life flag.

To move the enemies, just put new values into the array, for example

enemy(i,0)=enemy(i,0)+1

would move the enemy right, by incrementing it's x position.

Then to position all the enemies, use a for..next loop and use the array accordingly:

for i=0 to 19
position object i,enemy(i,0),0,enemy(i,1)
yrotate object i,enemy(i,2)
if enemy(i,3)=1 then show object i else hide object i
next i

This is a very basic explanation, I hope you understand it.
btecbuddies
21
Years of Service
User Offline
Joined: 21st Oct 2002
Location: United Kingdom
Posted: 6th Jan 2003 16:42
The movement technique that I am using is the same as the Swarm and it seems that he use a different method to you because he does not have a life flag in his array.

The thing that I am trying to do with his code is to not only have the formation to move as a whole but also have some aliens move indivdually. So can you help me with this task.

Thanks in advance

The Darthster
21
Years of Service
User Offline
Joined: 25th Sep 2002
Location: United Kingdom
Posted: 7th Jan 2003 00:21
You'll have to rewrite his code then, since it doesn't expand well. He uses one position, and puts all the aliens relative to that. You'll need to make an array, like I said above. Then you can use for...next loops to update all the aliens at once, or access them directly using their index in the array.
btecbuddies
21
Years of Service
User Offline
Joined: 21st Oct 2002
Location: United Kingdom
Posted: 7th Jan 2003 12:07
I have been looking at the code a he seems to use a section called objid in his array this maybe his version of the life flag. His array looks like the following.

enemy#(enemymax,1) = objid
enemy#(enemymax,2) Is the x position
enemy#(enemymax,3) Is the y position
enemy#(enemymax,4) I am not sure what this one is
enemy#(enemymax,5) Is the enemies type

and he also uses a loop like you but it is more complicated then the one you gave me but I can see some of the parts that you gave me this is what his part looks like.

For e=1 to enemymax

Objid = enemy#(e,1)

Position object objid, alienshiftx#+enemy#(e,2),alienshifty#+enemy#(e,3),-1

Yrotate object objid,wrapvalue(180-(cos(enemy#(e,4))*10.0))
Enemy#(e,4) = wrapvalue(enemy#(e,4)+16)

Ax# = object position x (enemy#(e,1))
Ay# = object position y (enemy#(e,2))

btecbuddies
21
Years of Service
User Offline
Joined: 21st Oct 2002
Location: United Kingdom
Posted: 20th Jan 2003 11:48
So if I were to rewrite the code using the same concept that you talked about then it would be possible to move some of the aliens indivdual using if statements or would i use another process.

btecbuddies
21
Years of Service
User Offline
Joined: 21st Oct 2002
Location: United Kingdom
Posted: 28th Jan 2003 17:02
I have started to rewrite the code but the code that you gave is that moving all of the aliens to the right once or is it moving one all the way to the right. Also what does the enemy(i,0),0,enemy(i,1) zero in between that sentence do.

Login to post a reply

Server time is: 2024-05-05 01:28:40
Your offset time is: 2024-05-05 01:28:40