AGS Tutorial - Stee Campbell

Transcription

AGS Tutorial - Stee Campbell
AGS
AGS Tutorial
An Introduction To Chris Jones’ Adventure Game Studio
Content by Chris Jones
2002-2009
Getting Started with AGS Part 1 ..................................................................................................... 5
Creating the game ...................................................................................................................... 5
Starting off .............................................................................................................................. 8
Colour choices ........................................................................................................................ 9
Creating a 256-colour game ................................................................................................. 10
Creating a 16-bit or 32-bit colour game................................................................................ 12
Game Resolution .................................................................................................................. 12
Getting Started with AGS - Part 2 ................................................................................................. 13
Creating your first room ........................................................................................................... 13
Naming the Room ................................................................................................................. 14
The Background .................................................................................................................... 14
Edges .................................................................................................................................... 14
Walkable Areas ..................................................................................................................... 15
Walk-behind areas ................................................................................................................ 17
Trying out the game ............................................................................................................. 19
Getting Started with AGS - Part 3 ................................................................................................. 20
Adding some interaction .......................................................................................................... 20
Hotspots ............................................................................................................................... 20
Interactions .......................................................................................................................... 21
Walk-to points ...................................................................................................................... 23
Edges revisited...................................................................................................................... 24
The AGS Tutorial
Page 2
Scripting tutorial ................................................................................................................... 24
Getting Started with AGS - Part 4 ................................................................................................. 25
Objects ..................................................................................................................................... 25
Inventory .................................................................................................................................. 26
Room Settings................................................................................................................. 29
Getting Started with AGS - Part 5 ................................................................................................. 30
Managing Inventory ................................................................................................................. 30
Inventory item hotspots ....................................................................................................... 32
Recap .................................................................................................................................... 32
Getting Started with AGS - Part 6 ................................................................................................. 34
Using your own graphics .......................................................................................................... 34
Tiled sprite import ................................................................................................................ 36
Getting Started with AGS - Part 7 ................................................................................................. 37
Animations ............................................................................................................................... 37
Characters ........................................................................................................................ 38
Game starting point ...................................................................................................... 39
Cutscenes ......................................................................................................................... 40
Getting Started with AGS - Part 8 ................................................................................................. 43
Conversations ........................................................................................................................... 43
More on conversations ......................................................................................................... 47
Getting Started with AGS - Part 9 ................................................................................................. 49
Cursors ..................................................................................................................................... 49
The AGS Tutorial
Page 3
Fonts ......................................................................................................................................... 50
Importing fonts ..................................................................................................................... 51
Conclusion .................................................................................................................................... 52
The AGS Tutorial
Page 4
Getting Started with AGS Part 1
So, you've downloaded AGS. You want to make an adventure game. But where do you start?
(NOTE: before we start, this tutorial was made using v3.0 of AGS. If you have a newer
version, there may be minor inconsistencies in the screenshots where extra options have been
added and so forth, but most of what's here should still apply).
Creating the game
Start up the AGS Editor by double-clicking the AGSEditor.exe file, and you should be greeted
by the following screen:
The "Welcome to AGS" dialog
Make sure that "Start a new game" is selected, and click Continue. You'll be presented with the
Create New Game wizard:
The AGS Tutorial
Page 5
Create New Game dialog
So, without further ado, click Next, and you'll see the Select Template screen:
Select Template dialog
Here, you need to choose which template you're going to use for your new game. AGS comes
with three, and you can find others for download on the AGS Forums.
The "Default Game" template is what we'll be using, as it comes with some default graphics to
get you started quickly. The "Empty Game" template is something you may want to use later on
when you're familiar with AGS - it comes with no default graphics at all.
So, select "Default Game" and click Next.
The AGS Tutorial
Page 6
Game Name dialog
Finally, you need to decide on what to call your game. In the first box you can type the full
name for your game. This is what will be displayed in the game title bar when it's running in a
window, and it's used for a couple of other things too. For the purposes of this tutorial, I'm going
to call it the incredibly lame "Roger's Adventure", but you can use whatever you like.
The second box asks you for the game file name. This is only used for the name of the folder
that your game is created in, and the name of the final EXE file you compile.
The third box allows you to choose where AGS should put the game files -- the default is your
My Documents folder, and I'm going to stick with that.
Click the Finish button, and after a short wait you should be presented with the main AGS
Editor window:
The AGS Tutorial
Page 7
The main editor window
So, there's your new game, ready and waiting for you to create it!
Starting off
The main way that you navigate around the editor is using the project tree in the top-right
corner, which allows you to access all the various parts of your game. Let's start by scrolling to the
top of the tree, and double-clicking the "General Settings" node:
The AGS Tutorial
Page 8
The General Settings pane
This screenshot demonstrates three of the main editor features. The project tree, as we've
already discussed, gives you access to the various parts of your game. The property grid, in the
bottom-right, is where item-specific properties are accessed. It's not used in the Game Settings
window, but we'll see it in action soon!
Finally, the AGS editor allows you to have several windows open at once, and they are
"tabbed" across the open windows bar at the top so that you can easily switch between them.
Use the Close button to close a window once you're finished with it.
Now, since we're on the Settings pane, let's briefly examine the various options we have in
front of us. Make sure these options are enabled to begin with:




Enable Debug Mode - Since we are going to be developing the game, we want the
assistance of the debug features in the engine. This allows you to do things like teleport to
different rooms, give yourself all the inventory items, and so forth. You would un-check
this before compiling the final version of the game when it's complete.
Enable 'anti-glide' mode - without it, the character movement can look somewhat silly.
Pixel-perfect click detection - improves the game playability by making sure that
clicking transparent regions of objects won't trigger them.
Characters turn before walking - if the character is facing right, and you click to move
him left, he'll rotate round before starting to move. This is what the Sierra and Lucasarts
point-and-click games did, and looks a bit more professional.
Personally, I would always enable these four options when starting a new game. As you get a
feel for AGS, you can decide what suits you best, and change these options again later.
Colour choices
The AGS Tutorial
Page 9
Now, at this stage we really need to decide whether we want to create a palette-based (8-bit,
256-colour) game, or a hi-color (16- or 32-bit) game.


The advantage of a palette is that the game size will be smaller, and the game will run up
to twice as fast as using hi-colour. Neat fading and colour cycling effects are also possible.
The advantage of hi-colour is that you don't have to mess around with palette slots, you
just import your graphics and they just work.
I'll cover both methods briefly below; if you're not really sure which to choose, go for Hi-color
(16-bit) since it provides a good balance of performance and ease-of-use.
(NOTE: We need to decide now because when you import graphics, they will be set to the
game's colour depth. Should you change your mind later, you would have to re-import all the
graphics).
Creating a 256-colour game
Double-click the "Colours" node in the project tree. You should see this:
The Palette Editor
The palette display has a grid with the 256 colour slots on it. The first 40 colours are gamewide colours, which means that those palette slots have a fixed colour throughout the game, in
every single room.
The remaining slots, marked "X", are background colours and vary from room to room. This
allows for different types of background to use different ranges of colours.
The AGS Tutorial
Page 10
The default palette setup is a little badly weighted. Your GUI and main character graphics will
have to use just the game-wide colours, since they are shown in more than one room. Therefore,
unless you want a greyscale main character, the colours displayed are probably not enough.
So, let's swap some background colours for some game-wide ones. Select the first "X" slot,
then hold shift and click on the last slot in the row marked "80". The screen should look as follows:
We have selected colours 42-95
We can now see the Property Grid in action. Change the "ColourType" setting from
"Background" to "Gamewide", and you'll see the selected "X"s turn into various colours.
If you select one of these colours you'll see its RGB colour values in the property grid, where
you can adjust the colour of that slot. If you don't want to do this manually for every colour, you
can set up slots 42-95 in another paint package, save a BMP file, and then right-click on the
selected slots and choose the "Replace selected slots from file" option.
What colours you use is up to you, and depends on what sort of colour scheme you're going
for with your graphics.
You should set up the palette as well as you can now, because changing it later may
require you to re-import some graphics.
The AGS Tutorial
Page 11
Creating a 16-bit or 32-bit colour game
Back on the Game Settings pane, check out the very top option in the list. It's called "Colour
depth", and all you have to do is change it to your desired colour depth. A warning message will
prompt you to make sure. Confirm it, and you're done.
Game Resolution
Having decided on our colour depth, the other important decision to make at this stage is what
resolution we want the game to run at. Higher resolutions allow you to have more detailed
graphics, but they need more memory and run slower than lower resolutions.
Go back to the General Settings pane, and select your chosen resolution from the "Resolution"
drop-down list.
The AGS Tutorial
Page 12
Getting Started with AGS - Part 2
In AGS, games are made up of several rooms, which the player moves between in order to
play the game. Each room is one screen that has its own background, hotspots and objects.
Creating your first room
Scroll down to the bottom of the project tree, and you'll see a node called "Rooms". Right-click
it, and choose "New room". You'll see a "1:" node appear underneath. This shows us that we've
created room number 1, and we can give it a name in a moment.
The Rooms list in the project tree
Expand the "1:" node, and double-click the "Edit room" node underneath to open the room.
You'll see a new window open up, with a big black area in it. This is the room background, which is
currently blank. The room editor looks like this:
The Rooms list in the project tree
There are four main parts to this window:
The AGS Tutorial
Page 13




The Background Selection area allows you to import and manage the room's backgrounds.
The Room Parts drop-down list is the way that you switch between seeing different aspects
of the room.
The Room Background Preview area is where you see the room's background image, along
with various things on top of it, depending on what's selected in the Room Parts option.
The Properties window allows you to set up various properties and events for the room.
Naming the Room
As a first step, let's give the room a description. This is just to help us easily remember which
room it is, and this description isn't used at all by the game engine. Click in the "Description"
property in the property grid, and type in something appropriate. You'll notice that the project tree
updates to include this description.
The Background
Now, the first thing you need to do is draw the background for the room. This needs to be an
image of at least the same size as your game resolution (that we set earlier on the General
Settings pane); if it's bigger than the game resolution then it'll become a scrolling room.
Draw the image in your favourite paint package, and once done, save it as a BMP or PNG file.
Then, return to the AGS Editor, and press the "Change" button. Find the file you just created, and
click Open.
You should see the black area in the editor replaced by your image. For this tutorial, I'm going
to shamelessly steal a background from Space Quest 4. Obviously, you should draw your own!
I've imported my background
Edges
Open up the combobox that says "Nothing" in it, and select "Edges". You'll see four yellow
lines drawn across your image in various places. These are the room edges, and they define how
The AGS Tutorial
Page 14
far the character needs to walk to be considered to have left the room. Click and drag them to
position them appropriately. Bear in mind that it's the character's feet that are compared with
these lines when positioning.
I've lined up the top and right edges correctly
At the moment, walking past the edge won't actually cause anything to happen, but we'll deal
with that later. In my example, the character can only walk off the top and right edges, so they're
the only ones that I've dragged into position. I've left the others as they are, since we won't be
needing them.
Walkable Areas
Next, we need to define the room's walkable areas, which define where characters are allowed
to walk within the room. Open up the drop-down list again, and select "Walkable areas":
The AGS Tutorial
Page 15
Walkable areas mode
In the toolbar you'll notice that some new buttons have appeared. These are the drawing
tools, and work in a similar way to most paint packages. AGS provides Line, Freehand, Rectangle
and Fill tools. Alternatively, you can draw your walkable area mask in a paint package and import
it (we'll cover that later).
What we need to do is to fill in the areas of the room where the player is allowed to walk. In
the game, the bottom middle of the character is checked against these areas, so it's probably wise
to make the walkable areas slightly smaller than they need to be, to allow the character's feet to
spill outside the area.
The best way to start off is with the Line tool. Draw some lines to encompass the area that you
want to be walkable. Make sure they are all joined up, and then choose the Fill tool and click in the
middle of the area, and it should be filled blue. If the whole screen goes blue, click Undo, then use
the Line tool to make sure all the edges of the area are properly connected up, and try again.
You can use the right mouse button with the drawing tools to erase areas in the same way
that you use the left button to add them.
The AGS Tutorial
Page 16
I've drawn a walkable area where I want the player to be able to go.
Walk-behind areas
The next job we need to do is to define the walk-behind areas. These areas (called "priorities"
by some other adventure game tools) tell the game where the character needs to be drawn behind
the background. For example, on my screen here, the player needs to walk in from behind the
curved wall on the right.
Choose "Walk-behinds" from the combobox. Your walkable area will disappear and you'll be
back to just seeing the room background.
Now, we draw on the walk-behind area in the same way as we did the walkable area - in fact,
all the same drawing tools are available. My result looks like this:
The AGS Tutorial
Page 17
The walk-behind area painted over the pillar
Notice that I haven't bothered to make the whole of the pillar a walk-behind from top to
bottom - using my knowledge of the walkable areas and the height of the character, I can just
draw a walk-behind in the places where it's possible for the character to be.
Now that we've done that, there's a very important next step in order to make the area work the baseline. The baseline is a horizontal line, which tells the game where the character has to be
in order to be drawn behind the area. For example, if you had a table in the middle of the room,
you'd only want him drawn behind the table if he was standing behind it.
You normally place a baseline at the lowest point of the walk-behind area. Move the mouse
cursor to the bottom of the walk-behind area, and look at the "Mouse Position" display above the
room background. These are the X and Y co-ordinates of where the mouse cursor currently is.
We're only interested in the Y co-ordinate, so type it in to the Baseline setting in the property grid.
By default, we've been drawing blue areas onto the screen. But what if we had two pillars, in
different places? We wouldn't want the same baseline to apply to both. Never fear, AGS allows you
to have several different areas on each screen. Above the property grid, there's a combobox that
says "Walk-behind area ID 1". You can change this to draw in another colour, and each area has
its own baseline.
The AGS Tutorial
Page 18
Selecting a different walk-behind area
Trying out the game
Ok, we've slogged away at making our room - now it's about time to give it a go. Press F5, or
click "Run" on the Build menu. This will save your work and launch the game! Once loaded, you
should see your room with the character in it.
When you use the Run command, the game will always run in a window. If you want to
test the game full-screen, use the Ctrl+F5 ("Run without debugger") option.
Try to move the character around. If he won't move, he probably didn't start on a walkable
area. If this is the case, expand the "Characters" node in the project tree, and double-click "cEgo".
Then, look in the property grid for two properties called "StartX" and "StartY". You can find out
what these co-ordinates should be by going back to your room background, positioning the mouse
cursor at the place where you want the character to start, and reading the "Mouse co-ordinates"
display.
Once you've got that working, have a play walking the character around the screen, testing
out the walkable and walk-behind areas.
The normal way of exiting the game is to press Ctrl+Q. It's possible that during
development of your game, you may create a script that causes the game to lock up - in this
case, the emergency break key Alt+X will exit the game for you.
The AGS Tutorial
Page 19
Getting Started with AGS - Part 3
Adding some interaction
Ok, so we now have a working room. The player can walk around it as much as they like.
However, our game so far is pretty boring - the player can't actually do anything of value yet!
AGS provides you with three types of things that the player can interact with hotspots, objects and characters:



A hotspot is an area of the background image that the player can look at and interact
with. Hotspots are generally used for parts of the screen such as a tree or the grass which
won't change as the game progresses.
An object is an item in the room that can move around the screen, and be switched on
and off at will. Objects must stay within the room that they are created in.
A character is like an object, except that it can move between rooms and therefore
appear all over the game. Characters also have special properties such as talking
animations and so forth, which means you will usually use one to represent each NPC
(non-player character) in the game.
Hotspots
The easiest thing to start off with is hotspots. Make sure you've got the room editor open, and
select "Hotspots" from the drop-down list box (the same place where we selected "Walkable areas"
earlier).
Hotspots are drawn in exactly the same way as walk-behind and walkable areas. You'll
probably want to use several different Hotspots for different areas of the screen. After drawing
your first hotspot, change the Selected Hotspot using the drop-down list above the property grid,
and you can draw in a different colour. All the other hotspots will be greyed out.
The AGS Tutorial
Page 20
I've drawn four types of hotspot onto my screen
Once you've drawn a hotspot, there are two other fields to set:


The hotspot's description. This sets a player-friendly name for the hotspot, which is vital if
you are going to use a Lucasarts-style interface where the player can move the mouse
over the screen to see what's where. If you're using a Sierra-style interface then this name
will never be displayed to the player, but it's useful to fill it in anyway for your own benefit.
By default this is "Hotspot 1", "Hotspot 2", etc.
The hotspot's Name: This is a name by which the hotspot can be referred to in the room
script. This name cannot have any spaces or special characters -- just the letters a to z.
The convention in AGS is to start the script names for hotspots with an h, for
example hDoor. The name must be unique within the room.
In the Areas editor, all the hotspots except the currently selected one are drawn in grey.
This is to emphasise which hotspot you have selected to edit. You can change this behaviour
by toggling the "show non-selected masks greyed out" button at the right hand end of the
toolbar.
Interactions
Right, now it's time to make something happen! Make sure the first hotspot is selected, and
click the Events button:
The AGS Tutorial
Page 21
The events list
You'll see that the property grid changes to list all the events for this hotspot. Events occur
when the player does certain things in the game. At the moment, nothing is set to happen in
response to any of the events, so whatever the player does to the hotspot, they will get no reply.
Right, let's start with something simple. When the player looks at my hotspot, I want to
display a message telling them what they can see. Click on the "Look at hotspot" row, and a "..."
button will appear.
The "..." button
Click the "..." button. This will create an entry in the script for this event, and you'll find
yourself taken to the script editor. If instead you get a message telling you that the hotspot needs
a name, read back up for how to set a name for the hotspot, earlier in this article.
So, you're now in the script editor. It all looks a bit bare and intimidating, but you should have
something like this:
The AGS Tutorial
Page 22
Script editor after adding a hotspot event
The "function hDoor_Look" line defines that the script underneath will be run when this event
occurs. In AGS, the curly brackets { and } are used to mark the start and end of a block of script.
Anything that you type in between them will be run as part of this event.
There's a seperate tutorial giving you an introduction to the scripting language, so I won't
attempt to explain it here. But we can start with something very simple, using
the Display command, which displays a message to the player. Type in something like this:
A simple script
Once you're done, click on the "Room 1" tab to return to the main room
editor.
Walk-to points
Ok, since we're back editing hotspots, let me quickly explain the "Walk-to point" option in the
property grid. This allows you to set a position for each hotspot that the character will walk to
whenever the player interacts with the hotspot - just like the way the Lucasarts games like
Monkey Island worked.
The AGS Tutorial
Page 23
If you set a walk-to point, then whenever the player clicks interact or talk on the hotspot, the
main character will first walk to the walk-to point before the relevant event is triggered. If you
want, the character can also walk there when the LOOK mode is used - this option is configurable
in the game General Settings pane.
To remove a walk-to point, simply set it to 0,0.
Edges revisited
Ok, so we've covered the basics of creating a room. However, there's one thing that we did a
while back that we need to clear up - yes, the edges.
Select "Edges" again in the list box. Now, click the Events button in the property grid and this
time we'll see the events for the room itself. Among the events listed, you'll see "Walks off left
edge", "Walks off right edge", and so on. These are fired when the player character crosses the
edges that we defined back in part 2. Normally, you'll use the player.ChangeRoom script command
for these events, to take the player to a different room.
Now, hit F5 to try out our latest additions! Make sure that when you look at hotspot 1 the
game displays the message that you typed into the script.
Scripting tutorial
Now might be a good time to check out the scripting tutorial to get a better understanding of
what your script code is doing. Alternatively, finish off this tutorial first and then check out the
scripting tutorial.
The AGS Tutorial
Page 24
Getting Started with AGS - Part 4
Objects
Objects are items on the screen which, unlike hotspots, can move, change and disappear. You
use objects for things in the room that the player can take (since they can disappear), and for
things which need to animate.
So, let's revisit the age-old "key" inventory item. Let's say we've got a locked door, and the
player can pick up a key from another room to open it with. Please don't use this puzzle when
you're making a proper game, it's been done far too many times ;-)
From the same list as we chose "Walkable areas" and "Hotspots" earlier, let's return there and
select "Objects". Now, to add an object to the room, simply right-click on the background where
you want to add it, and choose "New object here" from the menu which appears.
As if by magic, a blue cup appears! This is the default sprite in AGS, and will appear anywhere
that you haven't selected a proper image yet. Notice that the property grid has changed to display
the details of this new object -- one of which is a property called Image. Select this property, and
a "..." button appears.
Adding an object to the room
Click the "..." button, and you'll be presented with the Sprite Manager. We'll explain this in
more detail later, but basically it is the focal point in AGS where you import and export all your
graphics except for room backgrounds. You should see a small key picture as sprite number 2.
Double-click that for now, we'll import our own graphics later.
You should now see that the blue cup has changed into a key. You can move it around by leftclicking and dragging the sprite within the background image. Place it somewhere sensible on your
screen.
The AGS Tutorial
Page 25
The next thing we should do is give the object a name. Similar to what we did with hotspots,
since the object will be referred to in the script it'll need a name that we can call it by. Scroll down
the property grid and find the "Name" property, and set it to something sensible. The convention
in AGS is to have object names start with an "o", for example oKey.
I've placed the key cunningly in the middle of the walkway ;-)
Before we enable the key to be taken by the player, let me quickly go over a couple of
propertes in the property grid:


Baseline - normally, the baseline for an object is set to the bottom of the object graphic
(baselines are used to calculate which items on the screen are drawn in front and which
are drawn at the back). However, in some cases you might want to override this.
What you'll notice with our key is that if the player walks just behind it, the key will appear
in front of his feet. This is not what we want, since the key is supposed to be lying flat on
the ground. To correct this, change the Baseline property to 5 (this means that it will be
drawn behind everything that has a baseline lower down the screen than Y=5). This will
make sure that the player is always drawn in front of the key.
Visible - this toggles whether the object is switched on at the beginning of the game or
not. For our key we want it to be True, but sometimes you'll have objects which you don't
want the player to see until they've done something else in the game.
The game speed is directly related to the number and size of objects on-screen. AGS
imposes a limit of 20 objects per room, but even if you use all of these and have them
visible at the same time, the game speed could suffer.
Right, now back to the pressing matter at hand - letting the player pick up the key.
Inventory
The AGS Tutorial
Page 26
Now wait, there's one more step we need to do first. At the moment we could let the player
pick up the key, but then what would happen to it? Where would it go? We need to define the
player's inventory.
Select the "Inventory Items" node in the project tree. You'll see that there are already two
items defined - "Key" and "Pink poster". These are just defaults to help you get started. Double
click "1: iKey", and you should see a window open with the key image in it. But that picture's a bit
small for an inventory item, I'm sure I saw something better in the sprite list earlier.
Find the "Image" property in the property grid, select it, and then click the "..." button. The
sprite manager re-appears, so find sprite number 5, and you should see that it's a much larger
picture of a key. Let's use that as our inventory icon. Double-click the sprite to select it.
Yay, we've got a big inventory icon for the key
Ok, there are a few other settings on this screen, but let's return to our objective - letting the
player pick up the key. Remember that the script name is iKey, as we'll need it later.
Back to the events
Go back to the Objects pane of the Room Editor, and click on, yes you've guessed it,
the Events button. The events here are very similar to the ones we had for the hotspot:
The AGS Tutorial
Page 27
The events list for the object
Notice there are two obvious possibilities here: "Interact object" and "Pick up object". We
actually want to use the "Interact object" event, because we are using the default Sierra-style
interface which doesn't have a specific Pick Up mode. The "Pick up", "Usermode1" and
"Usermode2" events are useful if you go for a lucasarts-style interface which has more verb types
available to the player.
So, select "Interact object" and click the "..." button. When the player picks up the key we
want two things to happen - firstly, the object on-screen needs to disappear, and secondly, the
inventory item needs to be added to the player's inventory.
Here's my script solution. As an added bonus, I've also given the player 5 points for their
trouble, but you don't need to have that third command:
The AGS Tutorial
Page 28
Script for taking the key
Note that our solution is not perfect - the player can click the hand icon on the key from
anywhere in the room and it will disappear. We are also not displaying a message informing the
player of what happened. But, the functionality is there, and this will do fine for now.
Okey, so we now have a fully-working first room. Test the game as before, and try it out. Once
the player has taken the key, call up his inventory and you should see the large key picture there.
Room Settings
Finally, let's just quickly go over the available properties for the room itself (available when in
Nothing mode):





PlayMusicOnRoomLoad - you can type a music number in the box and that background
music will start playing when the player enters the room. For more about music and
sound, see later in the manual.
SaveLoadEnabled - if disabled, then if the player tries to save or load the game while in
this room, a message ("Sorry, not now") is displayed instead. .
ShowPlayerCharacter - if checked, the player character will not be visible in this room,
and the Walk mode will be disabled. Useful for close-up displays of control panels and so
forth.
PlayerCharacterView - you can type a number in here to override the player character's
graphic for this room. For example, if you have an overhead map screen, you will probably
want a different image of the character from an overhead perspective.
MusicVolumeAdjustment - this allows you to modify the background music volume for
this screen.
The AGS Tutorial
Page 29
Getting Started with AGS - Part 5
Managing Inventory
Each character in the game can carry their own set of inventory items. Inventory items are
totally separate from room objects, and you must explicitly set up every item which the player can
carry at some point in the game.
Go to the "Inventory items" node in the project tree. We visited this briefly in part 4, but it's
time to go into a bit more detail.
The inventory editor, another look
Every inventory item that the player can carry at some point during the game is listed in the
project tree. All the items there also have a number beside them - this is the inventory item ID,
which is largely for backwards compatibility with older versions of AGS.
To edit an inventory item, double-click it in the project tree, and a new window will open up
with the item's properties in the property grid. If you want the player character to start off
carrying the selected item, set the "PlayerStartsWithItem" option to True. Remember, if you want
to change which image is used for the item, select the "Image" property and click the "..." button.
Now, you may have noticed that once the player had picked up the key in our game, they
could see it in their inventory window but not actually do anything to it - clicking Look or Use on
the item did nothing.
In order to give the inventory item some interactivity, we once again need to call on the
Events List. Click the "Events" (lightning) button to bring it up:
The AGS Tutorial
Page 30
The events list... this time for inventory
Now, the important point to note here is that if you are using the built-in inventory window
(which we are), the only events which can occur are "Look at inventory item" and "Use inventory
on this item". This is because the default inventory window only has Look and Select options. The
other modes are all available if you design your own inventory GUI (but that's quite complex so
we'll leave it for later).
So, select the "Look at inventory item" event, and click the "..." button. You'll be taken to the
script editor once more, but this time you'll notice that there's already some existing script as well
as our new method:
The AGS Tutorial
Page 31
Script for looking at the key
We are now editing the global script. This has all the script for handling
events on game-wide things like inventory items and characters.
Previously we were working with hotspots and objects, so they were
confined to their own room script.
Anyway, for now I've just added a simple Display command to show the player a message
when they look at the key. Feel free to do something similar.
Inventory item hotspots
By default, when the player selects an inventory item as their mouse cursor and clicks on the
screen with it, the centre of the item will be used to decide what to activate. However, with some
items you may well not want this behaviour - for example, we might want the end of our key to be
the activation spot.
To set the cursor hotspot, simply click on the spot within the image. You should see a crosshair
appear where you clicked.
The "Draw crosshair" option, if activated, will draw a spot on this part of the item in-game so
that the player can easily tell which bit of the cursor is active. You can set the inner and outer
colours for the crosshair.
Recap
The AGS Tutorial
Page 32



Inventory items are not objects. The two are totally seperate, although often picking up
an object will give the player an inventory item.
Each character has their own inventory. If you are making a game like Day of the
Tentacle, where the player can switch between characters, then they will each have their
own set of inventory items. Usually, you'll use inventory commands to operate on the
current player character.
To give the player an inventory item, use the player.AddInventory command.
The AGS Tutorial
Page 33
Getting Started with AGS - Part 6
Using your own graphics
When you were choosing the graphics for the object earlier in this tutorial, you probably
noticed that the images available didn't look up to much. This is no problem, because you can
import your own graphics using the Sprite Manager.
Double-click "Sprites" near the top of the project tree. This opens up the Sprite Manager,
where you can see the complete sprite set for the game.
AGS uses these sprites for all game graphics, except room backgrounds. The Sprite Manager is
the central place where you do all your graphics importing. Whenever you want to use images in
the game (for mouse cursors, views, objects, etc), you select an image to use from here.
There are two ways to import your graphics - either overwrite an existing sprite with your
graphic, or create a new slot for it. To overwrite an existing sprite, right-click the sprite and
select "Replace sprite from file". To import a new slot, right-click on the background of the window
and choose "Import new sprite from file". If your game is hi-colour, you'll also have options to
paste from the clipboard.
Note that the sprite graphics you import must be the same colour depth as your backgrounds ie. if you have a 256-colour game, you must import 256-colour sprites.
Right-clicking to replace existing sprite
So, let's replace the default key image with something of our own. Right-click on it and choose
"Replace sprite from file". Select the file that you want in the dialog, and then you'll be presented
with this:
The AGS Tutorial
Page 34
The "Import Sprite" window
This is the Import Sprite window. You'll see the image from the file that you chose, along with
various options. The Zoom slider on the left allows you to zoom in on the image (very useful for
320x200-resolution graphics), and the "Transparent colour" option allows you to choose how AGS
decides which colour is the image's transparent colour.
Now, you have two choices. If you want to import the whole image, just click the "Import
Whole Image" button, and you're done. If on the other hand you only want to import a portion of
the image, then you need to right-drag the mouse within the image to select the area that you
want to import. Once you've got it right, left-click to confirm and the selected area of the image
will be imported.
NOTE: For character graphics, make sure you import graphics that are a suitable size for the
game backgrounds. For example, don't import a 320x200-sized image for your character, since it
will take up the whole screen. A good size would be about 20x50 pixels. This will look really small
in the Import window, but your game runs at a much lower resolution so it'll look much larger.
NOTE (256-colour only): You may well find that the colours on your graphic look slightly
strange once you've imported the image. This is because by default only the first 41 of the
palette colours are allocated to sprites, so your graphic will be remapped to this much
smaller palette. If you find that many of your imported sprites look strange, you can
increase the number of colours assigned to sprites, at the expense of background colours
The AGS Tutorial
Page 35
(see the earlier part of the tutorial for palette setup).
Tiled sprite import
This feature allows you to import a grid of sprites into separate slots - for example, if you have
several frames of a character animation side by side in the source bitmap. To do this, simply check
the "Tiled sprite import" box, and align your rectangle on the top left sprite. When you click the
left mouse button, you will get an extra step which allows you to size the grid:
Click the left button again once you are happy with the grid. Each of the cells will be imported
as a separate sprite.
NOTE: Tiled sprite import only works if you selected "Import new sprite from file". If
you used the "Replace sprite" option, only the first tile will be imported.
The AGS Tutorial
Page 36
Getting Started with AGS - Part 7
Animations
A graphical adventure game would be no good without animations. These range from
commonly-used animations such as the main character walking, to a flag waving in the
background in one particular screen.
Animations in AGS are managed using Views. A view is a set of one or more loops. A loop is a
set of frames which, when played in sequence, give the illusion of movement. Expand the "Views"
node in the project tree, and double-click the view 1:
The View Editor showing view 1
This is the View Editor where you will put together all your animations. You'll notice lots of
frames of Roger's walking animation in this window.
Each loop is displayed as a row of images (one for each frame), going from left to right. To
change the image for a frame, double-click the image, and you'll be presented with the sprite
manager where you can select the image to use. All images for use with views are imported
as usual via the sprite manager before they can be inserted into a frame.
At the right hand end of each loop, you'll see a "Create new frame" button, which you can click to
create a new extra frame at the end of the loop. You can also right-click a frame to insert a new
one before or after it.
Left-click a frame to select it. When you do so, the property grid will be updated with the
frame's details:
The AGS Tutorial
Page 37
Property Grid showing frame properties



Delay is the frame's relative speed. This number adds a delay to the amount of time
which the frame is displayed for, therefore a larger number makes it stay longer. You can
use negative numbers to specifically shorten the frame's display time.
Sound allows you to assign a sound number that will get played when this frame comes
around in the animation. This feature is designed for footstep sounds, but has many other
uses as well. Using sound will be covered later in the tutorial.
Flipped toggles whether the frame is displayed normally or mirrored left-right. This
feature allows you to just create animations for your character walking right, and then use
the same images for the walking left loop and AGS will automatically flip them.
Views aren't only used for character walking animations -- they're used for all types of
animations in the game. How you actually run an animation in the game will be explained later on.
Characters
If you remember back to part 3 of this tutorial, we talked about three types of thing that the
player can interact with - hotspots, objects and characters. We've covered the first two, so now it's
time to take a look at characters.
Put simply, a character is similar to an object, except that it can move between different
rooms in the game, take part in conversations, carry its own inventory and more.
Expand the "Characters" node in the project tree. You'll see that so far you only have one
character in the list, labelled "0: cEgo". You can create a new character by right-clicking the
"Characters" node. For now, double-click the "cEgo" character:
The AGS Tutorial
Page 38
The Character Editor
The first thing you'll notice is the text "This character is the player character" at the top of the
window. This shows that the currently selected character is the initial player character when the
game starts up. The game will start off in whatever room number the Starts in room option is set
to for the player character. To change it, simply open up the character that you want to use
instead and click the "Make this the player character" button.
There are quite a few properties available in the property grid. Rather than explain them all
here, we'll just cover the most important ones - you can find a full description of all the options in
the manual.



StartingRoom - this sets which room number the character starts off in at the beginning
of the game.
NormalView - sets which view is used for the normal walking animation of the character.
The view specified here must have 4 or 8 loops, and the first frame of each loop is the
standing still frame.
For a 4-loop character, when walking diagonally the closest straight direction is chosen for
display. With an 8-loop character, all 8 directions are displayed depending on the
character's direction.
Which loop represents which direction is shown in the Views editor (eg. "Loop 0 (down)").
Clickable - if this is not checked, then this character will be see-through to mouse clicks.
This is similar to the way the player character worked in Lucasarts games - you cannot
actually click on Guybrush, it will always activate whatever is behind him.
The character's "RealName" field simply gives you an easy way to identify the character in the
editor, and can also be accessed from the game script if desired.
The "ScriptName" field is very important, as it sets the name by which the character will be
referred to in the game scripts. The reason for having this as well as the RealName is that the
script name can only contain the letters A-Z, whereas the RealName field can contain any spaces,
numbers, etc.
Game starting point
The AGS Tutorial
Page 39
Just in case you missed it, I'll repeat what was just said in the Characters section - the "Starts
in room" setting of the player character is used to determine which room the game starts off in.
TIP: This feature can be handy for testing various parts of your game. For example,
when you're working on room 16, set the starting room to room 16 so that you can get to it
instantly when you run the game to test it.
Cutscenes
You can easily add intro, outro and cutscene sequences to your game. There is no specific
feature to do this - you simply use the provided animation and movement commands to do
whatever you like.
A cutscene is simply the name given to a sequence of actions over which the player has
no control. This usually applies to the entire introduction sequence, as well as far simpler ingame events. For example, if the player goes to pick up a rock from the ground, you may
wish to use a bending-down animation to show him picking it up. During this bending down
and standing back up, the player cannot control proceedings, so it is a cutscene.
Right, firstly let's do something very simple. When the player goes to pick up the key from the
floor of our room, we want him to walk over to it first rather than it just disappearing from
wherever he's standing.
So, we want to add something extra to picking up the key. How do we do this? Yes, that's
right, we need to return to the Event Script for the key object. Go back to the Events List for the
key object (remember, you open the room, select the "Objects" mode, then click on the key to
select it):
The AGS Tutorial
Page 40
Remember this?
The main difference you'll notice now is that the "Interact object" event already has a name.
This "oKey_Interact" is the name of the script function that we created earlier. So, just select it
and click the "..." button to return to the script editor.
Now, we want the player to walk across to the key before it disappears, so we need to add a
new line of script before the existing command that makes the key invisible. We want to do an
action on the player character (ie. move him), so type "player." and auto-complete will pop up
with the available commands. See if you can work out which one we need.
The Walk command needs X and Y co-ordinates
Eeek! It wants a destination X and Y location! We don't know that, but we can find out! Click
the "Room 1" tab on the tab bar at the top of the editor, and move the mouse cursor to where the
key is on the background. Look just above the background image, and you should see "Mouse
Position: 158, 108" or something similar. These are the X and Y co-ordinates, respectively, of the
key's location. So, note them down, and click the "room1.asc" tab to return to the script.
Now, we can type in those co-ordinates to our script. We also need to pass in the
BlockingStyle as eBlock, which tells the game to wait for Roger to get to those co-ordinates before
continuing the script. If we didn't do this, he would start to walk but the key would disappear
before he got there! The final script should look like this:
The AGS Tutorial
Page 41
Our new command is run before the existing ones
Now, hit F5 and try it out!
OK, I think we've had enough of animations and cutscenes for now. We'll return later to
explore actual animations and more complex cutscenes.
The AGS Tutorial
Page 42
Getting Started with AGS - Part 8
Conversations
What fun would an adventure be if there were no other characters to talk to? Probably not
much!
How much you go into dialog depends of course on your game style. Generally, Sierra games
used to just have one fixed line of dialog which the characters would talk about, possibly changing
if you talked to the same person again.
Lucasarts games (and some Sierra titles such as Quest for Glory) on the other hand, had complete
dialog trees through which you could choose your topics to talk about.
AGS lets you do it whichever way you want. We'll start off by looking at the complete dialog
tree approach, and then see how easy it is to cut it down to get a Sierra-style system.
Now, before we go any further, let's consider for a moment what conversation structure we
want. It's going to be a lot easier to implement if we have this planned in advance. For this
tutorial, we'll go for a structure like this:
Our planned dialog tree
In other words, when we first speak to the other character, we will say "Greetings!". After he
replies, we will then be presented with three options to choose from.
The "Tell me more about your wares" option will then lead us to be able to ask a different set of
questions.
Before we begin, we need to create a second character - we can't just have Roger talking to
himself! Go to the "Characters" node, right-click it and choose "New Character". Double-click the
new "cChar1" entry to open him up.
In the property grid, give the new character a RealName -- I'll call him Merchant. Now - and
this bit is vital - you also need to set this new character's script name. This is the name by which
we refer to him when creating our dialogs. I'll just use "cMerchant" as the script name. I'd
recommend you set it to something sensible like this, and don't just leave it as "cChar1" or else
your dialog scripts will get very confusing!
The AGS Tutorial
Page 43
Ok, all done? Expand the "Dialogs" node in the editor, and you'll see one existing "0" entry.
We'd may as well use it since it's there, so double-click it. (If not, you can always right-click the
Dialogs node and choose "New dialog" to make a new one). You'll see this rather empty window:
The dialog editor
Conversations in AGS are made up of topics. A topic consists of a set of options that the
player can talk about - not all of which are necessarily available to the player at the start of the
game. When the player selects an option from a topic, the topic's dialog script is run.
Each topic can contain some start-up text, which is displayed before the options are presented
to the player. Our "Greetings" line qualifies for this, so we don't need to make a special topic for it.
A topic is also referred to as a dialog in AGS -- the two words are one and the same thing.
Right, let's make our first dialog. Click the "Create new option" button three times, and three
new rows will appear in the window. You'll also notice some new lines being added to the script on
the right hand side. Make sure that the "Show" checkbox is ticked for all the options -- this
determines whether the options are initially available to the player or not.
Also, this dialog currently has no name, but we'll need to give it one so that we can access it
later. The convention in AGS is for dialogs to start with "d", so I'm going to call this "dMerchant".
Use the property grid to set the name, as usual.
Now, type in some text to the three new text boxes:
The AGS Tutorial
Page 44
We've inserted three options for topic 0
While we're at it, let's create the next set of options too. Right click the "Dialogs" node in the
project tree, and select "New Dialog". A new blank Dialog 1 is created. Double-click on this, and
again, create three new options and type them in. In the property grid, change the Name from
"dDialog1" to "dWares".
Now, go back to the first dialog (select it in the tab bar), and let's have a look at the script.
This is not the same type of script that we've used for our events like picking up the key. It's a
much simpler dialog-only scripting language.
Each of the "@" lines is an entry point. These define the different places where your script
can start. The "@S" entry point happens when the topic is first started - and so this is where we
want our "Greetings" text to be displayed.
Dialog scripting is very simple. It takes the form:
SCRIPTNAME: "Text to say"
So, in between the "@S" and the "@1" lines, insert a couple of new lines, and type the
following:
EGO: "Greetings!"
MERCHANT: "Hello there!"
return
Remember, these are the script names of the characters (but without the initial "c"). The
"return" is essential, because it tells AGS to stop running the script at that point and to display the
options to the player.
The numbered entry points will be run when the player selects the appropriate option - for
example, if the player clicks the "Who are you?" option, then entry point @1 will run.
The AGS Tutorial
Page 45
Here's a finished script for this topic:
Our finished dialog script
The goto-dialog command takes the player to another dialog - in this case, the new "dWares"
dialog we just created (with questions about the merchant's wares).
The stop command tells AGS to end the conversation and return to the game
(whereas return returns them to the list of options to talk about).
Now, we're not quite done ... we've got to deal with our second dialog too! In the tab bar, click
the "Dialog: dWares" tab to return to the main topic. Fill in the script however you like. You can
use the goto-previouscommand to take the player back to the first list of options when they get
bored of talking about his wares.
Here's my completed script for dWares:
The AGS Tutorial
Page 46
Dialog script for dWares
As you can see, it's done very similarly to the first one. Notice the use of "return" in the
startup entry point, to make sure that it doesn't go on and run the next bit of script straight away.
We're almost done! All we've got to do now is add a way for the player to initiate the
conversation.
Open up the Character editor for the new cMerchant character. Change his StartingRoom to
room 1 (ie. the same as the player character), and position him at let's say X:260, Y:130. You can
always change this later.
Now, still with the Merchant open, go to his Events list. Using your skills from earlier on in this
tutorial, add a command to initiate the dialog when the player talks to the Merchant. Now, we're
all set!
Event script to launch the dialog
Test the game, talk to the Merchant, and try out the conversation.
More on conversations
You may have noticed the "Show" and "Say" check-boxes in the dialog editors. You'll have
noticed that when the player selects an option, the player character will say the option text.
However, there are times when you won't want this to happen, and if you un-tick the "Say" box for
an option, the character won't repeat the text when the player selects it.
The "Show" box determines whether the option is initially available to the player. If you
uncheck it, then that option won't appear to start with. You can enable it later using the optionon dialog script command, or thedDialogName.SetOptionState script command.
There is also a dialog script command called option-off, which you can use to stop a particular
option from appearing once the character has found out all the vital information. See the manual
reference for more.
The AGS Tutorial
Page 47
If there is only one option enabled for a topic, then the game selects it automatically. You can
use this to make Sierra-style conversations, because the options will never be shown to the player
in this case.
The AGS Tutorial
Page 48
Getting Started with AGS - Part 9
Cursors
It's easy to overlook mouse cursors, but they provide the essential interface between the
player and the game world. In AGS, each mouse cursor provides a different mode of interaction to
the player.
The Cursors list
Unlike most of AGS, mouse cursors modes are not generic - that is, AGS has special coded
behaviour for some of the cursors. This means that you are unable to customize what some of the
cursor modes do - let's list these ones briefly:




Mode 0 (Walk to) - this will always move the player character to the co-ordinates at
which the mouse was clicked
Mode 4 (Use inventory) - AGS will only allow this mode to be selected if the player
character has an active inventory item, and it will always invoke the "Use inventory" event.
Mode 6 (Pointer) - this is used whenever a normal Windows-style mouse pointer is
required. For example, when the user is prompted to select a dialog option; when a popup
GUI is displayed, and so forth.
Mode 7 (Wait) - this cursor is shown whenever the player cannot interact with the game
world (ie. during a cutscene). It is automatically shown during blocking script functions.
All the other cursors are 'normal' cursors, in that you can use them for whatever purposes you
want.
If you want to create a Lucasarts-style game where the mouse cursor disappears during
cutscenes, the easiest way to do it is simply to import a blank image over the Wait mouse
cursor.
The AGS Tutorial
Page 49
The Cursors editor pane is fairly self-explanatory. Use the property grid to set a graphic for the
cursor; and click inside the graphic to set the cursor's hotspot, as we did for inventory items.
(The hotspot sets which spot under the cursor will be activated when you click with it).
There are a couple of other options you can set for cursors, let's cover them briefly:

Standard Mode tells AGS that this is a normal user-selectable cursor. It is used when
cycling through mouse cursors, to determine whether to use the cursor or skip over it. For
example, if during the game you disable the current cursor, AGS will change to the next
available Standard Mode.
Animate allows you to make an animated mouse cursor. If you check the box, then you
need to set the View property to the view that you want to use for the animation (loop 0 of
the view will be cycled continuously). You can also select "AnimateOnlyOnHotspot" to
make the cursor only animate while it is over something that the player can interact with;
and "AnimateOnlyWhenMoving" to do a QFG4-style cursor which only animates while the
player is moving it around.

You can right-click the "Mouse cursors" tree node and choose "New Cursor" to create
additional cursors to the standard 10. If you do so however, any extra cursors you create
will not have events created for them, so you will have to handle their clicks using the "Any
Click" events.
Fonts
The default blank game comes with a couple of basic fonts, but you don't have to use them you can import your own.
The Font Editor
The AGS Tutorial
Page 50
By default, you'll see three fonts are available. Font 0 is the standard font used in message
boxes. Font 1 is the speech font, used with lucasarts-style speech; and font 2 is an outline font for
the speech font.
Outlines are pretty much essential for lucasarts-style speech. Since the text is drawn directly
onto the screen and not onto a message box, without an outline it could be very hard to read the
text, depending on what colour the screen happened to be behind it.
There are two ways to do outlines - AGS can do an automatic outline, or you can import a
special outline font. They both have advantages:


Automatic outlining is easy to use - just set the option, and it works with any font.
Using an outline font is faster in the game, since it is just drawn once (whereas automatic
outlining has to redraw the line of text 8 times).
Importing fonts
AGS supports both TrueType (TTF) and SCI (Sierra's format) fonts. To overwrite an existing
font, simply open up its editor and click the "Import over this font" button. To create a new font
slot, right-click the Fonts tree node, and select "New font".
The advantage of SCI fonts is that they are significantly faster to render than TTF fonts; but
the disadvantage is that they only support 128 characters, which means that they are only useful
for English. If you want to support other languages then you'll need to import a TTF font in order
for the extended characters such as é, í and ñ to work.
Where can you get a SCI font? Well, there are three ways:



Create your own font and save it in SCI Font format, using Radiant's FontEdit
application.
Extract the font from a Sierra game, using the SCI Decoder program available on the
internet (note however that this will have copyright implications for your game).
You can get a Sierra SCI Font Pack on the AGS website.
If you go to your Windows Fonts folder to try and import a TTF font, you will not be able
to do so (double-clicking them will open them up in the Windows Font Viewer).
Unfortunately there is nothing I can do about this - you must either type the filename in
manually, or copy the font to another folder and import it from there.
By default, font 0 is used as the normal text font, and font 1 is used as the speech font.
To use any additional fonts, the script
properties Game.NormalFont and Game.SpeechFont can be used to change the active fonts.
The AGS Tutorial
Page 51
Conclusion
That's it for the "Getting Started" tutorials. I hope they've helped you to get a grasp of the
AGS basics. If there's anything you didn't really understand or that you think should be covered
but wasn't, please let us know on the Beginners Technical Forum, so that the tutorials can be
improved to explain it better.
The AGS Tutorial
Page 52