Simple but useful: Active Actors

Game Editor comments and discussion.

Simple but useful: Active Actors

Postby Hblade » Mon Mar 07, 2011 12:56 am

Hey everyone! :D Here is a little thing I'm doing, called SBU (Simple but useful), and I'm going to be doing quite a lot of these. They're simple functions that allow for a quick help and shortn' things down a bit, so say you have a bunch of stuff you use often, this is what thats for! :D

Sorry if I'm not making any sense I'm super tired >.>


Anyways, this one is "Active Actors", it enables you too activate or de-activate a player via variable. So say if your walking and you want a cutscene to go, all you'd do is this:
Code: Select all
active(0, "player");

and wadda bing the "player" actor becomes unable to do commands xD This is useful for those who are using Draw Actor to handle the players movement.

How to use:
Make an actor variable called "enabled", thats it xD Then in Draw Actor, do this:
Code: Select all
if (enabled) {
    your code here to be ran when enabled is on
}



Now for the actual script:
Code: Select all
void active(int value, char *actor) {
    Actor *act = getclone(actor);
    act->enabled=value;
                                   }


Simple right? but yet so useful xD
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: Simple but useful: Active Actors

Postby lcl » Mon Mar 07, 2011 2:55 pm

Very simple. :D
For making it even more user freindly, use #define.
Like:
#define ENABLED 1
#define DISABLED 0

Then can use: active(DISABLED, "player");
:D

Nice anyway! :)
Last edited by lcl on Mon Mar 07, 2011 4:49 pm, edited 1 time in total.
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: Simple but useful: Active Actors

Postby Game A Gogo » Mon Mar 07, 2011 3:25 pm

are they not already declared defaultly in GE? Some GE functions uses them, so you too can use them without defining them, otherwise it will give you an error
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Re: Simple but useful: Active Actors

Postby Hblade » Mon Mar 07, 2011 3:25 pm

Yeah :P
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: Simple but useful: Active Actors

Postby lcl » Mon Mar 07, 2011 4:49 pm

Game A Gogo wrote:are they not already declared defaultly in GE? Some GE functions uses them, so you too can use them without defining them, otherwise it will give you an error

Yeah. Not sure about ENABLED and DISABLED, but ENABLE and DISABLE are. :D
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: Simple but useful: Active Actors

Postby Hblade » Mon Mar 07, 2011 4:50 pm

Hehe :)
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest