You are on page 1of 36

Data structures

Particle effects
GMPhysics
Introduction to DLL making
Level editors
Smooth online movement
And Much More!

Interviews Resources Previews Reviews Tutorials


Contributors This Issue
Future-proofing

EDITOR’S DESK
Robin Monks Editor
How can you ensure your creation will your choice of programming language Eyas Sharaiha Editor
Andris Belinskis Editor
be around 10 years down the road and and development environment will
Leif Greenman Writer
still be enjoyed? That’s the topic for affect the about of time the game will
Rhys Andrews Writer
this month’s Editor’s Desk. remain operable. Game Maker has a José Méndez Writer
good record here, with a game made in Philip Gamble Writer
This month was a bit different, as you GM v6 being playable on Windows 98 to Gregory Writer
probably guessed by the late release Windows Vista, a time frame of 10 Bart Teunis Writer
date, mainly I headed off on a two years. Sean Flanagan Writer
month vacation and passed the mag Jake Writer
onto Eyas, who then left for vacation But, what can you do if you make a Stephan Writer
and passed it onto Andris, who then game, and there isn’t a great interest in Dan Meinzer Writer &
left. Long story short I’m finishing the it, or you are no longer able to maintain Graphic Designer
mag on my vacation time . We should it? How can you keep the game
be back on track for next issue, just progressing? Open Source it! Release it
keep those articles coming in! under a license like the GPL or Creative Table of Contents
Commons and let other continue to Editorials
But, heading back to the original learn from it and improve upon it. Your Future-proofing ............................... 2
question, how can you “future-proof” work lives on! Clone Games.................................... 6
your game and have it available for Make your code easier to read ....... 10
years to come? It’s a tough job, and it Not to mention open sourcing your Promoting your game to the GMC .. 20
has to start way back in the planning work under one of the aforementioned Tutorials
stage with you subject matter and licenses from the get go will allow you Particle Effects Tutorial .................... 3
Real time blur .................................. 7
target audience. Does your audience to get contributions and patches from
Cartesian and Polar Coordinates ...... 9
need knowledge of a current event (e.g. fellow game developers, and can also Binary for Beginners....................... 11
a sporting event?). Is the subject matter open up the opportunity for you to use Coding Styles ................................. 14
time-specific? This will limit the code and resources from other open Modulo in Computer Science ......... 15
enjoyable life of your creation. source games in yours. Smooth Online Movement ............. 17
Introduction to Making DLLs .......... 19
There is also the development side; Another way to keep your game living Level Editors .................................. 22
on is to have it hosted on many sites, so GMPhysics ..................................... 25
as sites begin to die out you’ll still have Graphic Design ............................... 31
Sound Effects: How Far? ................ 32
your game hosted elsewhere, and
Reviews
people will still have the opportunity
Textbar Maker ............................... 14
to download it. _FATAL_......................................... 33
Bounce 2 ........................................ 34
Keep up the games! I’ll see you Snow Ball War................................ 35
next month (hopefully ). Monthly Specials
Extension of the Month.................. 29
Script of the Month ........................ 30

Robin Monks,
Editor
MarkUp is a gmking.org publication;
please visit GMking for more free game
development resources!
2|P a ge July, 2007 http://markup.gmking.org
Photo © 2007 Robin Monks
GAME EFFECTS
Particle Effects Tutorial GAME EFFECTS

Introduction
Particle Effects are one of the most well
known visual/special effect methods
used in GML, and in many other
languages as well. Particles are various
shapes (and sizes), with very little
information. This information includes
where they’re supposed to go, their
appearance, and more. With such little
information, particles take little CPU
usage to calculate where and how to
draw them on the screen. This is why
particles are a great method to use if
you want effects such as rain,
explosions, smoke, fireworks, flames, within a
and more. In the GameCave Effects region in the room),
Engine, many engines are created on deflectors (which bounces
particles alone (and sometimes with particles off an invisible force), and
some non-particle effects attached). changers (which change particles into
Unfortunately, Particle Systems/effects other types of particles when they
collide with an invisible region/force). In //Create an attractor in the system
can take some time to get the hang of. 'system0'
They also take a lot of trial and error, this tutorial, only the emitter filter will
destroyer =
and patience to get individual particle be explained in detail. part_destroyer_create(system0);
//Create a destroyer in the system
types the way you want them.
'system0'

Inside a particle system are two types of Creating systems, filters, changer =
part_changer_create(system0);
elements. Particle Types, which are the and types //Create a changer in the system
particles themselves – what they look A game can have as many systems, 'system0'
like, how they move, how they live/die, particle0 = part_type_create();
filters, and particle types as you like. Of
//Create a particle type.
etc. Particle types are actually not a part course, the more you have, the more
of any system, and can be used by any memory they take up. To create one of If you do not assign these functions to a
system – however, for the sake of these, all you must do is use the variable, the system is still created
simplicity I like to think of particle types following functions: however you will not be able to access it
as part of a system. The other type is because the unique ID of the system,
system0 = part_system_create();
filters. Filters manipulate and change filter, or type was not saved to anything
the life of the particle as it is displayed //Create a System you can refer to. Remember, if you
on the screen. The most commonly used emitter = create a second system and assign it to
filter is an emitter. Emitters create the part_emitter_create(system0);
the same ‘system0’ variable, the old
particles in certain regions of a room. //Create an emitter in the system system will technically be lost and you
Other filters include attractors (which 'system0' will not be able to do anything with the
draw particles to a certain position with attractor =
system.
part_attractor_create(system0);
an amount of force), destroyers (which
destroys particles that come

3|P a ge July, 2007 http://markup.gmking.org



GAME EFFECTS
Particle Effects Tutorial GAME EFFECTS
determine the region where
As you can tell, systems and particles do particles have.
particles can be created. The x
not have any arguments. This is because
part_system_update(system0); minimum and y minimum are
they are not assigned to anything.
like the top and left sides, while
Systems cover all the filters, and so
This handy function allows you x maximum and y maximum are
filters must assign to the system but not
to fast-forward the movement like the bottom and right sides.
vice versa. Particles are not part of any
of particles. If you, for instance, When the emitter releases
system, but filters inside systems (and
create a snow effect, and the particles, they can only be
systems themselves) affect them.
snowflakes are created around released within these sides. The
After you create systems, filters, and the outside of the room, you last two arguments determine
particle types, it’s a good idea to start want to have the room start the shape and way of
customizing them. This allows you to with snowflakes all over the distributing particles within the
make the filters, particles, and systems room, instead of hanging x/y coordinates. A linear
behave as you want them to. In this around the outside of the room distribution
tutorial, I will show some key functions and slowly drifting in. (ps_distr_linear) means
and how to use them – however, to the particles have equal chance
To do this, you use this function
explore the boundaries just search for of being created in all areas of
to move the particles 1 step
the function prefixes (i.e part_type_ or the region, while a Gaussian
forward (and of course repeat
part_system_ ) in the GM manual and distribution
the function multiple times).
you will find an index of all the (ps_distr_gaussian) means
functions. that particles have more chance
Common Emitter Functions of being created right in the
middle, and quadratic ally
Common System Functions decrease chances as it gets to
part_system_position(system0,x,y); the edges of the region. See the
diagram on the right to see how
This presents the position of the
shapes fit with regions. Finally,
system. All filters in the system
an inverted Gaussian
that are positioned in the room
(ps_distr_invgaussian)
somewhere are positioned
has more chance of particles
relative to this functions x and y
being created on the edges of
values. For instance, if the
the region than the centre.
position of an emitter is from 5-
10 (x) and 5-10 (y), and the Below is a list of possible shape and
position of the system is part_emitter_region(system0,
distribution constants that can be used
changed from its default 0,0 emitter, x, x, y, y, ps_shape_line, in the last 2 arguments of this function
values to 5,5 - then the emitter ps_distr_linear);
will be placed at 10-15 (x) and  ps_shape_diamond
This function is very important  ps_shape_ellipse
10-15 (y) on the room.
with any emitter. It determines  ps_shape_line
part_system_depth(system0,depth); the position of the emitter on  ps_shape_rectangle
 ps_distr_linear
the room (relative to the
When particles are created from  ps_distr_invgaussian
systems position) and how the  ps_distr_gaussian
emitters inside a system or a particles are created from this


system itself, this function will emitter. The x and y arguments
determine what depth the

4|P a ge July, 2007 http://markup.gmking.org


GAME EFFECTS
Particle Effects Tutorial GAME EFFECTS
Common Particle Type functions work just like the 3
Functions alpha functions, in that they
part_type_alpha1(particle0,1);
give a fixed color for the birth of
the particle, and the colour
part_emitter_burst(system0,emitter,p
part_type_alpha2(particle0,1,0); fades to the second and third
article,10);
key colours throughout its life.
part_type_alpha3(particle0,1,0.5,0);
part_emitter_stream(system0,emitter, The fourth function gives 2
particle,1);
These 3 functions control the colors in which the particle
alpha (transparency) values of must pick a colour between the
These functions actually create
the particles. The first function two colours. For instance, with
certain particles into the
gives a fixed alpha value that c_red and c_white as the mix,
emitter, using the region and
the particle withholds from its the particle can be anything
any other
birth to its death. The second between pure red and pure
specifications/customizations
function uses a 'fade to' white, such as light red.
the emitter has had. The first
function "bursts" a set amount technique, in which the particle part_type_direction(particle0,0,360,
of particles into the region. This is created with the first alpha 0,0);
doesn't affect how the particles value and fades into the second,
move - it simply means one reaching the second as soon as This function gives the particle
group of particles is created and it dies. The third function is direction in its movement. A
then no more are created similar to the second however it minimum and maximum
unless the function is called has a second key frame for the direction can be given, plus an
again. The last argument asks peak of its life. 'increment' value (how much
for how many particles to burst, the direction is increased by
part_type_blend(particle0,true);
while the second last argument each step), and a 'wiggle' value
asks for the ID of the particle (how much the direction sways
This function can give the
you'd like to burst (the variable from its midpoint).
particle additive blending (the
name that accompanied the colors being drawn behind it are part_type_shape(particle0,pt_shape_e
creation function). added to the color of the xplosion);
particle), or can take away the
The STREAM function works This function allows you to pick
blending if given a false value.
very similarly, however stream from the predefined shapes that
continually creates more and part_type_color1(particle0, c_red); GM supplies, to apply it to your
more particles. Every step, in particle. Without this the
part_type_color2(particle0, c_red,
fact, a new batch of a specified particle is a lousy pixel (or you
c_white);
amount of particles is created. If can pick the particle as a lousy
you want the streaming to go part_type_color3(particle0, c_red, pixel using pt_shape_pixel).
slowly, you can specify a c_white, c_yellow);
You can of course make your
negative number for the last part_type_color_mix(particle0, own shapes and use the
argument; this means that 1 c_red, c_white); part_type_sprite function
particle will be created on an instead. The following shape
average of steps. -5 will mean These four functions can constants can be used:
an average of 1 particle will be determine the color of your
created every 5 steps. particle. There are other  pt_shape_circle
functions but these are the  pt_shape_cloud
most common. The first 3  pt_shape_disk
5|P a ge July, 2007 http://markup.gmking.org 
GAME EFFECTS
Particle Effects Tutorial GAME EFFECTS
 pt_shape_explosion
speed 'wiggle'. part_---_exists(system0);
 pt_shape_flare
 pt_shape_line part_type_life(particle0,50,100); Returns whether the filter, type,
 pt_shape_pixel or system exists.
 pt_shape_ring This function tells the particle
 pt_shape_smoke its life span. You can give it a
 pt_shape_spark minimum life span, and a Conclusion
 pt_shape_sphere maximum life span - both in I hope this gives you a bit of a better
steps. understanding in particles. It’s quite
 pt_shape_square
 pt_shape_star hard to compress all the information
about particle systems into 5 pages, and
part_type_size(particle0,1,2,0.1,0);
Global Common Functions so I’ve only explained the most
These functions are used in all filters, important parts. If you’re at all
This function provides the
types, and systems (unless stated interested, feel free to read my full, 17-
particle with sizes. A minimum
otherwise). They all perform similar
size, maximum size (the particle page tutorial from
“maintenance” actions. Replace (---) http://gmc.yoyogames.com/index.php?
will pick an initial size between
with the prefix, such as ‘system’, ‘type’, showtopic=272034, or if you want to
these two), a size increment
or ‘emitter’. see some particle effects in action, you
(how much the size increases or
decreases if a negative value is part_---_destroy(system0); can download the GameCave Effects
given), and a size 'wiggle'. Engine from
Destroys (removes from the http://gmc.yoyogames.com/index.php?
part_type_speed(particle0,5,10,1,0.5
memory) the system, filter, or type. showtopic=138220
);

part_---_clear(system0); And remember, particles are very useful


The function defines how fast
but use them in consideration – just like
the particle will go. Provided is a Reverts all the customizations of you would for laxatives.
minimum and maximum speed the filter, type, or system to its
for the particle to start with, a default settings. Rhys Andrews
speed increment per step, and a

EDITORIALS
Clone Games
“Clone games” is a subject that sound effects, programming, and more. tasks, such as creating a flawless
personally confuses me. On one hand it battle engine, etc.
is true what they say: people who do There’s also something else: and that is
clone games are just copying ideas of that making clone games requires a skill Basically, making clone games also
that no other type of games require: requires talent – just a different type
other games – they’re not innovating.
copying. of talent.
But that’s only one side of the story. It is
true that people who make such games To make a good clone game, the I made it clear that there’s nothing
are not innovating – but that’s only elements of the game need to be wrong with clone games, or people
when it comes to game design. replicated properly – the better the who make them – but does an
replication, the better the game. average gamer want to play a clone
There’s so much more in a game than game: usually, no.
game design, this includes graphics, Replication varies from using the same
effects and timing, to more complex Eyas Sharaiha

6|P a ge July, 2007 http://markup.gmking.org


GAME EFFECTS
Real-time Blur GAME EFFECTS
Blur effects can make your game look image_alpha/(iterations*0.3));
}
quite professional if used well. There
are several ways to achieve real-time
That´s it. Notice how I multiplied the
blur in GM, here we are going to
precomputed values by a "blur"
implement two: The first method is
variable. That will allow us to control
easy, cheap and quick, and the second
the amount of jitter applied (That is, the
one is slower and a bit more elaborated
separation between drawing points).
but will yield excellent results.
Now, use the array initialization code at
the beginning of the game (you can
First Method: Jittering Just store in an array a few of the write the code in a script if you like, or
Jittering consist in taking an image and drawing coordinates we produced using use it as the room creation code of the
draw it several times, in the same place, our function, so that we don´t have to first room), and put the drawing code in
but moving it a bit each time in a recompute them each time: the draw event of the object you want
different direction. We will draw the to blur.
image with a very low alpha value, so //initialize jitter array:
global.jitter1[0,0] = -0.334818; //x
that in the end, all the "stacked" images Execute it: As you can see, the quality is
coordinate 1
will look like a blurred version of the global.jitter1[0,1] = 0.435331; //y good for low blur values, but when we
original. coordinate 1 try to crank up the blur, it begins to look
global.jitter1[1,0] = 0.286438; //x really ugly. So it is good only if you want
So, we need a function to know where coordinate 2
global.jitter1[1,1] = -0.393495; //y
a quick and subtle blur effect.
to draw the image each time. It should
coordinate 2
be as quick as possible to compute, you global.jitter1[2,0] = 0.459462;
can use any kind of distribution, even global.jitter1[2,1] = 0.141540; Second Method: Repeated
global.jitter1[3,0] = -0.414498;
random points. However some
global.jitter1[3,1] = -0.192829;
Linear Filtering
functions will make the blur look better I found this clever idea in an OpenGL
global.jitter1[4,0] = -0.183790;
than others. You can use this one, for global.jitter1[4,1] = 0.082102; tutorial, and I thought it could be
example: global.jitter1[5,0] = -0.079263;
applied to Game Maker. It takes
global.jitter1[5,1] = -0.317383;
angle = 0; global.jitter1[6,0] = 0.102254; advantage of a very common feature in
spiral_spread = 1; global.jitter1[6,1] = 0.299133; modern graphic cards: linear texture
for(i = 0;i<360*iterations;i+=1){ global.jitter1[7,0] = 0.164216; filtering.
posx = x+cos(angle)*spiral_spread; global.jitter1[7,1] = -0.054399;
posy = y+sin(angle)*spiral_spread; The trick is as follows: What happens if
angle+=5; Next, we only need to draw the image
spiral_spread+=0.1;
we take a 32x32 image (for example)
several times (for this we will use a "for" and we divide its size by 2? We obtain a
draw_sprite_ext(sprite_index,
image_index, blurx, blury, statement) slightly altering the drawing 16x16 image, with less quality than the
image_xscale, image_yscale, coordinate using our precomputed original. Now, try to scale it again to
image_angle, c_white, values:
image_alpha/(iterations*0.3)); 32x32. If we have linear filtering
} blur = 5;
enabled, the computer will try to
for(i = 0;i<iterations;i+=1){ "soften" the resulting image to make
This one will draw the images following blurx = x+global.jitter1[i,0]*blur; the loss of quality produced when
this spiral pattern: (each point blury = y+global.jitter1[i,1]*blur;
scaling less apparent.
draw_sprite_ext(sprite_index,
represents the x,y coordinates at which image_index, blurx, blury,
a image will be drawn.) image_xscale, image_yscale,
That´s the key: this automatic filtering
image_angle, c_white, process is really quick. So we could

7|P a ge July, 2007 http://markup.gmking.org
GAME EFFECTS
Real-time Blur GAME EFFECTS
repeat this proccess several times (scale activated.
the image down, scale the image up
(this blurs the image), take the result, Now we need to make sure the memory
assigned to the surfaces will be freed
scale it down, scale it up...etc) to obtain when destroying the object (destroy
a decent looking blur effect. event):

Let´s begin with the code: surfaces are surface_free(s); Original Sprite Gaussian Blur
surface_free(saux);
ideal to implement this. We will draw
our sprite in a surface, scale it down,
Now the cool part. We need to repeat a
draw the scaled surface on a second
few times the scale down, scale up
surface, scale it up, then draw the
process in the step event:
second surface on the first one, and
repeat the process. //clear the main surface and draw
the sprite there: Jittering Repeated 1f
First of all we need to initialize a few Finally, draw the main surface to the
things in the creation event of the surface_set_target(s);
screen in the draw event:
draw_clear_alpha(c_black,0);
object we want to blur:
draw_sprite(sprite_index,
draw_surface_ext(s, x-
image_index, sprite_xoffset,
s = surface_create(sprite_width, sprite_xoffset, y-sprite_yoffset, 1,
sprite_yoffset);
sprite_height); //main surface 1, image_angle, c_white, 1);
saux =
/*scale down (to 0.5) and draw in
surface_create(sprite_width*2, Execute it. As you can see, the quality is
the auxiliar surface, then scale up
sprite_height*2); //auxiliar surface
the auxiliar surface (to 2, because good. It almost looks like real gaussian
0.5 * 2 = 1, the original image blur. An higher blur value means less
//clear the main surface:
size) and draw it in the main
surface_set_target(s);
surface again (thus blurring the
speed but the same quality. So this is
draw_clear_alpha(c_black,0); ideal for very intense high-quality blur
image due to linear filtering),
repeat.*/ effects (if speed isn´t that important).
//clear the auxiliar surface:
surface_set_target(saux);
repeat(blur_amount)
draw_clear_alpha(c_black,0);
surface_reset_target();
{
Conclusion
surface_set_target(saux); Both methods work perfectly with
//enable linear interpolation:
draw_surface_ext(s, 0, 0, 0.5, 0.5, rotated, color blended and animated
texture_set_interpolation(true);
0, c_white, 1);
sprites (although a little bit of “ghosting”
surface_set_target(s);
//the amount of blur we will apply: takes place when using the repeated
draw_surface_ext(saux, 0, 0, 2, 2,
blur_amount = 8;
0, c_white,1); linear filtering method with animated
} sprites).
Ok? So now we´ve got two surfaces
ready to use, and linear interpolation surface_reset_target();
José María Méndez

8|P a ge July, 2007 http://markup.gmking.org


TUTORIALS
Cartesian & Polar Coordinates TUTORIALS
There are two ways to describe a point
When describing a point with polar
in a plane. The first way is by using
coordinates, we don’t use the x and y-
Cartesian coordinates. The second way
axis. In polar coordinates, only one axis
to describe a point is by using polar
is used, this is the 0°-axis or the “polar
coordinates. The following image shows
axis”. 0 is the origin here. All distances
a point in the xy-plane, described both
are measured from this point. Rotation
with polar and Cartesian coordinates:
happens counter-clockwise. The point P
can now be described by the length r
(which is the distance from P to 0) and
the angle a between 0P and the 0°-axis.
This way, we have also fully described we have two formulas that can be used
point P. to convert Cartesian coordinates to
polar coordinates:

This article will explain how both Coordinate conversions y


a  arctan( )
coordinate systems are used, how to x
convert the coordinates from one r 2  x2  y2
system to the other and most important
for Game Maker: explain the Converting polar coordinates to
lengthdir functions. Cartesian coordinates is even easier. As
you can see:

Cartesian coordinates To convert Cartesian coordinates to x  r  cos(a)


polar coordinates and vice versa, we use y  r  sin(a)
an x- and y-axis. The distance |0P| is the
length r. The angle a is the angle And that’s all you need to know for
between the positive x-axis and line 0P. coordinate conversions.

The math behind lengthdir


The lengthdir functions are some very
As you can see, the point is described
handy functions if you need to know the
with the coordinates x and y, where x is
relative position between two points
the distance from P to the y-axis and y is
along a single axis (either the x-axis or y-
the distance from P to the x-axis. This
axis). Something that is different in
way, we have fully described this point We can use the right triangle to solve
Game Maker, is that the y-axis points
in the xy-plane. the problem. As you can see,
down: the y coordinate increases when
y
tan(a)  , so that means going down. This means that a negative
Polar coordinates x result means that the point lies higher in
y the room. The above image shows a
a  arctan( ) . This is a first formula
x room with 2 points in it.
that can be used to calculate a when y
and x are known. When we use The manual explains lengthdir_x and
Pythagoras’ theorem and apply it to the
above triangle: r 2  x 2  y 2 . Now

9|P a ge July, 2007 http://markup.gmking.org
TUTORIALS
Cartesian & Polar Coordinates TUTORIALS
lengthdir_y as follows: Let’s say the first object is called obj_1 Then we get:
and the second object is called obj_2.
lengthdir_x(len,dir) Returns lengthdir_x(length,direction) = r *
The distance between them is 100 pixels cos(degtorad(direction))
the horizontal x-component of the
and the direction 60°. The following lengthdir_y(length,direction) = r *
vector determined by the indicated sin(degtorad(direction))
code will return this relative x position:
length and direction.
lengthdir_y(len,dir) Returns a=lengthdir_x(100,60); Direction is in degrees. When we go
the vertical y-component of the back to the example, we can now
vector determined by the indicated The variable a now contains the x understand why the result is 50. The
length and direction. position of obj_2 relative to the x cosine of 60° is 0,5. Multiply this by r,
position of obj_1. This result will be 50. which is 100 in this case, and the result
A very appropriate question could be: “I Now why is this 50? To explain this, we is 50.
move length pixels in that direction, need to go back to our right triangle.
what are my x and y position now, Note that also in the room, we can think The two expressions derived above are
relative to the x and y position I left of a right triangle, this time with sides completely equivalent.
from?” Then lengthdir_x and length, lengthdir_x and lengthdir_y.
lengthdir_y would give you the And that’s all there is to tell about
Since it’s a right triangle, the previously
respective answers. These functions do Cartesian and polar coordinates. I hope
derived formulas are still valid. All we
not necessarily return a positive value this article has helped you understand
need to do is replace the variables:
e.g. when the value returned by these two coordinate systems.
lengthdir_x is negative, the second r = length
Bart Teunis
point lies left of the first. a = direction
x = lengthdir_x(length,direction)
An example: you need to know the y = lengthdir_y(length,direction)
relative x position between two objects.
EDITORIALS
Make your code easier to read
You may be perfectly happy coding in a where you left off without having to comments to explain what your code is
haphazard manner however you should decipher what you wrote just two doing, separate sections of code and
always ensure that your code can be easily weeks previously. remind yourself what needs to be coded
read. where.
If after release you come back to your
If you are working on a team project completed project and want to fix some Give your variables sensible names. At
having code which can be easily read is bugs that have been discovered, or the time you are coding using variables
vital. Otherwise when the game is being decide to make a spin-off or more up- called d, f & g may seem like a good
put together problems will inevitably to-date version of your game you also idea and make perfect sense, but take a
occur when one member of the team isn't need to be able to understand your look at your project a couple of weeks
sure what a certain section of a script previous work. Otherwise your existing later and you will be lost. Variables
does. If you work alone you may think code is a good as worthless. Here are such as playerhealth, topspeed and
that this does not apply to you, but writing some quick tips which, if followed, enemytype may be longer but they will
easy-to-read code will make your life should make your code easier to read. help reduce confusion, provided you
much easier. It may take you a bit longer can spell them correctly.
Use the tab key to indent your code. It's
to write than your normal jumble of code
sitting there on the edge of your Blank space is your friend. Don't try to
but it will be worth it in the long run and
keyboard so use it! cram your program into as few lines as
could save you hours of frustration. For
possible. Leaving a few blank lines is a
example with well-documented code you Add comments. In Game Maker starting good way to separate sections of your
will be able to find the section you are a line with '//' enables you to write a code.
working on quicker and if you take a break comment, visible only when you view
from coding 10 | Pwill
you a g be
e able to continue July,of2007 http://markup.gmking.org
the source code your project. Use Phil Gamble, GameMakerBlog.com■
TUTORIALS
Binary for Beginners
It is my philosophy that the underlying 1000, etc.). This means that the number
TUTORIALS
principles of our numeral system should 121101 can be broken down into Binary (Base Two)
be taught early on to budding computer (1  10 )  (2  10 )  (1  10 ) which
2 1 0
The binary numeral system (base 2)
programmers as well as to novice uses only two digits - 0 and 1 - to reflect
mathematicians. Unfortunately, these is equivalent to: (1  100)  (2  10)  1 all real numbers. Binary is the most
fundamental concepts are often (a 1 in the 100'ths place, a 2 in the widely used number system in the
completely ignored in high schools and 10'ths place and a 1 in the 1's place). computer sciences because it can be
introductory programming courses all Now do you see where the other represented easily in hardware by the
over the world and are often left positional numeral systems come in? states of on (electricity in a circuit) or off
completely unexplored until the college Other numeral systems simply use a (no, or less, electricity in a circuit).
level. In this article I will attempt to different base (and thus a different set Nearly every modern electronic device
illuminate some of the basic concepts of digits) to express the same set of real uses binary as its native numeral
behind positional notation focusing numbers. For instance, if we changed system. Each 1 or 0 is known as a bit in
specifically on the binary numeral the base to 3 (3 digits, 0, 1 and 2), then binary (instead of a digit as in decimal)
system (base 2) and its use in the 1213 would be equivalent to 16 base 10 and it is common to call a bit of 1 true
computer sciences. represented by: ( and 0 false.
(1  32 )  (2  31 )  (1  30 ) ). I suggest

Positional Notation that you make sure you have a firm


Logical Operations
Most readers will likely already know grasp on this section before continuing
It is ever the goal of computer sciences
that today's world primarily uses a base on with the rest of this article.
to create computers that can make ever
10 or "decimal" (also called denary [1]) more complex decisions. The decision
numeral system which uses a total of
Fractal Parts making process is accomplished on a PC
ten unique symbols (0-9) to convey by using logical operators on binary
Insofar we have only seen whole
every possible real number. The most numbers, however, logical operators
number representations of numbers.
likely reason for this is that humans should not be confused with binary
However, it would be pertinent to now
have a total of ten digits on both hands, operations (that is, operators taking two
mention the fractal part of a number. In
lending to easy decimal finger arguments such as addition and
any positional number system directly
calculations. Many readers, however, subtraction which are relevant for any
to the right of the one's place ( x  b )
0
may not realize that the decimal system base).
is not the only way of counting; in fact, there is another place defined as
it is merely one of an infinite number of ( x  b 1 ) and another, ( x b 2 ) and Humans are forced to make decisions
numeral systems that are called every day: we ask ourselves if we'd
so on and so forth. These negative
"Positional" numeral systems. rather go outside OR stay inside, would
places are often denoted by a separator
we like to eat pie AND ice cream OR just
To understand positional notation one between the whole and fractal parts of
pie? These simple decisions can be
must first known how our number the number, in base 10 this separator is
emulated by a computer using logical
system works. The positional number called the decimal point and is
operators such as "And, Or, Not, and
system allocates positions or places (eg. represented by a dot or comma (eg. 1.5
Xor."
1's place, 10's place, 100's place… etc.) or 1,5). More generally this separator is
that each number can fall into. Each called the "Radix point." Anything after The "and" operator simply returns true
position is related to the next by a the radix point is fractal, and anything if both the left hand and right hand
common ratio called the radix or base. before it is whole. This means that we arguments are true. For instance, 1 and
The decimal system is so named could represent 3.1410 as: 1 is true while 1 and 0 is false.
because it uses a base of ten, and thus (3  10 0 )  (1  10 1 )  (4  10 2 ) .
The "or" operator does exactly what it
the places are powers of ten (1, 10, 100,

11 | P a g e July, 2007 http://markup.gmking.org 


TUTORIALS
Binary for Beginners Cont. TUTORIALS
purposes though we will be using the
sounds like as well: it returns true if one
sizes defined above.
or the other argument is true (ex. 1 or 1
Cont Hexadecimal (Base Sixteen)
is true, 1 or 0 is true, and 0 or 0 is false). The problem with binary is that it is very While storing data as a single byte is
hard for humans to read quickly fine for text files, it has its limitations.
Xor you may not have heard of before
because even a small number can have Visualize a two digit number (base 10)…
as it is almost exclusively used in the
a very large number of bits (ex. 10010 is if we were to store all of our data as two
computer sciences. Xor (eXclusive OR)
equal to 11001002). Ergo it is often digit radix 10 numbers we would find
returns true if one or the other of two
convenient to express binary numbers ourselves with a very large problem:
arguments are true, but not if both are
in a slightly different (but equivalent) namely, that a two digit base 10 number
true. For instance, 1 xor 0 is 1, 0 xor 0 is
way called hexadecimal. Hexadecimal, can only store a number as high as 99.
0 and 1 xor 1 is 0.
or base 16, is very easy for both humans Bytes are limited in the same way: they
The "not" operator is a unary operation and computers to read as it has a can only store numbers as large as FF16
(that is, it takes one argument) which, relatively large radix which is also a or 255. Of course, we are not limited to
once again, does exactly what it sounds power of two making bin-hex two digits, therefore we can store
like it does. Not 1 is 0, not 0 is 1, simple conversions very quick on most numbers in shorts, longs, quads, and of
as that. computer processors. This means that nearly any other length (so long as it can
instead of having to write 10010 as fit into the memory). These numbers
As we can see combinations of these 11001002 we can simply write it as 6416 have higher and higher caps, just as a
operations can allow us to perform (notice how few digits that took). three digit base 10 number can store
simple logic, if statement1 is true AND Numbers written in hexadecimal are 999, a 64 bit long can store FFFF FFFF16.
statement2 is true OR statement3 is often prefixed with 0x (# in HTML, $ in For those of you who are familiar with
true then… You get the idea. GML). As you should now realize the the GM6 file format you will know that
hexadecimal numeral system will have it stores most of its data as 64 bit longs
16 digits. This means that not only does
Binary Operations for this very reason (a few values at the
it use the standard 0-9, but also the beginning of the file and some in
The simple binary operations we use
letters A-F where A = 10, B = 11 … F = resources are bytes).
every day (addition, subtraction,
15.
multiplication, etc.) can also be easily Before we can begin to create our own
defined for the binary numeral system files and store data there is one more
using simple logical operations. If a Storage thing we ought to know about numbers
human were to wish to add two binary Despite the copious amounts of in general. We normally write numbers
numbers he or she could simply add memory possessed by many modern from right to left with the largest values
them like decimal numbers, that is: computers numbers must still have on the left and the smallest on the right
some measure of consistency. In a (ex. 10010), however, to a computer it is
plaintext file for instance every letter is often just as valid to write numbers the
stored as 8 bits which is also called a other way around (ex. 00110) this is
"byte" and translates into a two digit called endianness or "byte order" and is
hexadecimal number. Two bytes (16 generally processor specific. The two
bits) make a "short" and 4 bytes (64 most common byte orders are little-
However computers cannot reason bits) make a "long." These values are endian (little-end-first) and big-endian
through this method. Instead, a fairly consistent on most processors, (big-end-first). You should now know
computer must use a series of logical however, be warned: The byte is enough to start reading and writing
operations processor dependant! Not all computers binary to and from files on your own!
use an 8 bit byte; in fact the size of
bytes ranges from 5 to 12 bits! For our

12 | P a g e July, 2007 http://markup.gmking.org
TUTORIALS
Binary for Beginners Cont. TUTORIALS
/*
Conclusion
Cont. ** Usage:
Knowing how to use binary effectivly ** file_bin_read_word(file,size,bigend)
will aid you tremendously in your game **
** Arguments:
and software development. While we
** file file id of an open binary file
have only touched the tip of the iceberg ** size size of the word in bytes
this article will (hopefully) have given ** bigend set to TRUE to use big-endian byte order (MSB first),
you enough knowledge to get you ** or FALSE to use little-endian byte order (LSB first)
**
started in the wild world of binary and
** Returns:
computer logic! There are many topics I ** an integer word of the given size from the given file
did not cover here and wish I could have **
(bit masking, radix translations, shifting ** GMLscripts.com
*/
and rotating, etc.) but I'm sure that, {
equipped with this knowledge they will var file,size,bigend,value,i,b;
only be minor obstacles. Following are a file = argument0;
size = argument1;
few functions in GML to help you get
bigend = argument2;
started writing in binary. value = 0;
for (i=0; i<size; i+=1) {
Leif Greenman b[i] = file_bin_read_byte(file);
}
if (bigend) for (i=0; i<size; i+=1) value = value << 8 | b[i];
else for (i=size-1; i>=0; i-=1) value = value << 8 | b[i];
return value;
}
/*
** Usage:
** file_bin_write_word(file,size,bigend,value)
**
** Arguments:
** file file id of an open binary file
** size size of the word in bytes
** bigend set to TRUE to use big-endian byte order (MSB first),
** or FALSE to use little-endian byte order (LSB first)
** value integer value to write to the file
**
** Returns:
** nothing
**
** GMLscripts.com
*/
{
var file,size,bigend,value,i,b;
file = argument0;
size = argument1;
bigend = argument2;
value = argument3;
for (i=0; i<size; i+=1) {
b[i] = value & 255;
value = value >> 8;
}
if (bigend) for (i=size-1; i>=0; i-=1) file_bin_write_byte(file,b[i]);
else for (i=0; i<size; i+=1) file_bin_write_byte(file,b[i]);
}

13 | P a g e July, 2007 http://markup.gmking.org


TUTORIALS
Coding Styles TUTORIALS
Have you ever wondered if you were Here is rule #1: Always indent your finish it. It is also possible to accomplish
coding ‘right’? Have you wondered code! It makes your code blocks more your coding mission with different code.
whether you should use ‘and’ or ‘&&’? readable, both to you or to any team For example, you could type
There is no incorrect way to program as members. You may use your ‘Tab’ key draw_circle(random(room_width),rand
long as the code works the way it from your keyboard, or press Ctrl + I to om(room_height),4,true) 50 times, or
should. These are some styles you can indent and Ctrl + Shift + I to un-indent. you could put it in a ‘repeat’ statement
use. You can choose to use ‘and’ or Another important thing to remember is for 50. There are many other coding
‘&&’, ‘or’ or ‘||’, ‘not’ or ‘!’, and to leave comments in code so you and styles, but if I wrote them all down, it
whether to use brackets or not. None of other people can decipher them later. If would fill a whole MarkUp magazine!
these make any difference whatsoever. you don’t already know how to insert
You may also choose whether to use in comments, use ‘//’ to comment the rest Stephan
statements like ‘if’, ‘while’, or ‘for’ to of the line, or use ‘/*’ to begin a long
use parenthesis around the arguments. comment, and add ‘*/’ at the end to
REVI EWS
Textbar Maker
When the first version of metal-games’ brought with it minor updates and moving it elsewhere on the textbar. The
Textbar Maker came out, I was pretty improvements. same applies to text – it is fixed in the
critical of it. It seemed too simple and position it starts in to the right of the
didn’t really do anything complex. Since Despite the apparent lack of rapid textbar.
that early version, however, things have progress, the early changes still remain
changed. Toenail initially helped metal- very useful and some of the more All in all, I would say that this was quite
games, causing the next version to have a recent developments have vastly a useful application. It’s quick an easy to
completely new interface, which looked improved the program. The “extra” use and lets you create a fairly stylish
wonderful, and many more features, options allow the user to create a more textbar in a matter of seconds.
some of them quite complex. Sadly the dynamic image with extra depth. The However, if you’re looking for a bar
changes since then haven’t been so choice of fonts too makes individual which really looks good with plenty of
dramatic, and each new version has only textbars more unique. Although the end features, you’d probably be much
results from the program are not quite better suited with a more complex
of the quality one might want, they still program.
The fairly are good enough to display in signatures
“complex” or elsewhere.
color
palette. There are, as ever, problems with this Some Information
Creator: metal-games
program though. If you load an image, it Get: http://xrl.us/textbar
is automatically stretched to a square
shape. There is no way of resizing it, nor “Grego” Tyler

14 | P a g e July, 2007 http://markup.gmking.org


GAME MATH
Modulo in Computer Science GAME MATH
Modulo is an important operation in practiced in elementary school, 5 mod 2
Now, consider the set of imaginary
both the computer sciences and in is 1 because two goes into five two
numbers: because the imaginary
general mathematics. It allows for the times with one left over, that remainder
number i can be thought of as the
use of complex logic in equations as well is the result of modulo. Because of this,
as loops and provides the ability to modulo has several interesting square root of negative one, f ( x)  i x
merge several equations into one properties: has a very interesting solution set as
formula. This paper deals with and illustrated in table 1:
1. x mod y where y > x = x
outlines the use of the modulo operand
2. x mod x = 0 Table 1
in the computer sciences and provides
3. x mod 1 where x∈ ℤ = 0
several detailed examples of its use. 4. x mod y = (x + (n * y)) mod y ix f (x)
where n∈ ℤ i0 1
Modulo is a simple operand which can
Property 4 leads modulo to often be i1 i
be defined quite simply as the fractal
associated with patterns that repeat i2 1
part of any ratio multiplied by the
themselves, lending it the name "clock i3 i
denominator of said ratio. It is taught
arithmetic" after its use in the 12-hour
first in elementary school, though not i4 1
clock system. For instance, 1 mod 12 i
by its proper name, and all but i5
will equal 1, 12 mod 12 will be 0 and 13 1
forgotten in middle and high school. Its i6
mod 12 will also equal 1 and so on and i
properties are never explained to the i7
so forth; because of this behavior,
average student, its methods and As we can see, the values of f (x)
modulo can be thought of as a simple,
means never comprehended. This paper repeat themselves for every four values
logical, loop. Following from the
aims to detail some of the uses of of x. This means that we can simplify the
previous example, let us say that we
modulo and offer a general expression i 294 down to i 2 using the
wished to write a function to convert
understanding and comprehension from equation i x  i x mod 4 . Though this
from 24-hour time to 12-hour time. We
which the hobbyist programmer and example may not be extremely practical
might initially write down:
amateur mathematician can glean a
f ( x)  x mod 12 , however, this from a programmer's perspective it is an
fuller understanding of the mathematics ideal example of exactly what can be
function as we can see will return 0 for
and prose of a simple remainder. done with modulo.
the inputs of 12 and 24. To remedy this,
What exactly is modulo? Modulo is the we may simply subtract and add 1 as
Now let us look at a more practical
remainder of a division, just like you follows: f ( x)  (( x  1) mod 12)  1 .

15 | P a g e July, 2007 http://markup.gmking.org


GAME MATH
Modulo in Computer Science GAME MATH
example. Let us say we are number which we want to know modulo
complex logic that makes most software
programming a small graphics editor two since all even numbers are evenly
possible. We as humans look for
and one of the features of this editor is divisible by two. And, because all
repetition and patterns in everything we
a button which shifts all pixels to the integers are evenly divisible by one, we
do; we have set routines and schedules
right one pixel. We might simply add can check to see if a number has a
which repeat themselves regularly in
one to the x value of each pixel, but this fractal part by simply calculating the
accordance with a given timeframe and
will cause all pixels on the far right of number in question mod 1 (if it returns
even the basic elements of our universe
the canvas to no longer be visible. 0 then the number is an integer).
follow a simple periodic order. Modulo
Modulo to the rescue! Instead, we can Modulo can be used in this manor to
can be used to abstract many physical
use the simple equation: find a whole host of useful values
phenomenon and ergo is a cunning and
x  ( x  1) mod width where width is including whether or not two numbers
indispensable device to have in your
the width of the drawing canvas in are powers of each other
programming repertoire.
pixels. See how simple that is? The same log b x mod 1  0 (just make sure to
might apply for looping a rocket to the add a few error traps) and whether or
other side of the screen in an asteroids not a number is evenly divisible by References
style game, or when translating the another number (as seen in the  Leijen, Daan (December 3,
contents of a data structure such as a previous examples). 2001). Division and Modulus for
grid (see Listing 1) or list. Computer Scientists (PDF).
As you can see, modulo is an
Retrieved on 2007-07-03.
Transformations are only one of the indispensable tool to the mathematician
 Multiple Authors. Modulo
many uses of the modulo operator and programmer alike. Modulo
operation. Retrieved on 2007-
however. In an even more useful twist, pervades our culture and society, it is
07-03.
modulo gives us an easy way to see if a found in our system of time, in our
number is even or odd (returning a measurement of angles, in the Leif Greenman
Boolean value) by simply calculating the mathematics of our music, and in the

Listing 1: Translation of a grid using the Cartesian coordinate system


{
// ds_grid_translate(dsid,horiz,vert)
// This script is in the public domain and may be found at GMLScripts.com
var dsid,w,h,sx,sy,mx,my,dx,dy,temp;
dsid = argument0;
w = ds_grid_width(dsid);
h = ds_grid_height(dsid);
sx = (((argument1 mod w)+w) mod w); // Notice the use of modulo
sy = (((argument2 mod h)+h) mod h);
mx = w-1;
my = h-1;
dx = mx-sx;
dy = my-sy;
temp = ds_grid_create(w,h);
ds_grid_set_grid_region(temp,dsid,0,0,dx,dy,sx,sy); }
if (sx>0) { ds_grid_set_grid_region(temp,dsid,dx+1,0,mx,dy,0,sy);
if (sy>0) { ds_grid_set_grid_region(temp,dsid,0,dy+1,dx,my,sx,0); }
if ((sx>0) && (sy>0)) { ds_grid_set_grid_region(temp,dsid,dx+1,dy+1,mx,my,0,0); }
ds_grid_copy(dsid,temp);
ds_grid_destroy(temp);
}

16 | P a g e July, 2007 http://markup.gmking.org


MOVEMENT
Smooth Online Movement MOVEMENT

especially useful for lowering the


amount of bandwidth used, and offering
a much more professional and lag free
experience.

Constants
The main idea behind this example is to
communicate between players with
simple variables which then translate
into movement. We start this off by
setting up constants as a form of packet
title. The packet title is simply used to
give each packet it’s own ID. By doing
Introduction
this, both client and server understand
The other day I was browsing the Game
Maker Community, testing some of the
what data you are trying to send, and Transforming Data into
can read it accordingly.
online games and engines made with Movement
Game Maker. A quick look at most of Now that we are successfully sending
the games and engines being coded Sending Data packets to the server and clients that
helped me come to the conclusion that Now that our constants/packet titles are 
the community as a whole is still very set up, we can begin the process of
new to the world of online sending data to the server depending on
Dragger DLL
programming. This is made evident in what buttons have been pressed. For The dragger DLL allows

QUICK REVIEW
part by the lack luster games being example, if the player presses the left windows to be dropped inside a
programmed that make little to no use keyboard button, we send a packet to Game Maker window. A single
of a widely used technique called Dead the server which basically tells it what file or multiple files could be
Reckoning. This technique is used to button we’re pressing. Afterwards, it simultaneously dragged into a
save on bandwidth and lag in an updates our x and y position to re-sync Game Maker window. The DLL
attempt to guess what certain info is the player. Now that the server is up-to- can figure out the number of
depending on data already received. date on what the player is doing, it then files being dropped into the
The example I am about to talk to you forwards the received packet onto all window by using an index (0-
about is a form of Dead Reckoning. It clients connected to the server. These based). The DLL download
calculates the movement and fluidity of clients then do the same thing as the comes with an example in a
a player depending on certain data that server by reading the data sent. GM6 format.
has already been received. This is
Get it now!
http://xrl.us/draggerdll
17 | P a g e July, 2007 http://markup.gmking.org
MOVEMENT
Smooth Online Movement MOVEMENT
contain the info to what button the
player is pressing, we can begin the Physics checking, gravity, etc. This is a fairly
Unlike in online games where player easy part; just remember to make these
process of transforming these variables
movement is done by constantly physics exactly the same as the ones
into simple movement of the player. An
updating the x and y position of the affecting your own player. If not, it can
example of this in step-by-step order:
player, we must now program in some create quite a bit of lag.
1. Player presses left keyboard simple physics for the dummy player so
button that he acts in a manner that mimics
2. Packet is sent containing info The End
that of the actual players key presses.
for left keyboard button Hopefully by reading this little summary,
We do this by giving him some collision
3. Packet is received and read in you now have a decent insight on what
the form of simple variables it takes to program a more professional
4. The game checks those online game. If you have any questions
variables and translates them regarding the technique or the example,
into movement please e-mail me at
jakethesnake3636@hotmail.com. For a
As you can see, it is a pretty simple look at a full-fledged MMO using this
process. One in which only a little technique, please visit
common sense is required to create a nightfallonline.co.nr or stick-online.com.
highly used form of Dead reckoning.
Jake
EDITORIALS
Promoting your Game to the GMC
To start off with I will clarify that in this you should also try the same there. For to get your game reviewed or previewed
article the “Game Maker Community” example many Game Maker ‘teams’ have by one or, even better, both of the Game
refers to people who use, or are familiar their own forums, you can easily copy and Maker magazines. Provided you have put
paste the same post onto a number of a sensible amount of time into your game
with, Game Maker and not the name of
these, although I don’t condone spamming your review should in effect be free
the official forums. It is of course possible of any kind. advertising and you will also get some
to promote your game outside of the constructive criticism on top of that.
community, and this is something which Uploading at community based sites such These magazines also give free
more and more people are beginning to as 64digits won’t be a bad thing either, nor advertising in exchange for articles so if
do, however this article is only about will posting your game at YoYo Games, you get writing about something Game
promoting ‘internally’. where there is big audience. Maker related, not just shameless
promotion, and submit it to one of them
Affiliating (link exchange) with other sites you will probably be given a quarter page
Forum signatures are a great place to
is a good idea but you only get a small ad or something similar. From my
advertise since it is essentially free space,
canvas on which to show your message by experience ads in MarkUp do get clicked
and if you are an active poster it will
using this method. If your banner will and do get results.
quickly spread your message across many
appear at the bottom of a page alongside
different topics.
hundreds of others this will also be pretty As well as choosing the right place to
useless (says the man who runs a Game advertise your message also has to be
You can obviously start a topic promoting
Maker affiliation service). Textual links effective, you will only have a limited
your game in the Game Maker creations
may be more beneficial, particularly when amount of space so you need to make the
section of the official forums, and you
it comes to Search Engine Optimization, most of it and make sure you have got
could also post your website in the
however this shouldn’t be your primary everything right. Sloppy spelling and a
Website Announcements section to
concern when promoting to the misspelt URL won’t do you any favors.
coincide with your release. There isn’t just
community.
the one forum though, if you are a
Phil Gamble,
member of any other forums which focus
on Game Maker or game development
I believe it would be more valuable to try GameMakerBlog.com■

18 | P a g e July, 2007 http://markup.gmking.org


TUTORIALS
Introduction to DLL-making TUTORIALS
Along time ago in a land far, far away, language which means that DLL's can code. One of the many advantages of
there was a programmer. This add functionality that was previously using DLL's is that C++ has many more
programmer had a project that had impossible to Game Maker. Though data types than GML and can define
many, many functions which needed to DLL's can be written in a variety of custom data types which are just as
be shared between several source files. different programming languages, in valid (to C++) as the standard types.
He toiled away, copying and pasting this article we will be focusing on Unfortunately, GM only supports two of
every time he made a slight change to creating DLL's in C++. The concepts the data types which C++ is capable of:
the functions in one of his programs. covered in this article however should Null terminating strings, and real
Finally he decided enough was enough apply to most any language in which DLL numbers (doubles). Now, when I say
and a brilliant idea came to him: thus creation is supported. What follows in GM only supports these data types I
the DLL was born! Before we start, I Table 1 is a detailed comparison of GML mean just that. Your DLL can define its
must warn you, DLL's are not for the code as opposed to compiled C++ code. own data types or use as many others
faint of heart, to understand this This highlights some of the advantages as it wishes, however, GM can only
tutorial you must be familiar not only and disadvantages of using DLL's as supply the DLL with doubles and strings,
with GML, but you must have some opposed to standard GML scripting. If and the DLL can only return doubles and
general C++ knowledge as well. If this you want to skip these small technical strings to GM. Let’s take a look at each
has not deterred you, read on! details and jump strait to programming of these types and see exactly what kind
your own DLL you may want to skip of data you can store with them.
down to "Programming DLLs" on the
What is a DLL next page. There are of course some
Doubles, or real numbers, are signed 64
The Dynamic Link Library, or DLL, is a discrepancies in the table: dynamic bit double precision floating-point
collection of pre-compiled code that can typing is not necessarily a pro for GM, numbers that can store values in the
be linked with and executed but for our purposes it will be, also ease range of 1.2 x10 4932 (19 digits) and
dynamically at runtime (as opposed to a of use and learning curve are the have a precision of about 8 bytes (on
static library which can only be linked to opinion of the author. most computers). They are initialized in
at compile time). DLL's are one of the C++ using the keyword "double".
programmer's most useful tools; they
allow for easy management of shared Data Types Null terminating strings on the other
code between many applications and Now down to business. As you can see, hand are lists of characters that only
allow you to update code in one spot DLL's offer several advantages over C++ end when the escape sequence "\0"
and one spot only without having to (null) is reached. I prefer to use the
recompile your entire project (See LPSTR class found in the standard
Figure 1). windows includes (windows.h).

The Basics Programming DLLs


Game Maker supports limited linking Open up your favorite editor, prepare
with DLL's compiled in another language your favorite compiler or GUI, and let’s
such as C++ or Delphi. DLL's have get started writing a DLL for Game
several advantages over GML code: first Maker! Create a new project or file and
of all they are compiled; this lends them set up your compiler to compile a DLL
to much faster execution speeds than (this is compiler specific, so you'll need
scripted GML code. Secondly, you can Multiple programs can link to a DLL to read the documentation if you don't
do a lot more in a real programming at the same time know how to do this). Now let's create a
simple function to add two numbers in
Fig 1

19 | P a g e July, 2007 http://markup.gmking.org 


TUTORIALS
Introduction to DLL-making TUTORIALS
functions to a block of memory called
Table 1 GML C++
the "stack." The stack is a low-level data
Dynamic Typing Yes No
Compiled No Yes structure that functions exactly as you
Flexibility Worse Better would expect a stack to, when you call a
Speed Slower Faster function its arguments are put (or
Dynamic Resource Access Yes Not Allowed1 "pushed") on the top of the stack in
Memory Pointers No1 Yes reverse order. When the function
Ease of Use Easier Harder returns, the arguments are "popped"
Custom Data Types No Yes
from the top of the stack on a first-in-
Learning Curve Smaller Steeper
first-out basis. This means that
whatever the last thing you placed on
C++. We will call this function dAddNum the stack was will be the first thing to
standard C++ includes. I like the LPSTR
and it might look something like this come back off of the stack.
class which can be used by simply
(remember that we can only use
including windows.h with your DLL. Cdecl is the default calling convention
doubles and strings for arguments and
That's about it for defining functions for C programs and global functions in
return types):
from within DLL's! Of course, you can do C++ programs. When the calling
double dAddNum(double dNum1, double dNum2) much more advanced things with your convention is set to cdecl the caller
{ functions than just perform basic
return (dNum1 + dNum2); (Your game) is responsible for popping
}
calculations (which are more suited to data from the top of the stack. This is all
GML). done automatically and you probably
There is still one problem though, if we don't need to worry about it.
GM supplies a certain function that
compile a DLL and try to execute this
allows your DLL's to deal with the game Stdcall on the other hand requires that
function from Game Maker it will not
window directly. This function is called the callee pop arguments from the
work. This is because we have not told
window_handle() and (counter stack. This is the default convention for
the DLL to export the function to Game
intuitively) returns the handle of the the Win32 API. Because the callee is
Maker. To do this we must add the
game window. This handle may be used responsible for removing its arguments
following to the beginning of our
in your DLL's to modify the windows the stdcall method is slightly faster,
function right before the declaration:
position, attributes, contents, styling, however, it prevents the use of the …
extern "C" __declspec( dllexport ) etc. However, this is not a C++ tutorial, operator for sending runtime defined
and we will not be covering the means arguments.
Rather than add this before every and methods of window manipulation
function, however, I prefer to define a here; for an example see the code If you're uncomfortable choosing a
single keyword that will act as a stand in example at the end of the article. The calling type, better make it cdecl.
for this line of code. This makes our final final topic we must cover before we can
addition function look something like really be expert DLL creators is that of
the one found in Listing 2. calling conventions. Game Maker Using the DLL
supports two calling conventions: cdecl Now finally comes the fun part:
Strings on the other hand are a little implementation, actually using our
and stdcall. To understand the
more complicated to pass and return. newly created DLL in Game Maker!
difference between these two methods
C++ does not define a built in class for Before GM7 we had to use a series of
and what they do, we must first know a
storing strings, instead we have to use functions to initialize the DLL, define the
little bit about how C++ calls its
either an array of bytes (char) or one of functions, and call the functions. GM7,
functions. C++ passes all arguments to
the many string classes found in the however, does away with all that and


20 | P a g e July, 2007 http://markup.gmking.org
TUTORIALS
Introduction to DLL-making TUTORIALS
gives us a single mechanism for the file which can be imported into Game DLL's, good luck!
inclusion of a variety of file types: The Maker. To execute your DLL's functions
GEX file. all you have to do is call the name of the
function or the alternate name you Resources
The GEX file will act as a container for defined in the extension builder from  Microsoft Visual C++ Express
our DLL file that will export it to a
within Game Maker!  Visual C++ Developers Center
temporary directory at the start of the  Dev-C++
game, call any initialization scripts that  MinGW
need to be called, define every function Conclusion  DLL Programming Resources on
within the DLL, and finally, when the GMC
You should now know enough about
 C++ for Dummies
everything is all done, call any tear DLL creation to get out there and start  Game Programming Gems
down functions and release the DLL creating some basic DLL's! Remember
from memory. Unfortunately, you though, DLL creation is a very advanced Footnotes
1
cannot create extensions from within form of programming which can be hard It is unfair to say that the inability of
Game Maker itself. To create your to debug. Before you start trying to C++ to access GM's resources is a con.
extension you will need the free utility make your own GMSoc or Xtreme3D, After all, this is the fault of Game
found here. From within the extension make sure you know enough about Maker, not C++
maker you can simply click "Add DLL" to calling conventions, memory allocation, 2
GM does not define pointers but they
import your DLL and then define your and data types to prevent memory leaks
can be emulated for resources.
functions by adding them to the and buffer overflows which can lead to
functions list (see Figure 2). Now, on the security vulnerabilities in your games. Leif Greenman
file menu, click "Build Package…" to Below is a list of resources which you
compile your project into a single GEX

may find useful when developing your

#define export extern "C" __declspec( dllexport ) /* __stdcall if we will cleanup */


#include <windows.h>
#define MAIN_EDIT 101 // Just an edit ID
export double dAddNum(double dNum1, double dNum2)
{
return (dNum1 + dNum2);
}

export double dTextBox( double dX, double dY, double dWidth, double dHeight, double dWinHandle)
{
HWND hwnd = (HWND)(int)dWinHandle;
CreateWindowEx( WS_EX_CLIENTEDGE,
"EDIT",
"Hello World",
WS_CHILD |WS_VISIBLE |WS_VSCROLL |WS_HSCROLL |ES_AUTOHSCROLL |ES_MULTILINE,
(int)dX,
(int)dY,
(int)dWidth,
(int)dHeight,
hwnd,
( HMENU ) MAIN_EDIT,
GetModuleHandle( NULL ),
NULL );
return (0);
}

21 | P a g e July, 2007 http://markup.gmking.org


TUTORIALS
Level Editors pt. 1: Format TUTORIALS
of objects, setting variables for these that whenever it is created in the level
A level editor in a game is considered a objectives, etc. editor, it adds some GML code to a
massive feature by many, and indeed it global variable about its creation,
is. The reason developers add level As it will be discovered later, the method position, etc. While this could prove
editors to their games are different: isn’t so flexible, might need a lot of hard- more flexible at some times than using
while some times it is done just as an coding (which means it would make it the with statement, it also creates a
extra, in other times there could be a difficult to update), and is simply problem: destroying the object.
compelling reason. completely insecure – someone could However, using string replacement
make a level that deletes your system functions, or by simply adding a
Take for example my most recent files! Nevertheless, we will briefly discuss
with(…){instance_destroy();} line of
project, which involves a crime scene the different ways to create such a
investigator trying to solve cases – code could solve that problem.
method.
different cases are represented as
METHOD 2: A relatively more
different levels and in order for my By using the WITH statement
game to be successful; those cases need A great function to do this would be a
to be really interesting: and that’s with(all) statement. In that statement,
where I fail! That’s why I decided to something such as:
create a level editor so that others could
code+="instance_create("+string(x)+",
make interesting levels for the game, "+string(y)+",
and later packed as true levels. "+string(object_name(object_index))+"
);";

Methods of Creating Level To set more variables to the created


Editors object, obj= could be added before the
code, to create something similar to this:
METHOD 1: The famous
code+="obj=instance_create("+string(x
execute_file() )+", "+string(y)+",
The most insecure of all methods on "+string(object_name(object_index))+"
);";
earth is execute_file! What happens is
that the code of creation of each object
is directly added as GML code to a file –
Now, to define variables such as my_life secure alternative to
for that objects, a simple line of code
this includes creating different instances execute_file
could be used:
Instead of executing a file, how about
obj.my_life=79; executing a string? Sounds stupid, but a
file with the same type of GML code as
The with statement could also include a shown above could be encrypted, read
switch() statement, where the by the actual game, stored in a string,
object_index of each object is tested – decrypted, and executed.
and accordingly, different types of
variables could be added to the object. That could make it safer, but decryption
has been proven to be a weak form of
Embedding code directly into protection – especially when malicious
objects coding could still be injected in the file
Another alternative could be to directly after the encryption has been cracked.
add code to an object’s create event – so


22 | P a g e July, 2007 http://markup.gmking.org
TUTORIALS
Level Editors pt. 1: Format TUTORIALS
that need to be defined, it is a Though the use of commas, colons, or
good idea to include the object’s semi-colons is generally considered
name as the first part of each row, okay, many variables might store text –
to define which object is being and text generally contains all these. For
created. that reason, I suggest to use an
uncommon character as the separators,
For example, a certain object I use (`), (^), (|), etc.
might only need two variables
defined, while others might need To make things “nicer”, I often use two
several ones – that could separators: one to separate the object
introduce array index out of name from the rest of the variables, and
bounds or other types of errors so the other to separate the different
variables from each others.
it’d be better if object names are
Here’s an example of what a file could
defined at first.
METHOD 3: A special file look like:
format Character Separated Values EVIDENCE`96^336^blood_2.png^Evidence
There is no doubt making a special file vs. Fixed Length Record ^Sample evidence text.^/*none*/
format is the most secure and efficient
On one hand, reading and separating
method of storing level data. The idea is EVIDENCE`96^144^blood_2.png^Evidence
Character Separated Values is not a ^Sample evidence text. ^/*none*/
that values are stored in specific
native function in GM, and coding such
locations, and are separated by TILE`128^144^0^0
thing in GML could be difficult – and at
different separator characters (example:
the same time, Fixed Length handling is TILE`160^144^0^0
CSV). This way, the game could read a
easy in Game Maker, as functions like
value, either keep it as a string or turn it TILE`192^144^0^0
string_char_at() and string_copy()
to a real value using the real() function
could easily create parts of a string that
– and setting a variable to that value.
lies within a certain position.
Reading the Format
This is the method I personally use for
However, using fixed length records Using two separators means that
my project, and this is the method we
mean that there should be a maximum readings could occur on multiple stages.
will further discuss in this article.
length for all records, and it also means In the first stage, the strings are
that the file size would be much larger 
The format than variable-length records.
AStar DLL
QUICK REVIEW
We could take advantage of Game Character Separated Values succeed in The AStar DLL is one of several
Maker’s ability to read only one time at every way when compared to Fixed path finding DLLs based on the
a row. Different pieces of data such as Length Records except for the fact that effective A* algorithm. It allows
different objects to be added to the they cannot be natively and directly for fast real-time path finding,
room will be stored in separate lines – used in GM. However, GMLscripts.com so that the object could move
this means each has come to the rescue – as shown in around blocks and other
file_text_read_string() carried out Issue 4, script of the month – and gave restricted areas (obstacles) to
would read a single line, and therefore a us the explode_string function. reach its target position.
single object. Which separates a string into multiple
It is very effective, and allows
strings in an array.
Since most games have different types for awesome AI!
of objects, each with different variables Separators
Get it now!
23 | P a g e July, 2007 http://xrl.us/astar
http://markup.gmking.org
TUTORIALS
Level Editors pt. 1: Format TUTORIALS
Table 1: First stage
SPR[0] SPR[1]
EVIDENCE 96^336^blood_2.png^Evidence^Sample evidence text.^/*none*/
EVIDENCE 96^144^blood_1.png^Evidence^Sample evidence text.^/*none*/
TILE 128^144^0^0
TILE 160^144^0^0
TILE 192^144^0^0

Table 2: Second stage

PART[0] PART[1] PART[2] PART[3] PART[4] PART[5]


96 336 blood_2.png Evidence Sample evidence text. /*none*/
96 144 blood_1.png Evidence Sample evidence text. /*none*/
128 144 0 0
160 144 0 0
192 144 0 0

separated into 2x1 arrays. performed, this time to separate


different variables from each other Conclusion
The first explode_string() function will (table 2). In this issue, you learnt about the
separate the object name from its different ways of storing information
variables (table 1, overleaf). about levels. Next issue, we’ll talk about
Writing the format the different methods of creating a level
Now a tile only needs to have 4
The act of writing the format by the editor’s interface.
variables read, while the evidence
level editor isn’t hard anymore. with()
object needs six. So, a switch statement This covers the separation of the items
statements could be carried out, but
is done, if the variable SPR[0] is of the level from the actual interface,
instead of using all we use a specific
"EVIDENCE" all 6 indices of the array are ways of making a good interface, etc.
type of object each time. So, we’ll have
read, but if SPR[0] was "TILE", the final
a with(obj_tile) and a
two indices are not read – as reading Eyas Sharaiha
with(obj_evidence), each of them adds
them causes an error.
the name of the object, along with
A second explode_string() function is character separated variable values.

N E W S
Cage Match no more.. again?
Though not directly related to of a weekly Cagematch – until recently.
Following these events, the Game
development – the Game Maker The Cagematch was suspended after Maker Community moderation staff
Community’s Cagematch (once seen as a about 100 mysterious votes came from decided to suspend the Cagematch until
method of showcasing one’s work) – has nowhere to one of the games. However, further notice.
now been suspended until further notice. the creator of the game insists he has
It is not known whether the Cagematch
nothing to do with it.
The Cagematch used to be run by Dex in will reopen in the near future, and it is
the old days, until he became too busy to It now appears that a hidden iframe or a also not known whether it has only
handle it, and eventually the Cagematch similar trick in a certain site was placed, been suspended for inspections or not.
ceased to exist. which forced users to automatically Eyas Sharaiha
Not-so-long-ago, Ablach Blackrat took vote for that certain game.
over, and revived the long-liked tradition

24 | P a g e July, 2007 http://markup.gmking.org


ENGINE
GM Physics ENGINE
To start, let’s say that you’ve made a
game. Someone plays it, and complains
about the incorrectness of the physics in
a certain part of the game. As a
developer, how can you ensure that all
the physics in your games is accurate,
which also aids you in making some
pretty cool games too? The answer can
come to you in a single package,
GMPhysics.

Introduction
So, when you open it up, you see a
bunch of DLLs and a couple of example
games. Look through them, and when
you’re done playing, open up the
platform tutorial included.

Before we start making physics, we’re


going to have to learn about how it
works. Clear the room of everything but
the control object (it should be
displayed as a blue question mark.)
Then, open up the control object in the
medium-sized rock.) But think of it this In every step, you’ll want to update the
object editor. Double click on the code
way. If the body is just sitting on the simulation. So, open up the code in the
in the Create event. Something like this
bottom of the screen, it will fall off. But, step event and you should see the
should pop up:
if you put STATIC in its density, it following:
{ becomes ground. Now, nothing will

init_physics();
create_body(0,room_height,STATIC,SHA affect it, but other things will be
PE_PLANE,90); affected by it. The next argument is
} SHAPE_PLANE, which indicates that the
Easy Inventory

QUICK REVIEW
shape is a plane, and the last argument
So, let me explain this. init_physics(); “Easy Inventory” is a set of
is the argument specific to that shape,
simply initializes physics to run. The Game Maker scripts designed
which is direction. Unlike Game Maker,
next piece of code is a bit more to allow you – the developer –
the directions are as follows: 0° is up,
complicated. We’ll take it step by step. to add inventories to your
90° is right, 180° is down, and 270° is
The function, create_body(), is pretty game. This is particularly useful
left. Because the plane is on the left side
self-explanatory. The first two in RPG games like Diablo, etc.
of the screen, we want it to stretch until
arguments are x and y. So, this creates a it reaches the other side, the right. It allow for the drawing and
body at the bottom-left corner of the Different shapes have different manipulation of the inventory
room. The next argument is the density. arguments, too. For example, a ball’s and the items in it using simple
This can be any positive number (for a only argument is its radius, and a lines of code.
good scale, use 1 as a small chapter rectangle’s two arguments are its width
book, 3 as a dictionary and 5 as a and height. Get it now!
http://xrl.us/inventory
25 | P a g e July, 2007 http://markup.gmking.org
ENGINE
GMPhysics ENGINE
{ Put a Create event in it, then put the
update_bodies(); {
following piece of code in its create
}
event: destroy_body(h);

This updates it every step, and this is { }


very important.
h = create_body(x, y, 1, SHAPE_BOX,
Now, go back to the controller object.
The last thing you’ll need to look at is 32, 32);
Create a mouse Global Left Pressed
the Game End event. In it should be
} event, and in it put the following piece
something like the following:
of code:
{
From what you’ve learned before, this
shouldn’t be too hard. It creates a box- {
release_physics();
instance_create(mouse_x, mouse_y,
} shaped object with a width and height obj_box);
of 32 (hence the sprite.) It creates it at }
That simply gets rid of the physics. You its x and y, and gives it a lightweight
don’t want it to be calculating nothing density of 1 (you can change this, but That makes an instance of object box at
after you quit, do you? don’t make it past 10. It’ll be too heavy.) the mouse x and y, you should be
We assign it to a variable so we can familiar with this if you have coded
Well, that’s it. You now know how to
easily access its physical body later. before.
make a static body and maintain your
physics correctly. Now here comes the Before it does anything, you also need Now, run the game and click anywhere.
fun part: making all those bouncing balls to make it update itself. So in the Step If you haven’t made any mistakes, it’s
and falling blocks. event, put in this: quite fun, isn’t it?

{
Making Bodies Making Joints
object_update(h);
So, create a new object called obj_box Joints are pretty easy to make, and can
and give it a simple 32x32 box sprite. } provide you with pretty amazing results.
Make sure that the origin of the sprite is
in its center! This is very important! That simply updates it. The last thing There are three types of joints, which
you’ll want to do is make it so that when will all be explained.

D3D9 Wrapper its Game Maker instance is destroyed,


The first type is a fixed joint. Fixed joints
QUICK REVIEW

the physical body will get destroyed too.


This Game Maker DLL is a
So, make a Destroy event, and in it put:
wrapper of the latest version of
DirectX 9’s Direct3D library.
Game Maker itself incorporates
features such as rotation, etc.
from DirectX 8 – but doesn’t
even use it to its full potential.
This DLL – a work in progress –
seems as if it will become
faster, and give us some
interesting features in the near
future. A GMK example is
included.

Get it now!
http://xrl.us/d3d9w
26 | P a g e July, 2007 http://markup.gmking.org

ENGINE
GMPhysics ENGINE
{

create_joint(firstvar.h,
secondvar.h, JOINT_SLIDER,
get_body_x(firstvar.h),
are very easy to create, and link two
get_body_y(firstvar.h), 180);
objects together. To make one, use this:
}
{

create_joint(something.h,
Everything from the hinge joint is
something.h, JOINT_FIXED); included. The last argument, which is
new, is the direction in which the slider
}
joint points.

To make the joint work correctly, switch


the two ‘somethings’ two the objects Conclusion
you want to join. The “h”s are there to Well, that’s it. You now know how to
make sure it links the bodies and not event in their create event, it should create and maintain physics, create
the instances. For example, if you work fine. static bodies, create bodies, and create
wanted to link together our obj_box and joints. Of course, this isn’t the end of
The next kind of joint is a hinge joint.
another obj_ball, you would use: GMPhysics. It can be used to create
Hinge joints are slightly harder to
{ understand. rays, water, springs, wind, magnetism,
soft bodies, and a whole lot more.
create_joint(obj_box.h,obj_ball.h,JO To create one, use the following piece Here’s a hint: See what happens when
INT_FIXED);
of code: you create a bunch of spheres and link
} them all together from 1 to 2, 2 to 3, 3
{
to 4, and so on.
Note that you have to be careful when create_joint(firstvar.h,
secondvar.h, JOINT_HINGE, Sean Flanagan
using object names. Creating more of
get_body_x(firstvar.h),
that kind of instance could mess it up.
get_body_y(firstvar.h));
Remember that you can assign
instances to variables, too. Kind of like }
this: Dialogue System

QUICK REVIEW
The first three arguments link the two This dialogue system imitates
{ bodies with a hinge joint. The last two is the one present in Baldur’s
firstvar = instance_create(100, 100,
where the joint is anchored. If you want Gate. This includes scrollable
obj_box); B to swing around A, anchor the first dialogues, with the ability to
one. If you want A to swing around B, use the script in conjunction
secondvar = instance_create(200,
anchor the second. (Usually this won’t with room views (early versions
200, obj_box);
matter unless you’re using a static body require editing, latest version
create_joint(firstvar.h, as one of the objects.) has it native).
secondvar.h, JOINT_FIXED);
The last kind of joint is a slider joint. Features include multi-line with
}
Slider joints are usually the hardest type setting line limits and
of joints to understand. Here’s an conjunction with scrollbars and
Take note that this assumes firstvar
example of the code used for creating a scrolling buttons.
and secondvar have already created
slider joint:
their bodies. If you put a create_body();
Get it now!
27 | P a g e July, 2007 http://xrl.us/dialogue
http://markup.gmking.org
ADVERTISEMENT

28 | P a g e July, 2007 http://markup.gmking.org 


EXTENSION
Extension of the Month EXTENSION
Powered By:
#define
file_bin_seek_relative(fileid,
position)
An extension of the file_bin_seek script built into Game
GMbase is a relatively new site dedicated to hosting the Maker, file_bin_seek_relative seeks from the current
web's largest archive of freely available extensions for position in a file instead of the absolute position. This
Game Maker. Upon learning of this fantastic resource I means that if you seek for a position of 5 from byte 10, you
couldn't resist submitting my most useful extension will move to byte 15 instead of byte 5.
package - HexScripts. Originally a collection of scripts - as
the name implies - this package extends Game Maker's
built in binary capabilities to include the reading and Conclusion
writing of big and little endian formatted integer words Besides the functions, there are also over 60 constants to
of any length. It also adds functionality for converting help you when defining large bases or data types! The
between different bases (such as binary and decimal) bases follow the "nb_*" naming scheme (eg. nb_bin,
and in addition includes a function to move the position nb_dec, nb_quin, nb_hex etc.) while the data types follow
of the document relative to the current position. the "dt_*" convention (eg. dt_byte, dt_long, dt_quad,
dt_short)

#define file_bin_read_word(fileid,
size, bigend) Download the extension
file_bin_read_word reads an integer word of the given http://gmbase.cubedwater.com/view_ex.php?ex=118
size (in bytes) from an open file stream in little or big- Leif Greenman
endian byte order.

#define Tile Optimizer


Tile Optimizer is an amazing script used

QUICK REVIEW
file_bin_write_word(fileid, size, to optimize tile usage in Game Maker –
bigend) leading to a speed boost.
file_bin_write_word does exactly what it says, it writes a
little or big-endian formatted integer word with the given The author says the tile optimizer could
size (in bytes) to an open binary file. increase the FPS of a game (provided it
uses a sufficient amount of tiles)
dramatically – a figure that could rise up
#define radix_change(number, to (but not always) an 820% FPS gain.
old_base, new_base)
The script is very simple – however the
The radix, or "base" of a number (ex. Decimal, binary, or
author warns us not to use this script
hexadecimal) is notoriously difficult to change with
unless we have about 30 tiles in a room,
conventional mathematical methods. Rithiur however,
or more, otherwise the script would not
takes a different approach and uses strings to change the
be as effective.
base of any given number. I obtained permission long
ago to use this script, however, credit to Rithiur should The example is provided in the GM6
probably be given. format. You must have at least a
registered version of Game Maker 6.

Get it now!
29 | P a g e July, 2007 http://markup.gmking.org
http://xrl.us/tile
Script of the Month

SCRIPTS
file_text_close(fid);
SCRIPTS
Powered By: return 0;
}else{
GMLscripts.com return -1;
}
}

List Saving and Loading Load Script


Though “lists” as a concept – is a great thing for Game Maker /*
developers like me, a problem it has is that it cannot be saved ** Usage:
** dsid = ds_list_load(filename,separator);
with the regular game_save() function.
** Arguments:
** filename file path to save the list to
This means that other methods should be used to save and load
** separator string used as separator
lists. between elements (optional)
** Returns:
Game Maker has its own set of function that allows you to store a ** ds_list id if successful, or (-1) on error
list to a string and later read it. These could be written to files to ** Notes:
** If separator is not given, each list element
be saved or loaded.
must be on a separate line.
** If separator also appears within data, the list
However if the creator wanted to store lists in a readable and
will not load correctly.
editable form (by humans), the best way to store it would be ** GMLscripts.com
using this set of scripts: */
{
Save Script var dsid,filename,sep,fid,dat,len,ind,pos;
/* filename = argument0;
** Usage: if (is_string(argument1)) sep = argument1; else sep
** ds_list_save(dsid,filename,separator) = chr(13)+chr(10);
** Arguments: fid = file_text_open_read(filename);
** dsid ds_list to be saved if (fid > 0) {
** filename file path to save the list to dat = "";
** separator string used as separator between while (!file_text_eof(fid)) {
elements (optional) dat += file_text_read_string(fid);
** Returns: file_text_readln(fid);
** 0 if successful, or (-1) on error }
** Notes: dat += sep;
** If separator is not given, each list element will len = string_length(sep);
be on a separate line. ind = 0;
** If separator also appears within data, the list dsid = ds_list_create();
will not load correctly. repeat (string_count(sep,dat)) {
** GMLscripts.com pos = string_pos(sep,dat)-1;
*/ ds_list_add(dsid,string_copy(dat,1,pos));
{ dat = string_delete(dat,1,pos+len);
var dsid,filename,sep,fid,i; ind += 1;
dsid = argument0; }
filename = argument1; file_text_close(fid);
if (is_string(argument2)) sep = argument2; else sep = return dsid;
chr(13)+chr(10); }else{
fid = file_text_open_write(filename); return -1; }
if (fid > 0) { }
for(i=0; i<ds_list_size(argument0); i+=1) {
if (i != 0)
Contributors
file_text_write_string(fid,sep);
file_text_write_string(fid,string(ds_list_find_va Thanks to xot and Leif902 (Leif Greenman) for creating the
lue(dsid,i))); script.
}
Eyas Sharaiha
30 | P a g e July, 2007 http://markup.gmking.org
GRAPHICS

GRAPHIS
Graphic Design “But g00d gamezzz dont n33d graphix! „

Most developers using GM forget that mapping that makes your computer cringe.
their main way of conveying However, the game rocks - say what you
information to the user is through want – and it rocks without any of those
BAD
graphics. Nearly all the relevant info special effects.
'Chain Chomp' has a textured dark
the user needs to play the game is background. There is no need for a
given with sprites, backgrounds, text,
Style rocky looking background because it
and all sorts of images. Particles tell has nothing to do with the game and
Using real photos, or heavily textured
you when something is being hit, or graphics in puzzle games can make the only adds distraction. Even worse,
maybe when the thrusters are on. game all blend together and too hard to the main character has very few
Sprites animate to signify that play. They need simplified graphics, that colors, and it very dark like the
something is moving, or trying to at are easily recognized by the player. Some background. If the game were to use
least. And even when developers know of the best games you will notice, have better graphic techniques, it would
cartoon-like graphics, with a black 1 pixel look more professional.
how critical graphics are to their
games, they often overlook it. On any outline on everything. This makes it all
given day, you can find a handful of very easy to see, no matter what the
sprites are in front of. Now obviously, an
bad games, and a handful of good
RPG with more detailed graphics will take
games. In 95% of the cases, the good
much more time, but in the end, it will
games will have clear, easy to see
look amazing if done right.
graphics, and it will all look nice and
clean. The bad games will have GOOD
Priority 'Seiklus' has cartoon-like sprites that
distracting backgrounds, sloppy
The colors of your objects is very all have a distinct black outline. This
layouts, and sprites that make your
important in any type of game. Too many makes having a white character on a
eyes bleed. There is no reason for this! game makers use a stunning background bright background possible without
With little knowledge of even MS that is way too busy for their game. The making it hard to see. The simplicity
Paint, anyone can fix up their games to background is just what it sounds like, it's in the graphics is also consistent
look nice. to be left in the background and not throughout the game and nothing
distract from the rest of the game at all. looks out of place.
Uniformity
All games need to have a standard Effort!
drawing style for all the graphics. While Fixing up graphics really does not take up
this can sometimes be difficult with much time. I hope this article has taught all
multiple artists, but it's definitely the developers out there that putting a
achievable on any project. If anyone takes little more effort into the thought part of GOOD
a look at Company of Heroes, and then their games' graphic design can make all Objects in 'Wubly 2' are color coded.
takes a look at Command and Conquer, the difference! The most important objects are lime
they will definitely notice the different art green, crimson red, or sharp pink,
styles. Use whatever is best for your Dan Meinzer
while the walls are left a navy blue,
game! Puzzle games need simple art, that which is closer to the background
is easy to see and understand. color.
Minesweeper is a great example of this.
The game does not have any new next
generation blur affects and normal
31 | P a g e July, 2007 http://markup.gmking.org
EDITORIALS
Sounds in Games: How Far? EDITORIALS
There is no doubt that sounds and
Though it’s a good idea to make
music have a crucial part in games –
something “exciting” that would
but the true question is: How much is
generate some enthusiasm for the
too much?
player, you must remember it should
I’d certainly like to listen to background be low and transparent. That is not the
music, and I’d certainly like to hear case when the game is being played;
some sound effects whenever I do a sounds are now part of the gameplay –
certain action, but at what point does and should be louder, more exciting,
sounds become a downgrading and be directly related to the tone of
experience to the game? the game.

To be able to come to a correct, logical However, even in the Game, you must
cannot and should not be implemented be very careful that the background
answer – we need to differentiate
in certain areas. Though in menus, music does not degrade the sound
between various types of sounds – as
option screen, and other similar effects in the game; you should be
each one has its own type of
situations, there might be no need for able to hear all the players speaking,
limitations.
background music, I certainly think you should be able to hear the sounds
Sounds include background music, and there should be. of buttons you’re clicking, and steps
sound effects. The sound effects group the players are making.
The type of music to be present at such
itself could be divided into two: those
areas however must – I repeat: must –
you listen to when clicking buttons, and
interacting with the game’s UI, and
be different (in terms of tone and Sound Effects
mode) from what is present in the Sound effects that need to be in the
those you get form the characters
gameplay. Such music should be
themselves: such as the sound of them game form a huge range of different
talking, their steps, gunshots, etc.
calmer, and it must not be loud. 
Though the article is more aimed at the
higher limit for sounds – how much is
GM Cash 1.1
GM Cash is a Game Maker 7 extension
too much – I’ll also be discussing the that adds more Drag n’ Drop actions to

QUICK REVIEW
must-have sounds as well – the the object properties window.
‘minimal requirements’ for games.
The library added allows the game
developer to add links and commands
Background Music that the user could use to donate to the
Background music is an essential part game’s developers, or just pay to get a
of a game, and my personal full version of the game.
recommendation is: at no point in the
game – be it Game Play or just The extension library supports 8 stores at
interacting with the interface – should its current version, these include PayPal,
there be no background music at all. ShareIt, Payson, Ebay, VSTORE, MyStore,
Mal’s Ecomerce, and OSCommerce. It
This may be thought of as – there is no also has support to be used with the YoYo
“too much” background music, and Games community and the Game Maker
when it comes to quantity: it’s true; but Community.
there are certain types of music which
The extension requires Game Maker 7.

32 | P a g e July, 2007 Get it now!


http://markup.gmking.org
http://xrl.us/gmcash
EDITORIALS
Sounds in Games: How Far? screams on various occasions player.
EDITORIALS
types of effects. Out of the many
 “Radio” when in vehicles
possible sounds, I thought the following
need to be included in a game: Of course, such sound effects do not Conclusion
apply for all kinds of games, but it Sounds need to be included in the
 Bullets
certainly gives you a picture of what game, without them – a game wouldn’t
 Bullets colliding with wall, could be included in your games. be as good. The challenge would be
player, and enemies
knowing what types of sounds you
 Buttons being pressed One general piece of advice though,
should put in, when they should be put,
 Steps (preferably for different sound effects must NOT be overused. If
you’re thinking about adding sound and most importantly: when to stop.
materials)
 Players taking effects to something that occurs very As I previously said, redundant sounds
 Vehicles frequently, like a button that might effects should be avoided, and so
pressed several times in 20 seconds, should using the same sound effect for
Extra sounds that would be nice to be then you might want to think again. multiple actions. As for background
added – but not required for all games –
music, you should know when it should
are those that would add excitement to I know what some might be thinking:
be low and when it should be higher,
the game, but without them the game is what about footsteps? Sure, footsteps
are very redundant, and that is where when it should be calm and when it
not “silent”, these include:
talent kicks in; footsteps should have the should be more exciting, as well as the
 Occasional “Oh, I’m hit!” quality and types of sounds to be used
same status that I gave to background
screams music in menus: it should be low and all over.
 Dying sounds transparent – something that could be Eyas Sharaiha
 “Fire in the hole” and similar heard, but does not keep annoying the

_FATAL_ REVI EWS

_FATAL_ is described as a “fast paced use both hands and are spread out well the full version, but I hope it will be
SHMUP”. You’d be hard pressed to argue across the keyboard. The three action worth the money. It is certainly one of
against that. Within seconds of starting, keys are close together which may be the most underrated games in the GMC
you find yourself surrounded by bullets easy for some, but others may find at the moment.
from various enemy craft whilst you fire a difficult – slipping and pressing the
wrong key or doing so because of not Some Information
seemingly inexhaustible armory of bullets. Creators: ChIkEn AtE mY dOnUtS and
It’s hard to last for long at all and obvious paying enough attention proved
Coffee.
to see why you start with five lives rather problematic for me.
Download link: here.
than the more traditional three. As ever there are cons to the game.
You can automatically see that the game Being a work in progress, it is typically
will have a retro feel to it. The graphics lacking in features. But that will
are formed of very simple, similar looking undoubtedly change. ChIkEn believes
ships and lines to give a feeling of depth. that the game will eventually sell for
Similarly, the sound is the collection of almost 23 USD, so it will almost certainly
squeaks and beeps that one expects to be abundant in features.
hear off a classic arcade machine. To me, I look forward to the end version of this
this is a very admirable quality as I’ve game. With more craft to choose from
always been a fan of very retro game. and different modes of play, it will be “Grego” Tyler
The controls are fairly easy to grasp. You great to play. I probably won’t be buying

33 | P a g e July, 2007 http://markup.gmking.org


REVIEWS
Bounce 2 REVIEWS
height is adjusted enabling you to reach
get bored of playing through the 50
high platforms and duck under
What they say obstacles. Blue blocks make the ball
levels (including the levels from the
In BOUNCE 2 you control a ball that you original ‘Bounce’) consecutively.
bounce higher, whilst red blocks reduce
have to try and guide to the end of the the height. There are also yellow Many who played the game criticized
level. You have to avoid obstacles by blocks which blast your ball up high so it, saying that if you keep the ball over
bouncing on different colored blocks you can reach the portal to the next a red block too long. As the bounce
which alter your bounce height (blue level. height is constantly reduced eventually
makes you go higher, red lower, etc).
the ball becomes stuck and cannot be
You will use many objects and power- Some strategic thinking is needed if you
moved off the block, resulting in an
ups to reach the end of each level. are to reach the end of some level
irritating noise being played until the
successfully on your first attempt.
level is reset. Obviously this adds
Review another risk to the game which the
player must overcome to complete a
This game takes a simple concept,
level but the opinion of some seems to
guiding a ball to the end of a level, and
be that this is too much. Personally
adds in different elements to make the
I’m not too bothered by it, however I
game harder as you progress.
did become stuck a couple of times
The ball you control is constantly whilst reviewing this game which was
bouncing, by using the left and right a minor annoyance.
arrow keys you can change the
Sounds do become repetitive and you
direction in which the ball travels. In
will probably recognize some of them
order to reach the end of a level you Blasts of electricity can be turned off by
from other applications when you play
have to avoid the many obstacles bouncing on the appropriate colored
the game for the first time.
which lie in your path. At first these switch and fans can be used to blow
Fortunately there are options to toggle
are just a maze of walls which the ball your ball both to your advantage and
both music and sound effects.
must be guided through, but later in disadvantage.
the game dangers such as spikes and Philip Gamble
electricity are added which, if touched, Thankfully a save and load game
send you back to the start of the level. feature is included, otherwise you may

Information
Graphics Download Size: 2 MB
8
Download Link: xrl.us/bounce2
6 Download Type: Zipped Executable

Overall
4 Released: July 2006
SoundAuthor: SuperCasey4
SUMMARY
2

0 Review Summary
Graphics: Adequate, not perfect
Sound & Music: Becomes an
irritation, too repetitive.
By manoeuvring your ball so it hits Gameplay: Very simple controls,
Gameplay Music
different coloured blocks your bounce ‘sticky’ issue
Overall: A nice idea enhanced by
power-ups and obstacles
34 | P a g e July, 2007 http://markup.gmking.org
REVIEWS
Snow Ball War REVIEWS
and an added realism is that you can be
What they say hit by members of your own team.
They say it’s a classic game of Capture Perhaps one problem is the one-hit
the Flag. You and a team of blues fight health each snowballer has. You are
the reds for the flag. Click once to get a forced to respawn each time you are
snow ball ready, click again to throw. If snowballed – a health bar indicator
you get hit you will be sent back to the above a player with three-hit health
nearest spawn point. It’s primitive but would be more realistic and would give
addicting!! you a longer chance of fighting your
opposition.

Review The blocks in the game serve only as


Snow Ball War definitely falls into the
category of mini-game. It is based on a obstacles to navigate around as
concept used in several Flash games snowballs can be thrown over them to variation in the different levels
where you control a member of a team hit someone on the other side. available either. If more customization
in the weather dependent sport of was added to this game it could be
Other realistic features such as the fact much more fun, and with such a
snow ball fighting. This has also been
that you have to gather snow before simple a game a level editor enabling
seen in games of a similar nature
you can throw each ball, and that balls players to create their own snowball
where instead of snow a catapult or
can only stay in the air for a certain arenas would also be a useful addition.
grenade can be used to inflict damage
distance further enhance gameplay.
on your opposition. Philip Gamble
However it isn’t all fun and games, the
The AI in Snow Ball War is
screen view is very small and whilst the
unquestionably clever, it is realistic in
graphics are adequate for basic
the decisions it makes and it isn’t easy
gameplay they could easily be
to avoid your rivals at all. That said by
improved. There is little noticeable
running around obstacles you are able
to dodge the snowballs which the red Information
team will through at you, and grab the Download Size: 1MB
flag from your opposition’s base which Download Link: xrl.us/snowball
makes the game winnable. Graphics Download Type: Zipped Executable
8 Released: July 2007
Your own team however is not Author: Beat22

SUMMARY
6
supportive of your efforts to go and
grab the enemies’ flag, instead tending Overall 4 Sound & Music
Review Summary
to throw snowballs at any opposition 2 Graphics: Could be easily improved,
they see and engage in their own mini no much variation
0
war against the computer’s team. Sound & Music: Non-existent
Gameplay: No real bugs, smooth
Unlike many mini-games there are a
AI Gameplay AI: Your opposition are effective in
number of levels to choose from, 4 in
both capturing the flag and
fact, each with its own terrain and a
defending their base. Let down by
different number of participants.
Level Design your own team’s choice of tactics.
One snowball can hit multiple people, Overall: Simple concept which
should have been built upon
35 | P a g e July, 2007 http://markup.gmking.org
further.
THE WRAP UP
Until Next Time! THE WRAP UP
And so it ends: another record- every month. the previous issues, and we’re looking
breaking, content-packed issue of forward for more participation in the
MarkUp magazine! Before I start with all of the thanks, I future.
have an apology first; sorry to Leif
MarkUp Issue 6 also celebrates the half- Greenman who also was a contributor MarkUp has grown in an overwhelming
year anniversary of MarkUp magazine! in the Script of the Month for issue 5 way in the past six months, but we still
We are thrilled by the amount of but was not mentioned. Contributors in aspire to more growth which can only
support, feedback, and contribution scripts at GMLscripts.com are now be done by your continued support and
MarkUp has gotten in the past six mentioned in articles. contributions. To contribute to the
months. magazine you could visit the MarkUp
Again I want to say how much I forum here.
We are also thrilled about the growth of appreciate the support we got from
MarkUp magazine, in terms of content, various Game Maker sites. First and The quality of MarkUp magazine is
readership, and yes: community foremost, thanks to YoYo Games for the expected to improve continuously as we
support. continued endorsement and support of get more readers and supporters.
MarkUp. Remember that even if you cannot
The entire MarkUp staff is contribute in terms of articles to the
overwhelmed with self-satisfaction. Thanks to GameMakerBlog.com and
Magazine, we won’t improve if you
After all, we have not only delivered an GMLscripts.com for the continued won’t give us your much appreciated
excellent publication for six months, but contribution to MarkUp Magazine. Also opinion.
also managed to deliver such a content thank you for GameMakerResource.com
packed issue on-schedule: each time, for all the work that they have done in Once again, thanks for your support!
The MarkUp Staff

Be sure to check out…


GMking.org – the network behind MarkUp – also supports developers in various ways. GMking.org provides Game Maker
developers with excellent resources, as well as other developers from other IDEs.

MarkUp has sister projects, also developed and maintained by GMking.org, all meant to help Game Developers. To learn
more information about your Game Platform of choice, you could check out GMPedia.org. GMPedia is a game development
wiki with a growing community-base and content.

You can also listen to our audcast – GMPod – related to the Game Maker Community and its events by viewing the Audcast
page on the GMking.org main page.

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
36 |ofPora affiliation
to indicate sponsorship ge July, 2007
with any product or service. While the information contained in this magazine has http://markup.gmking.org
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.

You might also like