I am making a game where I have a background image of a neighborhood. Each location has a different number of customers that are generated to walk on sidewalks. They all walk to a specific location (like a stand or cart that sells stuff), after they get to location I want them to interact with the cart. However, if another customer is already in a sale interaction then the others get in line in order of arrival. After the transaction the customers walk off screen. Any information on how I can do this and what game engine would be needed? Any one have any idea where I should go for this. I already have my game done up through Eclipse/Java without any game engine.
|
|
What you are looking for is a Queue, check the destination, and if there is already somebody there, add the person to the queue, and then query the queue to figure out where to stand (you can use vectors to figure out where exactly to stand in the line) Best I could give you is C++ code, so see if this works...
If anybody knows what to do better, please feel free to edit this! |
|||
|
|
|
Use the number of customers in line to offset the destination. For example, say the line is below the stand at Use the distance formula to check and see if the customer is in range.
If the distance is small enough, then the customer is in range to "see" the booth. To actually move the customer, find the unit components of the distance, and then multiply by your desired speed.
Then just move by uxdist and uydist each frame. This will get them to the line. Once distance is around zero, he reached the line and gets assigned a queue number and stops. When a customer in front is served, he moves up in the queue, walks to the spot designated for that queue, and stops. Let's say for example, he is third in line. A signal is sent that the line is moving, and so he moves up as second in line. His destination becomes |
|||
|
|