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 / Multiple sprites

Author
Message
Newbie to 3d
20
Years of Service
User Offline
Joined: 20th May 2004
Location:
Posted: 10th Aug 2005 19:22
Hi, I'm using DB Classic and tried to make multiple sprites at the same time but I find it very confusing. How do I use multiple sprites like in an rpg game that has npc moving constantly while the main character walks freely? Thanks
master programmer
19
Years of Service
User Offline
Joined: 30th May 2005
Location: 3D Space
Posted: 11th Aug 2005 06:50
Well, simply (and you could print out a copy of the sprite numbers that correspond with what if you want), you load the images, then make them sprites. I would try to make you a code, but I can't figure out what "npc" means. Sorry.

Newbie to 3d
20
Years of Service
User Offline
Joined: 20th May 2004
Location:
Posted: 11th Aug 2005 07:12
Hi, thanks for the reply I'm really not good with Darkbasic. I meant like people in a town like in a rpg that you can interact with but they are animated sprites.

npc = non player character because I just want to try to make a little 2d offline rpg or adventure genre
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 11th Aug 2005 11:49 Edited at: 11th Aug 2005 11:50
Non-Player Character

Characters that are in the game and not controlled by the player.
NanoBrain
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Portland, OR
Posted: 11th Aug 2005 12:26 Edited at: 11th Aug 2005 12:27
master programmer,

NPC stands for Non-Player Character.

Newbie to 3d,

To control multiple NPCs simultaneously, you must first setup a general NPC engine. Think of the engine as a set of rules and instructions that drive the characters, which is accually what it is. Technically, it is a load of IF statements, or what-not, that make the characters to do something, based off the rules given for each possible situation they can face.

To make each NPC follow these rules, simultaneously, you use arrays in connection with each different sprite. However, to create the engine, forget about the array, and code the rules for a single sprite, first. Elsewise, coding the engine can get really confusing.

Let us start out very basic. Let us make a single NPC that roams around in random directions(left, right, up or down), changing its direction at random times. This code should be easy to follow.

Example 1:


Basically, we have a random movement engine for our single NPC. Now, we can implement this same code to work for a variable amount of NPCs, all at the same time. We do so by replacing the variables used, with an array or two. First, let us create more than one sprite NPC, each with their own unit number. Let us use a for next loop to do so, efficiently. Also, create an array, where each slot has 5 dimensions. Slot 1 holds the NPC's x coordinate, slot 2 = y coordinate, slot 3 = time, slot 4 = duration, and slot 5 = direction. Let us fill these slots from within the loop. Look below for what we have so far.

Example 2:


Simply, lets use this same method around the engine. Let us wrap the engine in a for next loop, and replace all the variables with the array. This brings to life our map of fully simultaneously engined, working NPCs.

Example 3:


Again said, this is just very basic, to show you the fundamentals of using an array or more, and the for next loop, to task mutiple NPCs simultaneously. The movement here is all random. However, it can get much more difficult and interesting than this, like using scripted movement, and boundary movement. It all depends on your program's needs, and the engine you build. Think about what you need, build the engine, then apply it to the NPCs. Note, that an engine doesn't have to be a set of instructions(sequential IF statements), but can be a formatted value file. That, the program reads the values within a text document, in a certain layout, to create a looped or scripted movement. Using this method, each NPC can be ran by the same engine, but have different set movements. Ever seen where an NPC follows the same path back and forth. Well, it is not hard-coded.


+NanoBrain+
master programmer
19
Years of Service
User Offline
Joined: 30th May 2005
Location: 3D Space
Posted: 12th Aug 2005 10:16
OK thanks, now I REALLY know what NPC is thanks.

Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 13th Aug 2005 09:13
With 3 people telling you the same thing you better know!

Login to post a reply

Server time is: 2024-09-24 01:21:41
Your offset time is: 2024-09-24 01:21:41