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.

Newcomers DBPro Corner / how to control NPCs

Author
Message
G T R
19
Years of Service
User Offline
Joined: 26th Apr 2005
Location: Dubai, UAE
Posted: 9th Oct 2005 02:10
hello

i know how to use dark basic i can load meshs and make a moving
character and stuff and make a level and door and stuff

but the problem is that i cant comeup with the way to
control the objects thats doublicated like if have enemies
how can i apply the same code on each one of them
i thought of using types and arrays and the "for" loop
but i dont know where to start or the best way
it'll be nice if some one explain or give me some hints
or a link to a lesson!
iam using dbp

thanks in advance
Lazlazlaz 1
19
Years of Service
User Offline
Joined: 18th Sep 2005
Location: England
Posted: 9th Oct 2005 03:21
if you read the tutorial that comes with dbpro then it tells you in one of the sections. read the bit about creating enemies.

Hmm
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 9th Oct 2005 05:00
OK, it's a difficult subject to summarise here, but I'll have a bash at it...

As you mentioned in your post, the secret is to use arrays - DB's universal answer to all problems!

OK, let's say you have 24 NPC's in your game and are object numbers 1 to 24.

Assuming that you know what you are going to do with them (AI-wise), then you would normally have a Do..Loop as follows:



OK, to do the same thing to a number of them at the same time, you would need to group them when they are created using an array. For example, you could have 6 groups of 4 in which case you would use the following:

Dim NPC_Group(24)

When you create the NPC's, you could set the array for each one to the group that it's in. Eg if NPC's 1, 2, 3 and 4 are in group 1 then say:

NPC_Group(1)=1
NPC_Group(2)=1
NPC_Group(3)=1
NPC_Group(4)=1

If 5, 6, 7 and 8 are in group 2 then use:

NPC_Group(5)=2
NPC_Group(6)=2
NPC_Group(7)=2
NPC_Group(8)=2

and so on to assign groups to all 24 NPC's.

When you move them, your loop would then look like this:



This is only a simple example, but it demonstrates the method adequately.

TDK_Man

G T R
19
Years of Service
User Offline
Joined: 26th Apr 2005
Location: Dubai, UAE
Posted: 11th Oct 2005 02:06
thnk u guyz for helping out
espicially TDK that helped alot

Login to post a reply

Server time is: 2024-09-24 05:31:15
Your offset time is: 2024-09-24 05:31:15