home | et13 - game prototyping in Gamemaker | prev | next |
David
Javelosa |
|
week
11 - Video,
Repurposing, Scripting & Randomization
|
HOW
TO REPURPOSE? / Gamemaker Basics Review
What To Change
- sprites
- Sounds
What To Keep
- objects
- events/actions
- rooms
Scripting
Comparing
the programming interfaces of then vs. now:
- Command Line Interface (CLI) - C,
C++, Assembler, Basic, DOS, Lingo
- Graphic User Interface (GUI) -
Macintosh, Windows, mouse & menus
GML:
The Game Maker Language
Overview:
There are almost 1,000 functions and variables available to control game action in Gamemaker. There are different places where scripts can be inserted. First, a script must first be defined. Secondly, the code action must be added to an event. The code action also must be scripted.Thirdly, scripts can run from a room's creation code. Also, GML expressions can be used when specifying a value in an action. When using GML, all resources must be named with the legal naming convention: start with a letter, no spaces and no punctuation marks except underscore "_". Every resource must have an unique name! Keywords may not be used, including: "self", "other", "global" or "all".
A
program :
A program is a set of instructions called statements. Each begins with the symbol "{" and is puntuated with a "}".
Variables:
Variables are memory locations that store information. They are named for access and can be stored as a real number or a character string. They should be as descriptive as possible such as mouse_x which would indicate horizontal position of the mouse. Legal characters apply. Maximum length for a string is 64. When a new variable is local to an instance, programs in other instances are independent of them.
New variables are created when you assign a value to them.
They can be local or global.
If you are using several variables in a program, they can be declared at the
same time with:
var <varname1>, <varname2>, <varname3>,...
Assignments:
An assignment stores a value in a variable: <variable> = <expression>
Expressions:
An expression can be a simple value or more complicated like
a formula suxh as
Example:
{
if (x < 0 && hspeed < 0) x = room_width + sprite_xoffset;
if (x > room_width && hspeed > 0) x = -sprite_width + sprite_xoffset;
if (y < 0 && vspeed < 0) y = room_height + sprite_yoffset;
if (y > room_height && vspeed > 0) y = -sprite_height + sprite_yoffset;
}
When
the instance moves outside the room, this script wraps it to the other side
of the room.
sprite_index = random(4)
}
Copyright © 2001-2014, David Javelosa unless otherwise stated. |