GM: Introduction to Programming

From GMpedia.org Wiki

Jump to: navigation, search
Portions of this article were assimilated from the content at the Game Maker Community, by 'Rick Slick'.
Feel free to continue to modify and expand this page, but please leave this notice and any licence notices in-tact.

This tutorial works with...

Game Maker specifically, but applies to all other game development IDEs in general.

Computer programming is more often an art rather than a science. You can read all the books on computer programming that you want, but unless you're one of those people that just pick things up right away, the only way you are going to learn computer programming is to sit down and do it. This means trying different things, reading through the tutorials, tinkering with existing code to find out what the effects are, adding your own code to get the desired effect, and so on. Just like you can't expect someone to read a book on how to repair televisions and then automatically know how to fix every television you sit in front of him, you can't expect to learn computer programming overnight. It takes time, patience, trial-and-error, experimentation, and a willingness to learn on your own. I would be willing to bet that some of the top game makers on this site who have completed some of the most popular GM games available are all self-taught. That doesn't mean they never came here asking for help with how to do something, but they most likely didn't have anyone spoon-feed them an answer either.

All too often, there are various questions on the Novice/Beginner forum where the user is trying to jump in head-first into a project that is too far beyond them, and then they become frustrated when no one can offer any help to their questions like "How do I make a pokemon game?" or "I need to know how to make my platform guy jump, move, shoot, oh and I need enemies to attack him... how do I do all that?" My typical first response is... have you looked at the tutorials? Have you read through the GM manual to get a feel for what DND/GML commands are available and how you might use them? Is this the right project to be undertaking for your skill level?

I'm not going to sit here and try to tell anyone that there is one complete and proper path to learning how to use Game Maker, but I can provide some insight as to how to become self-taught. There's nothing wrong with asking people how they would go about doing things if you truly don't understand, but do you really learn anything if someone spells out all the code for you? Sure, you might get your feature working, but what happens the next time you reach an obstacle that you don't have an answer for?

The first thing I did when I started programming on the ol' Commodore 64 (keep in mind this was 25 years ago) was I took existing programs and changed them around, with my face in the C64 BASIC Reference Manual. Tinkering and trial-and-error are the best ways to learn about the commands and what they do. Have the GM Manual handy at all times, and be familiar with how to search for information. There is also a very good guide linked on this forum somewhere regarding DND commands and their GML equivalents. While DND is a good place to start for users with very little programming experience, you will soon find yourself limited and you will want to learn GML and its syntax soon thereafter to provide more functionality and fancier features in your game.

This means you look at the tutorials that came with Gamemaker and understand how they work. Can't figure out how to make your player move back and forth across the screen? It may not be the best thing to run here and ask a question that you could have figured out on your own and learned something in the process... because you'll be right back here again when you need to figure out how to make your player rotate. Check out the player object in one of the tutorials and read over the code that performs that function. Tinker around with it. Change some values. Run the game again to see what the effect was. Download another engine/tutorial and see how someone else handled it with their code. Change some of that, see what happens. If you find particularly useful bits of code that you can see yourself using frequently, copy it down and study how it works. Re-write it in your own fashion and save it so you can use it in your games, or if needed, write down whose code it is so you can give proper credit. Become familiar with the Debug windows... they're invaluable for determining whether those global or local variables are changing the way you want them to, or if you have a memory leak somewhere because instances aren't being destroyed properly.

Once you're comfortable with the syntax of the language and how to use it to perform the desired actions on your objects in the game, the next step is to attempt to make your own game. All too often, people screw this step up by attempting something way too difficult for their skill level. Then they become frustrated and run to the forum to ask all sorts of questions. My question would be... why are you starting out with a top down shooter or a role-playing game? These are some of the hardest types of programs even for veteran users to accomplish: a top-down shooter usually requires an extensive assortment of weapons and effects, as well as enemy AI, views, collision checking, and a HUD. Role-playing games require an extensive equipment/item list, skill and inventory systems, a variety of maps and enemies, magic spells and effects, and enemy AI.

Wouldn't it be easier to start simpler to get used to programming in the GM environment? As unexciting as it might seem, why not start out with a game like Pong or Space Invaders. Granted, it may not seem like much of an accomplishment, but Pong requires 3 moving objects, some rudimentary deflection physics, and collision checking. Space Invaders requires a bunch of moving objects, projectile firing, collision checking, and enemy pathing. Either would be a great first project for a GM beginner, and there are plenty of tutorial examples that have those features contained within so you can tinker and pick them apart.

Think of it like you're in your own role-playing game... there are certain programming skills you need to learn and develop before you can attain a certain goal. Think about how you would rate yourself in the following GM programming concepts (these are examples, this list is nowhere near complete) and then pick a project that helps you hone those skills:

Object Movement Image Animation Collision Checking Particle Systems Using Variables Using Arrays String Manipulation Surfaces Firing Projectiles Tiles Line of Sight Enemy AI etc etc

When you've got the basics down, the next project that would match your skill level would probably be a scrolling shooter. There are also many tutorials on this type of game, but you can make it as simple or as complex as you want. Add different types of enemies with some rudimentary AI. Add some challenging bosses with different attack styles. Make some different levels/maps. Try some different explosion and weapons effects.

After you've finished something like that, the next good step would be a platformer. Now you will be using some image animation skills, obstacles, gravity, different attacks, level design and map making, enemy AI, items to collect, traps, etc. These are more tools in your toolbox that you can use in future projects as you build upon your game-making skills, and there are plenty of platformer tutorials/engines to modify, tinker with, and pick apart.

Once you've completed these initial projects, you should have enough experience with some of the simpler things that I see people asking about on the Novice/Beginner forum, such as score-keeping, health, lives, variables, collisions, gravity/friction, image_angle, how to make an enemy close on the player, how to execute an attack and remove health, animation, etc. At this point, then you would be in a better position to attempt that Pokemon game or that top-down shooter, or even an online game (after studying the multiplayer tutorials/engines inside and out.) Be an avid reader of the Game Design section of this forum... it'll help you think about how to design your game from the ground up before you even start to code, minimizing the chance that you run into a roadblock, balance issue, or design flaw. Plus, it's useful as a sounding board for some of your ideas.

The bottom line is programming is a skill that is best self-taught, and if you jump too far ahead with a project that is too ambitious for your skill level, you will become frustrated and most likely give up. And that would be a shame, because this community can always use more aspiring game developers. Don't be afraid to ask for help, but by all means make sure the answer is not just staring right at you in the GM manual first, and make sure you have attempted to understand and tinker with the appropriate tutorial or engine after you've searched for one on the forum. And don't just ask for the code... you won't learn anything that way. It's better if someone gives you a conceptual idea of how they would go about performing the particular task you are asking about (the "art"), leaving you how to translate that into code yourself (the "science").

Personal tools