Storing and Controlling Actors

You must understand the Game Editor concepts, before post here.

Storing and Controlling Actors

Postby DST » Fri Sep 18, 2009 6:26 pm

I am looking for more information about Actor*.

1st - can you store an actor permanently? If so, where would you store them?

2nd - can you store actors in an array? If so, is there any kind of vector or dynamic list class that can change sizes on the fly?
It's easier to be clever than it is to be kind.
http://www.lostsynapse.com
http://www.dstgames.com
User avatar
DST
 
Posts: 1117
Joined: Sun Apr 15, 2007 5:36 pm
Location: 20 minutes into the future
Score: 151 Give a positive score

Re: Storing and Controlling Actors

Postby makslane » Mon Sep 21, 2009 12:56 pm

You can store the pointer to an actor, and you can use an array of pointers like:

Code: Select all
Actor **myactors;


But you need to control the allocation of the array:

Code: Select all
myactors = (Actor **)malloc(MAX_ACTORS*sizeof(Actor**));


Where MAX_ACTORS can be defined by you.
Other way is use some data struct, like a linked list to make more good use of the memory (you only alloc what you need).

In any case, you need to update the array when an actor is destroyed (In the Destroy Actor event).
You need to get a pointer to the event actor:

Code: Select all
Actor *eventActor = getclone(clone name of the event actor);


And update the array:

Code: Select all
RemoveActorFromMyArray(eventActor);


What you will do in the RemoveActorFromMyArray function depends of the data structure used.
If you have used an array, you need to scan the array until get a entry thats have the eventActor pointer and make this entry NULL.
If you have used a map (hash tables, ...) you can make this process faster!
Game Editor is an open source game creator software that's wants to pay it's developers to keep evolving.
If you like Game Editor, make a review!
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Re: Storing and Controlling Actors

Postby Bee-Ant » Tue Sep 22, 2009 12:20 am

Umm,so one pointer for one actor?
What if we have 50x50 array?
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

Re: Storing and Controlling Actors

Postby makslane » Tue Sep 22, 2009 12:27 pm

One pointer array for all actors.
Game Editor is an open source game creator software that's wants to pay it's developers to keep evolving.
If you like Game Editor, make a review!
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score


Return to Advanced Topics

Who is online

Users browsing this forum: No registered users and 1 guest