Game Maker Programming/Basics

From Wikibooks, open books for an open world
Jump to: navigation, search

Game Maker is an object-oriented programming language; the most basic parts are Sprites, Sounds, Backgrounds, Objects, and Rooms.

Coordinate system (X,Y)[edit]

As in graphs that you do in school. In Game Maker it is done in pixels and it is quite easy to lose track. In most places (sprite room editor etc.) you will get the chance to find and move in x,y coordinates. If the concept is new to you, you won't know what these are yet but it will make sense when you become more accustomed to Game Maker.

Note- Game Maker uses Cartesian system of graphing, so only x and y values are supported. What about z? z is going on to 3d, so we won't talk about that here.

Sprites[edit]

Sprites are images which can be imported from most image file types and are graphical representations of objects within the game. A sprite can be static, animated or stepped when used in Game Maker. A program that you can use to make the sprites is MS Paint. In Advanced Mode, you can create a sprite from scratch, or edit a finished one.

Sounds[edit]

Sounds are an audio file imported within the game, and may be taken from a variety of file types (including MIDI and .Wav files). The user can create positional sounds so that when the player walks into a dungeon eerie music plays to set the tone of the area. You can also add sounds to buttons, so that when the user presses a key on their keyboard a sound is emitted. Sounds in general like background music may also be added.

Example : sound_play(some_soundfile);

Backgrounds[edit]

Backgrounds are images which can be imported from most image file types. Backgrounds can either by tiled horizontally or vertically, stretched to the width of the room or used as tiles to 'build' the look of the room. Like Sprites, in Advanced Mode, you can create your own background or edit it.

Objects[edit]

An object is a piece of code in your game world and may be programmed to do a variety of things, ranging from simply occupying space in order to prevent the player from advancing along a path to being as complex as a programmed enemy with hundreds of lines of code to give it a small amount of artificial intelligence. Objects are commonly represented with sprites, though they may be rendered invisibly by not selecting a sprite for them.

Instances[edit]

An Instance is an actual physical representation of an Object within the game world. Whereas the Object is the piece of code which provides the template for how a given Instance acts, the Instance is the actual thing with which a player interacts.

For example, in Super Mario Brothers there was only one Goomba programmed. It was programmed to walk left until it fell down a hole or got squished by an overweight Italian plumber named Mario. The actual Goombas that Mario is interacting with when he's running through World 1-1 are Instances of that original programmed Object.

Rooms[edit]

A Room within the game is a piece of the game world which is rendered as a single area during gameplay. Any global effects due to objects within a single room (for example, the rain effect generated by the use of particles) will be rendered throughout the room. You will use Objects to make the rooms.

Step[edit]

Every game runs in steps. Each step is 1/30th of a second. 0.06 reoccurring. Unless you have changed the room speed, then it will be different; or if there are too many object/particles and other things that eat up your Frames Per Second. Lets get to the point, a lot of step events happen every single second.

Basically everything is mathematical in here. There's not much math for you to do, if any at all. However if you try to relate everything back to a math lesson you had at some point in your life, things begin to make sense a lot faster.

Instance[edit]

Is what the player sees in-game, the actual thing. So say you have a robot in your game, who would twist at the torso, and run with his legs. one object would govern the torso and one object would govern the legs. kind of like a tree. Sprites make objects, which in turn make instances.

So in whatever game you are playing take age of empires (which is a 2d real time strategy game, if you were wondering, and is capable of being made in Game Maker) the catapult or battering ram you see in-game is an instance of the object battering ram.

3D[edit]

When you learn how to program in game maker, you "can" create 3d things. 3d in game maker, goes slower than 2d, so you have to be careful. But assuming that you are new, we will not go into depth about game maker's 3d functions. 3d functions are available only to registered game maker users. To prepare a 3d game, all you have to type is d3d_start() . Then after that... Have fun with lots of head aches!