Basic Logic Set-up for a Typical Scene

From AGI Wiki
Jump to: navigation, search

Tutorials and Guides Table of Contents
 

The Basic Logic Set-up for a Typical Scene
by David Smith

 

Here is the basic Logic for a typical scene.

How to add another scene

Adding another scene to the game is pretty simple. First step is to be sure of your orientation. That is, look at your map and see how the scene will fit into the whole game. This will help you with making sure the feel of the game flows from scene to scene. Now, pick the number for the scene. (Remember, the scene number is used for both the picture and the logic file) You can either do this by picking the next unused number or if you have drawn a good map, number the scenes by either column or row. The latter is better because then, it will be easier for you to go through the scenes latter on, you can see if the feel really flows. Next step is to draw the picture for the scene. Make sure that the edges of the scene which hook up with scenes you've already drawn match up. i.e. If a house, building, object, crosses between one scene to the next that they are the same height, color, and that they basically flow between the scenes. Now save the picture with the scene number you've picked and exit PICEDIT. Once you have drawn the scene, it can be added via the resource menu. (The resource menu will only show up when the resources window is selected). Go to add a resource and select the picture you've just drawn. Now you must also add a logic for the same scene. I typically like to have a copy of the template's logic for scene 2 handy for this. Click the logic button, and a blank logic page will pop up. Copy the logic over into and save the logic. When it asks for a number, type in the number for the scene which you selected previously. Now, you can add specifics into the logic so that it will match up with your scene, and fit into your game.


Linking together scenes

When I say linking together scenes, I mean having it so that if the player hits the edge of one screen, he/she will be sent to the opposite edge in the next. Left <-> Right, and Top <-> Bottom. This is actually done within the logic code. You can put this bit of code anywhere in the main body of the logic file, but for readability, it is best to put it near the end, right before the return() statement.

If you want to go from scene A to scene B, place the following code in scene A:

Code:
	 if (v2 = = X) { 
     	new.room(B); 
     }    
 
and, in scene B, place this code:
 
	 if (v2 = = Y) { 
     	new.room(A); 
     }

replacing A and B with the respective scene numbers. Variable v2 corresponds to the edge of the screen which the ego has touched. If the ego is touching an edge, v2 will be a number from 1 to 4. 1 corresponds to the top of the screen, 2 to the right edge, 3 to the bottom edge and 4 to the left edge. So, if scene B is to the right of scene A, X should be 2 and Y should be 4. In other words, if the ego has touched the right edge of scene A, put them in scene B.

 

Tutorials and Guides Table of Contents

< Previous: Beginning of Tutorial Next: Making Ego Swim in Water >