Beruflich Dokumente
Kultur Dokumente
org Publication
Game Maker 7
is OUT! What you need to
know ((ppgg.. 66))
Plus…
IInntteeggrraattee w
wiitthh VViissttaa’’ss ggaam
mee eexxpplloorreerr PPllaayy ggaam
meess ooff yyeeaarrss ggoonnee bbyy
((ppgg.. 1177)) ((ppgg.. 22))
Markup is an open publication made possible by the contributions of people like you; please visit markup.gmking.org for information
on how to contribute. Thank you for your support!
©2007 Markup, a GMking.org project, and its contributors. This work is licensed under the Creative Commons Attribution-Noncommercial-No Derivative Works 2.5 License. To view a
copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/2.5/ or send a letter to Creative Commons, 543 Howard Street, 5th Floor, San Francisco, California, 94105,
USA. Additionally, permission to use figures, tables and brief excerpts from this work in scientific and educational works is hereby granted, provided the source is acknowledged. As
well, any use of the material in this work that is determined to be "fair use" under Section 107 or that satisfies the conditions specified in Section 108 of the U.S. Copyright Law (17
USC, as revised by P.L. 94-553) does not require the author’s permission.
The names, trademarks, service marks, and logos appearing in this magazine are property of their respective owners, and are not to be used in any advertising or publicity, or
otherwise to indicate sponsorship of or affiliation with any product or service. While the information contained in thi s magazine has been compiled from sources believed to be
reliable, GMking.org makes no guarantee as to, and assumes no responsibility for, the correctness, sufficiency, or completeness of such information or recommendations.
Editorial
Editor’s Desk
Graphics Effects
So there are two types of graphics
effects that I have noticed: destruction,
and smoke – but I’m sure I might find
more if I play it a bit longer.
P age |6 http://markup.gmking.org
Reviews
GAME DEVELOPER IDES
P age |8 http://markup.gmking.org
Reviews
GAME DEVELOPER IDES
P a g e | 10 http://markup.gmking.org
Reviews
GAME DEVELOPER IDES
Collision Checking works with Is there something wrong Here’s the thing, Mark never lied: the
Scaled Instances with Game Maker 7.0? .gmk encryption is aimed to stop
If an instance of an object has a scaled projects that access Game Maker source
You might ask: is there something
sprite, it won’t stop you from having files like G-Java. It is Mark’s belief that
wrong with Game Maker 7.0? And the
proper collision checking in Game by stopping projects like G-Java, it is
answer would be: definitely. Game
Maker 7.0! That’s indeed good news. actually in Game Maker’s best interest,
Maker 7.0 is by far not perfect when we
and he means it.
Collision_ Functions with non- judge it a separate piece of software.
However, when looking at it at a simple Users were upset because they thought
integer Coordinates work
upgrade, it has no bad points compared what Mark was sort of a betrayal to the
properly to Game Maker 6.1 (except for the .gmk Game Maker members who have
All of the collision_ functions that check
encryption, we’re getting to that later). worked hard to provide such tools for
for collisions between lines, rectangles,
Game Maker. They also believe that
circles, etc. and objects now work as So, this means that if you want to use
Mark hasn’t gave much thought about
expected, even if their coordinates are Game Maker as a regular game
incorporating that “feature”, and have
non-integers. development tool, you definitely should
said that it would do more harm than
get Game Maker7.0 –it is that simple:
Opening a Non-Existent Game Maker 7.0 isn’t worse than Game
good to Game Maker, since those
Binary File Creates it making these tools could decide to
Maker 6.1, as a matter of fact: it’s
make their own Game Development
As with the rest of file handling better. The other question is: is it what
toolkits that rival against Game Maker.
functions, the open function for binary we had expected? And the answer to
files file_bin_open() now creates the file that could be different from person to In my point of view, however, Mark’s
to be opened if it doesn’t exist. It’s person; I’ll tell you my point of view probably more right. Converters would
surprising such function didn’t exist after a couple of sections. create lots of benefit for Game Maker,
before. true. But the important point is, they
would create much confusion to the
Setting Object Parent Via GML The .GMK Encryption beginner users, it might as well hurt
now has Checks The “.gmk encryption” is a new change
Game Maker’s reputation when
So, the object setting function of GML in Game Maker introduced by Mark
features in the converters themselves
now has addition checks to see if any Overmars. It has been highly
do not work – and that was what
cycles were made in the object’s controversial in the Game Maker
concerned Mark.
April, 2007 11 | P a g e
Reviews
GAME DEVELOPER IDES
TUTORIAL
Game Maker Tutorial
Getting the number of blue pixels on The Example
the screen in Game Maker is an
excellent example of the return function width=room_width;
of Game Maker. height=room_height;
current_x=0;
This script makes a loop that checks the current_y=0;
color of each pixel on the room. To do blue_pixels=0;
repeat(height)
this, we check one row at a time, then {
move on to the next row. repeat(width)
{
It then returns the number of blue current_pixel_color=draw_getpixel(current_x,current_y);
pixels in the current room. Handy if you if current_pixel_color==c_blue
{
were making a game that required user
blue_pixels+=1;
interaction with colors, or for a drawing }
program. }
current_y+=1;
current_x=0;
}
return blue_pixels;
P a g e | 12 http://markup.gmking.org
Tutorial
DRAWING TUTORIAL
Surfaces
reset) the surface. enter in the “w” field in the
“surface_create(w, h)” function.
Introduction But this is not all what surfaces are
Surfaces is a new feature that was about! When you draw a surface, the surface_get_height(id)
added in Game Maker 6.1, it allows the surface uses the system temporary
Returns the height of the surface with
user to use the normal draw functions memory to save its contents, which
the given id. The height is what you
to draw on a canvas, or a “surface” means it acts as if it is a bitmap file (or
inter in the “h” field in the
once, and then, it can be saved to a file, something similar) in a file in the Main
“surface_create(w, h)” function.
drawn on the screen, go through some Memory! So that is why speed is saved
when using a surface.
manipulations and rotations, or get First Attempt
copied to another surface. Ok! So let’s try out these functions that
Since we now know what a surface is, I
we have just learnt in a piece of code,
Benefits think we can start learning about the
code these surfaces use in order to and see what happens! We will create
Surfaces usually are handy when
function. an object called “o_surfaces” and put
making a paint system, like MS Paint.
this code in its Create Event.
You draw a line to the screen, then the
line is saved on the surface, and the surface=surface_create(50,100);
Primary Code //Creates the surface
surface is drawn at the end of each
draw_text(5,5,“This text is drawn in
step, which means that even if you The Basics the create event.”);
draw thousands of lines on the surface, surface_create(w, h) /*The code above attempts to draw
then draw the surface on the screen, text in the create event!*/
the game will still run fast, as the Creates a new surface with the width
surface is drawn all at once, not each “w” and height “h.” It then returns the Explanation of First Attempt
line separately. surface “id” which is used in all the The code above creates a surface called
other functions. This means that when “surface” and attempts to use it to
Concept calling this function, you must set a draw text in the create event, and
To understand Surfaces more, we have variable’s value to this function, like therefore take advantage of the
to understand the regular drawing first. “_var=surface_create(5,5)” surfaces by using a drawing action once
To do that, imagine that the main room to draw on a surface on the screen.
in any game made with Game Maker is surface_exists(id)
Problem
just a simple piece of cardboard, that
Checks whether the surface with the But after you place the object in the
everything you draw on it is erased
given id exists. Returns true or false (1 room and run the game, you will notice
after one millisecond. Therefore, if you
or 0, respectively). that no text is drawn! “Why is that?”
draw a line once, it would be removed
you wonder!
after one millisecond, which means that surface_free(id)
you need to draw it once after each Reason
Frees the memory that the surface with
millisecond is over. The answer is simple! Game Maker
the given id is using. This must be called
doesn't understand automatically when
However, Surfaces are just a piece of when there is a surface you are no
to draw on a certain surface and when
paper that “flies” above the main room longer using in order to save memory.
you need to draw on the main room, so
(or the piece of cardboard) and lines
surface_get_width(id) you need to use certain functions that
drawn on it do not get removed after
will switch between drawing on
each millisecond, but they stay drawn Returns the width of the surface with surfaces and the main room, and switch
on the surface unless you empty (or the given id. The width is what you
April, 2007 13 | P a g e
Tutorial
DRAWING TUTORIAL
Surfaces Cont.
between making the drawings on Reason “height.”
certain surfaces between each other. It’s simple: the test is saved in the
surface, and it is in the memory, but it is draw_surface_ext(id, x, y,
Code Explanation will help: xscale, yscale, rot, color,
not drawn to the game’s main screen! It
alpha)
surface_set_target(id) is true that I said you don’t have to use
the draw functions constantly to draw Draws the surface with the given id in
This function is the function that tells all the drawings and lines, but however, the position (x, y) scaled by xscale and
Game Maker what is the target of the you do need to draw the surface. So yscale (1= no scaling) and rotated using
drawing. You need to enter the id of when you draw a 100 lines in the the value rot (0=no rotation), and with
which surface do you want the drawings surface, you only need to execute one blending color (use c_white for no
to be on. each step (the surface drawing blending) and the transparency alpha
function), not zero. Below is the code value from 0 to 1, whereas 0 is
surface_reset_target()
explanation for the surface drawing transparent completely.
Resets the drawing target to be on the functions. They have been copied from
the help field, and then edited to make draw_surface_stretched_ext(id, x,
normal screen again. It is important to
y, w, h, color, alpha)
use this code immediately when you the functions clearer.
finish drawing what you need on the Draws the surface with the given id
draw_surface(id, x, y)
surface, as it may mess up the whole stretched to the size of (w, h) in the
game; objects, backgrounds, and other Draws the surface with the given id in position (x, y). Color is the blending
things are drawn on the main screen, the position (x, y) without any colors or color (c_white=no color blending) and
making the game draw these things on a alpha blending. alpha indicates the transparency setting
surface may corrupt the game. from 0 to 1 whereas 0=transparent.
draw_surface_stretched(id, x,
Second Attempt y, w, h) draw_surface_tiled_ext(id, x,
surface=surface_create(50,100); y, xscale, yscale, color,
//Creates the surface Draws the surface with the given id alpha)
surface_set_target(surface); stretched to the width of w and h, in the
//Sets drawing surface target position (x, y). Draws the surface with the given id tiled
draw_text(5,5,“This text is drawn in
so that it fills the entire room and starts
the create event.”); draw_surface_tiled(id, x, y)
/*The code above attempts to draw in the position (x, y), but now with scale
text in the create event!*/
Draws the surface with the given id tiled factors (xscale, yscale) and a color
surface_reset_target();/*Resets the blending (color) and transparency
drawing target. The drawing target so that it fills the entire room. It starts
is not set as the main screen in the tile in the position (x, y). setting (alpha) from 0 to 1 whereas 0 is
order for the game to continue transparent.
functioning properly without draw_surface_part(id, left,
corruption.*/ top, width, height, x, y) draw_surface_part_ext(id,
left, top, width, height, x,
Problem Draws the indicated part of the surface y, xscale, yscale, color,
Go ahead and test this code, you may with the given id that is drawn at the alpha)
think it will work. But it still wouldn't! position (x, y). The part of the surface
Do you have any idea why? Draws the indicated part of the surface
starts and the position (left, top) with
with the given id that starts on the
the width “width” and the height
position (left, top) of the surface, with
P a g e | 14 http://markup.gmking.org
Tutorial
DRAWING TUTORIAL
Surfaces Cont.
the width and height (width, height), you may see that a part of the text is (source) to the new surface
with its origin at position (x, y) but now not drawn, that is because your surface (destination). The (source) copied will
with scale factors (xscale, yscale) and a width is “50,” and there might not be be pasted in the position (x, y) of the
color blending (color) and transparency room for all the text! This, ladies and new surface (destination). The copying
setting (alpha) from 0 to 1 whereas 0 is gentlemen is the magic of surfaces! occurs without doing any blending.
transparent.
Now let’s move to the more-complex surface_copy_part(destination,
draw_surface_general(id, left, part of the surfaces, which is the once x, y, source, xs, ys, ws, hs)
top, width, height, x, y, dealing with files and saving.
xscale, yscale, rot, c1, c2, This function copies a part of the
c3, c4, alpha) surface (source) to the new surface
Secondary Code (destination). The (source) copied will
The most general drawing function. It be pasted in the position (x, y) of the
draws the indicated part of the surface Files and Saving new surface (destination). The part of
with the given id, that starts on the surface_save(id, fname) the (source) to be copied will start on
position (left, top) in the surface, with position (xs, ys) of the source and have
the width and height of (width, height), This function saves the whole surface
the width (ws) and height (hs). The
with its origin at position (x, y) but now with the given id to a bitmap file. The
copying occurs without doing any
with scale factors (xscale, yscale), a filename must be a string (fname). The
blending.
rotation angle (rot), a color for each of “fname” could be just the name of the
the four vertices (top-left, top-right, file or its complete target.
bottom-right, and bottom-left) Cleaner Surface Drawing
surface_save_part(id, fname,
(c1,c2,c2,c4 respectively), and an alpha To draw to a cleaner surface, all add this
x, y, w, h)
transparency value (alpha) from 0 to 1 piece of code after
whereas 0 is transparent. This function saves a part of the surface surface_set_target(id):
with the given id to a bitmap file. The
Third Attempt draw_clear_alpha(c_white,0);
filename must be a string (fname). The
So in order to make the drawing on “fname” could be just the name of the This will make the surface completely
surfaces function work properly, you file or its complete target. The part of transparent.
need to draw the surface in the draw the surface begins at the position (x, y)
event, all the other code that you have on the surface, and has the width (w)
made in the create event is correct and and height (h). Special thanks & Closing
must stay the same. Add the following Remarks
code to the Draw Event. More Functions
Thank you for reading this tutorial. The
surface_getpixel(id, x, y)
draw_surface(surface,0,0); //Draws tutorial has been originally written by
the surface This function gets the color of the pixel Eyas Sharaiha and published in the
in the position (x, y) in the surface with Game Maker community. It is now part
Result the given id. of our wiki (GMking.org’s Wiki), you can
Now you can clearly see that the text is visit the wiki here:
drawn, even though only the surface surface_copy(destination, x,
drawing function is called! Depending y, source) http://wiki.gmking.org/
on your system and font-size settings,
This function copies the whole surface Eyas Sharaiha
April, 2007 15 | P a g e
Tutorial
PROGRAMMING TUTORIAL
PROGRAMMING TUTORIAL
<Version>
element is an important but optional Another element I really like is the
<VersionFile ratings element which gives you
attribute that allows you to choose the
path="bin\MyGame.exe"/> recommended and required “Windows multiple rating attributes for the game,
</Version> Experience Index” values for running so that parents or anyone else could
your game. know if the games suit themselves,
The developers element specifies the
their children, or any other person.
developers of this particular game, a <WindowsSystemPerformanceRating
link to their website can also be minimum="4" recommended="5"/> I’m not going to talk much about that
included: element, but you can read more info at
The table below lists the attributes for their MSDN article. Use the links at the
<Developers>
WindowsSystemPerformanceRating. end of the article.
<Developer
URI="http://www.microsoft.com">Mi There’s also an element called the The Game Executables element is the
genres element, which could contain last one I’ll talk about. It is very simple
crosoft</Developer>
multiple genre elements, it looks as to use and understand:
</Developers>
follows:
<GameExecutables>
Note: A total of five different developer
<Genres> <GameExecutable
links could be added inside the
path="bin\game.exe"/>
developers element <Genre>Action</Genre> </GameExecutables>
<Genre>Adventure</Genre>
The publishers element specifies the An example of the complete code of
</Genres>
publishers of this particular game, a link the document is below:
to their website can alos be included: Complete document code
<?xml version="1.0" encoding="utf-16"?>
<Publishers> <GameDefinitionFile xmlns="urn:schemas-microsoft-
com:GameDescription.v1"
<Publisher xmlns:baseTypes="urn:schemas-microsoft-com:GamesExplorerBaseTypes.v1">
URI="http://www.microsoft.com">Mi <GameDefinition gameID="{dc90fdca-aa28-4d13-8401-ad149e4bccae}"
WMID="{9e6c8124-5159-4aed-a175-a2dd292dfe86}">
crosoft</Publisher> <Name>Boggle"!</Name>
</Publishers> <Ratings>
<Rating ratingID="{7a53b0be-b92d-4e8a-a11f-8e6f9f3c575b}"
ratingSystemID="{768bd93d-63be-46a9-8994-0b53c4b5248f}" />
Note: A total of five different developer
</Ratings>
links could be added inside the <Version>
developers element <VersionNumber versionNumber="1.0.0.0" />
</Version>
The </GameDefinition>
</GameDefinitionFile>
WindowsSystemPerformanceRating
P a g e | 18 http://markup.gmking.org
Tutorial
PROGRAMMING TUTORIAL
April, 2007 19 | P a g e
Tutorial
PROGRAMMING TUTORIAL
C++ “Hello World” tutorial normal. The important thing is knowing now, but most functions return values
C++ is one of the most popular
that the line of code "int main()" of some sort, so the return itself is used
programming languages out there, but
initializes the code. It is in this function to mark the end of a function.
learning can be a tedious process.
that all the actions occur.
Since we really do not need to return
One of the first things anyone learning
Many also like to use: any value, let’s just choose to return
C++ should know is outputting text.
“0”:
Unlike more recent software, no void main()
function exists in C++ “as is” that could return 0;
display text; instead, you need include But I personally – for some weird reason
“libraries” that would introduce such – prefer using int, so that’s how we’re Final Code Form
functions and capabilities. going to continue. #include <iostream>
int main() {
To start the tutorial, open a new C++ The curled brackets you saw earlier std::cout << "Hello World!!\n";
project, and start working on the main define the beginning and ending of a return 0;
}
.cpp file. (Need a development tool? block of code. All the code that we will
Try Microsoft Visual C++ 2005 Express perform in this tutorial must be in the
Edition SP1, you can get it from int main() block of code. Running the code
http://msdn.microsoft.com/vstudio/express
The actual code to output the “Hello You can build the C++ project or you
and, it’s totally free!)
world!” text is: can use the Debug function to run it.
Note: in Visual C++ 2005 Express
The Code std::cout << "Hello World!!\n"; Edition, you will not get a "Press Any
The very first thing you should include is Key to Continue . . ." message, and the
The “std::cout<<” is the command that program ends instantly if it is run in
Input/output stream that would allow
tells the computer to output text. The debug mode, therefore you will see no
you to output text. In older versions of
text written later must be a “string” – so result. To fix that, click on the Debug
C++, you could include a header file (.h
text and numbers should be surrounded menu on top, and then click on the
file) that would give you these
by quotation marks. menu item "Start Without Debugging".
functions, but now it is done differently:
The final “\n” you see at the end defines
#include <iostream>
a new line, similar to the Enter Key we
End Result
use when typing text in notepad or
To start giving out instructions to output When running the program, you should
word. If this wasn’t use, the “Insert any
the text, you should first initialize the see the following:
key to continue” text that is normally
main function that would execute the
automatically outputted by C++ would Hello World!!
actual code. You could do so by typing:
be right next to the “!!” in the text you Press any key to continue . . .
int main() { outputted.
… However, if you have omitted the “\n”
} Another important thing is that all (newline) at the end of the code, as
instructions must end with a semicolon stated earlier, you would see:
The "int" stands for integer. That means (;), otherwise an error is outputted.
"int" initializes the function main()’s Hello World!!Press any key to
Finally, to conclude the function “main”, continue . . .
returned value as an integer. This might
be hard to understand when you first we need to write a return instruction,
Eyas Sharaiha
start programming C++, but that's this might seem pretty meaningless
P a g e | 20 http://markup.gmking.org
gmpedia.org
forums.gmking.org
openload.info
ircbloopers.com
gmking.org
irc://irc.gamemaking.org/#gmking
April, 2007 21 | P a g e