Need algorithm for private variables and transitions

For questions about using Classic.

Post » Thu Nov 19, 2009 6:21 am

Alright, so I'm trying to come up with my own algorithm for constantly obtaining the X and Y positions of my NPCs using private variables. But before I would put it all into events, I need to ask if is possible.

Since there will be a time where the player will leave the layout, and would eventually come back. What I need is for the game to record each NPCs current X and Y pos the moment the player left the layout, and when he gets back, it will just load it up and will cause the NPCs to be recreated at the same positions they were when the player left the layout.

So how would I do that?

Another is how do I play a transition that will only cause the player to transfer to a different position, not layout? I was thinking that if the player goes out of the house, there will be a small transition, like the circle and will cause the screen to go black, then will fade and at the moment, the player will already be outside of the house.

How do I do that? Helps will be much appreciated.
B
10
S
5
G
8
Posts: 203
Reputation: 4,395

Post » Thu Nov 19, 2009 6:27 am

For your first question. You can do it a number of ways.
I'm not sure if making the NPC's global will keep their values or not, but if it does you could just go:
start of level: set NPC position to VariableX and VariableY.

Or you could store the info in global values, or save them in an external file or what ever. Then just set the positions at the start.
B
134
S
65
G
16
Posts: 1,765
Reputation: 19,188

Post » Thu Nov 19, 2009 11:56 am

Hmmm... But I will be having like around 50 or so NPCs in one layout since that layout will more likely be a town or city map. Would that mean 50+ global variables?
B
10
S
5
G
8
Posts: 203
Reputation: 4,395

Post » Thu Nov 19, 2009 6:06 pm

Use a Hash Table to keep track of your town. When the player leaves, cycle through each townie with a loop and record their X/Y in the Hash Table. When the town loads, cycle through the table and create each townie in the X/Y that is stored in the table.

You could give each townie a PV for it's index in the Hash Table, essentially naming them 1 through 50, so it would be easier to loop them.

You could even keep track of other things for your townies, like what conversation they've already had or whatever... anything that needs to be global. Then you just make your Hash Table global, and your townies won't need to be global.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 3 guests