Activation Regions

Non-platform specific questions.

Activation Regions

Postby ESL » Wed Aug 17, 2011 2:11 pm

Hello

Can someone help me with the activation regions?

Suppose I want to create my game all in one .ged file.

One activation region has the start and help buttons

Another one has one level, another one has the next level and so on.

How do I show only one region at a time and then transition to the next region?

I hope you can understand what I am writing.
:)
ESL
 
Posts: 96
Joined: Mon Jun 28, 2010 2:05 am
Score: 1 Give a positive score

Re: Activation Regions

Postby skydereign » Wed Aug 17, 2011 8:45 pm

What I usually do is create some definitions or an array in global code. Don't know if you know arrays, so I'll just explain the definition way.
Global Code
Code: Select all
#define menu_x -300
#define menu_y -240

#define level1_x 1000
#define level1_y -240

// and so on


That way when you want to jump into another activation region, you do this.
Code: Select all
view.x=level1_x;
view.y=level1_y;


Now a property of activation regions is that only regions intersecting with the view are loaded. So besides moving the view into the levels, you don't need to do anything else. Of course depending on how you set up your levels, you might have some trouble. For instance you either need a clone of the player in every level, or you need to move/create one.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Activation Regions

Postby ESL » Thu Aug 18, 2011 2:49 am

Well, that is something to wrap my head around. It gives me a basic understanding. I will toy with it until I get something working.

Thanks!
ESL
 
Posts: 96
Joined: Mon Jun 28, 2010 2:05 am
Score: 1 Give a positive score

Re: Activation Regions

Postby ESL » Thu Aug 18, 2011 3:22 am

Sorry for my plebian mind. The computer coding still baffles me.

This is not a game, just an example.

In the first region, there is an astronaut.
In the second region, a planet.
In the third region, an explosion.
In the fourth region, a space ship.

When I play in game mode, it shows all four on the screen.

How do I show the first alone, then the second alone, and then the third and fourth?
Attachments
ship_11_animated.gif
ship_11_animated.gif (6.75 KiB) Viewed 2429 times
Explode-01-june.gif
Explode-01-june.gif (15.55 KiB) Viewed 2429 times
Comunication.gif
Comunication.gif (5.67 KiB) Viewed 2429 times
Astronaut_turns.gif
Astronaut_turns.gif (3.5 KiB) Viewed 2429 times
example.ged
(1.63 KiB) Downloaded 77 times
ESL
 
Posts: 96
Joined: Mon Jun 28, 2010 2:05 am
Score: 1 Give a positive score

Re: Activation Regions

Postby skydereign » Thu Aug 18, 2011 5:07 am

Any and all activation regions intersecting with the view are loaded. So, if the actor is positioned in the view, then naturally it will be loaded. Each region would need to be far enough away so the view can't collide with more than one region at a time. If you want to have some actors show on the screen while having others not appear (even though they are within the view) then you need to do something else, such as disable the other actors' visibility state.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Activation Regions

Postby ESL » Thu Aug 18, 2011 5:41 am

So what I am getting from this is that I need to change the location of the view actor in order to view another region

How do I do that?
ESL
 
Posts: 96
Joined: Mon Jun 28, 2010 2:05 am
Score: 1 Give a positive score

Re: Activation Regions

Postby skydereign » Thu Aug 18, 2011 5:49 am

Yeah, so it is like I said above. Each level must be far enough apart, and to move the view to the different regions, you set the view's x and y values. So if clicking an actor is supposed to jump you to level 1, the code would look like this.
button -> Mouse Button Down (left) -> Script Editor
Code: Select all
view.x=1000;
view.y=-240;
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Activation Regions

Postby ESL » Thu Aug 18, 2011 6:05 am

cool, that did the trick. Now I just need to know how to position the coordinates correctly.
ESL
 
Posts: 96
Joined: Mon Jun 28, 2010 2:05 am
Score: 1 Give a positive score

Re: Activation Regions

Postby skydereign » Thu Aug 18, 2011 6:10 am

Well you can use the trick I mentioned above. The only things to note are that the view's position is the top left pixel, so find what pixel the top left of the view should be based at, and write it down. You could also use actors to hold the position if you wanted to.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Activation Regions

Postby ESL » Thu Aug 18, 2011 6:30 am

If I want a certain number of actors to be destroyed before moving to the next region, can I write:

if ("A","B", "C") == 0;
view.x=1273;
view.y=-8;
ESL
 
Posts: 96
Joined: Mon Jun 28, 2010 2:05 am
Score: 1 Give a positive score

Re: Activation Regions

Postby skydereign » Thu Aug 18, 2011 6:34 am

Well not like that. But, if you want no A, B, or C actors in the region before jumping, you can use this.
Code: Select all
if(ActorCount("A")==0 && ActorCount("B")==0 && ActorCount("C")==0)
{
    view.x=1273;
    view.y=-8;
}
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Activation Regions

Postby ESL » Thu Aug 18, 2011 6:45 am

you rock dude!
ESL
 
Posts: 96
Joined: Mon Jun 28, 2010 2:05 am
Score: 1 Give a positive score

Re: Activation Regions

Postby ESL » Thu Aug 18, 2011 9:21 am

I put that last script into the global code but there was no effect.
ESL
 
Posts: 96
Joined: Mon Jun 28, 2010 2:05 am
Score: 1 Give a positive score

Re: Activation Regions

Postby skydereign » Thu Aug 18, 2011 10:04 am

If you mean the if statement with the ActorCount calls, it won't work because that is not what global code does. Global code is not executed every frame. That is to say the code you stuck there will never be triggered. To have parts of global code execute you need to create functions and call those from actor events. So, long story short you don't want to put them there. Instead you should put them in some actor event. For example if certain actors are being destroyed, which allows the player to move on, you might put it in the actors' (that need to be destroyed) Destroy Actor event. Of course the code will need to be changed to something like this.
A, B, and C -> Destroy Actor -> Script Editor
Code: Select all
int sum = ActorCount("A") + ActorCount("B") + ActorCount("C");

if(sum<=1)
{
    view.x=1273;
    view.y=-8;
}
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Activation Regions

Postby foleyjo » Sat Aug 20, 2011 12:24 pm

hey just jumping in here with a question.

When you move into a region (with the view) all the actors are created.
When you exit the region do all the actors get destroyed? If not do their events still take effect (eg if something had an xvelocity would it still be moving )
If so are they recreated the next time you enter that region?
KISS -Keep It Simple Stoopid
foleyjo
 
Posts: 275
Joined: Mon Jul 09, 2007 1:15 pm
Score: 15 Give a positive score

Next

Return to General

Who is online

Users browsing this forum: No registered users and 1 guest