Welcome Guest ( Log In | Register )

[ Big| Medium| Small] -

Post new topic Reply to topic  [ 6 posts ] 
  Wed Nov 20, 2013 6:10 pm
User avatar

Generic Townsperson
Hello! I've been using GameMaker for about 3 weeks now, and I have fallen in love with it.
However, it does have a bit of a learning curve to really get cozy with it.

So I decided to compile and share some of the not-so-obvious things I've learned. I'm sure most of you that actually read this topic will know much of it already, but I wouldn't be surprised if even advanced users didn't know one or two of these.

First, this entire document assumes Advanced Mode is enabled.
File->Advanced Mode (make sure it is checked).

Second, a few preferences that make life a bit nicer:

I suggest unchecking "show website button in main window"

I suggest unchecking "show news/tutorials at startup" (news or tutorials depends on your version of GM)

I suggest making sure Backup on Save is enabled, and setting it to something like 5 backups. Quite nifty if you want to revert.

I *strongly suggest* disabling "Hide the designer and wait while game is running" as this option is a bit broken. If your game
crashes, the designer won't come back, and you can't save your changes.

Now, a few tips on Objects:

Add a "Room End" event, which calls the code instance_destroy(). Destructor's don't typically call on exiting a room, this ensures
that they do, making this behaviour a bit more predictable.

Step events are basically "on update" events. The game speed is set in "steps per second".

Drawing code in scripts, such as drawing a rectangle, will only function if it takes place during any object's Draw event. (The script
helper object exists to enable such behaviours without needing a logical object to attach it to).

I suggest, when possible, using Call Script instead of Execute Code - oddly, with a Script Editor open, you can still interact with the
main window, while the Code Editor blocks input to the main window. Also lets you update code without having to fish through objects.

Lastly, in an object's Step End event (or just step, technically), you can use the following snippet:
That will give the object "map depth", allowing things to walk behind or in front of other (dynamic) things dynamically.

Now, some neat tips on instances:

First, you can CTRL+RightClick on an object (in the room window) to get a context menu. This context menu has the option Creation
Code, one of the most powerful features of GM (and few people seem to realize it exists o.O).

Creation code runs *before* the object calls its "on Create" event, allowing you to set up local variables that are specific to that exact
instance. For example, objItem could set itemId=5 in its Creation Code -
the actual Create event for objItem would simply switch(itemId){...}.

Map editor tips:
Personally, I always leave Snap to Grid enabled- in the lower left of the window you'll see a list of hotkeys. Learn to use these as
they will greatly expedite the mapping process.

There's a checkbox that says "Delete underlying". This is important - sometimes appropriate, sometimes absolutely not. Let me
point out now, that Delete underlying will delete *any* underlying object, even of a different type. For example, say I want to place
an item atop a table. The table might have collision mask objects present, which I don't want deleted. So I would make sure the
box is unchecked. On the other hand, say I'm painting a collision mask - I want to leave that checked so I don't risk stacking multiple
collision tiles on top of each other.

Speaking of tiles - you *could* create map tiles as objects, and assign them various properties. Personally, I find it much faster to
use collision objects, which have "Visible" unchecked in object properties (but are visible in the editor). This way, I set the map layers
to whatever Depths I want them at, and then make a quick and easy second pass to set the collision. No extra effort required :)
There will be some notes on tiles below.

Background/Tiles tips:
When you create a new background, and load an image, you have a checkbox that says "Use as tileset". This is an important option,
as tile-based mapping is probably what you're into at this point. Ideally, the tilesize of your grid in the map editor should match this
size. Now, an important note: If you use a background as a tileset, in the map editor, it will no longer be listed under Backgrounds.
Instead, it will be listed under Tiles, and used just like any other sane tile mapping editor.

Script Helper Object:

I often use a "startup" room, consisting of only one object: an object I call the Script Helper Object.

Script Helper is set to Persistent - meaning every room you switch to after startup, it remains unless it destroys itself.

I basically set all the events I am interested in to call my eventHandler scripts. For example, eventHandlerDraw().

The purpose of the Script Helper Object is organization - mine often exists at a negative depth, so that anything I draw with it is drawn
over the level. It lets me call script functions on events, without having to depend on the existence of a visible object.

While not "neccessary", it seems to keep things much cleaner for me.

Game Settings Tips:

You can "disable" the loading image by using a 1x1 image and setting its opacity to 0 (be sure to disable the loading bar too if you do this).

I use Game Information for notes, and therein I disable "Press F1 to view Game Information", as I don't want that visible to the end user.

Rooms Tips:
There is Room Creation code, under the settings tab. This can be used for setting Room variables. For example, say you have your script
helper object draw a gray rect (set to additive blending) over the entire screen. Here in room creation, you could set its color and opacity
for a cheap Screen Tone implementation.

The game *always* starts in the first room in the list. I personally leave this room empty, containing only my script helper object, and use its Game Start callback to switch to any room I like.

The Room Caption is what will show in your window title bar. Don't be afraid to hijack this with GML instead, using the script helper.

Don't be afraid of GML. There is a GML (script) command for every single one of the drag and drop features, and several more.
Personally, I recommend orienting your project around GML, and using the objects/events/etc to organize your scripts. By doing so,
it's relatively painless to create any kind of 2D engine you can imagine.

Here's a tip: script names are important - because each seperate script acts like a "function" from a traditional programming language. For
example, if I have a script called scrUpdateClock, in any other script I can add the line scrUpdateClock(); to call it.

Scripts have arguments. While you don't declare them, you can pass up to 15 (for example: scrUpdateClock(time, speed, somethingElse);)
You can access script arguments using an array called arguments[0-15].

Data types are automatic in GML, you can declare something with the "var" keyword, but its entirely unneccessary.

And obviously, Google is your friend. Seriously, even for the silly stuff. I've written two entire engines in GML, and my search history
is crammed full of stuff like "how to draw a gradient gml" and "gml dynamic depth" and "gml pathfinding tips" and of course "gml
for n00bs". Read, learn, create.

Here's a starter kit covering most of what I've explained so far. See my comments below for the actual features/changelog.

The Download (requires GameMaker 8.1 or later):
For those of you who don't have GM 8.1+, but would like to take a look, here's the EXE.
http://www.mediafire.com/download/3qdjy ... n/demo.exe

You're free to use it in any way you like, no credit neccessary.
Please replace the title screen and windowskin art - they were grabbed from a public resources site, but as its not an actual project I forgot to check who to credit. I'll do something original for these later.

If anyone has comments, questions, or just wants to say hi, don't be shy.

In closing, I really wish we had a GameMaker subforum.

Last edited by aphadeon on Thu Nov 21, 2013 4:39 pm, edited 4 times in total.

Top Top

  Wed Nov 20, 2013 8:37 pm
User avatar

Generic Townsperson
Added a demo demonstrating a lot of the points I've made so far. It could serve as a starter kit for a top-down system.

Functional Title Screen (demonstrates a simple form of scene control)
4 directional movement (with key priority resolution!)
Collision system for solids
Dynamic depth for map objects
Terrible, terrible artwork (not doing all your work for you. :p)
Script helper object
Automatically creates player object on every map (while in a "map" state)
An absolutely useless HUD (but easily expandable!)
Enough code to learn your own

I suggest you explore the demo thoroughly to get an understanding of how it works. I tried to add a reasonable number of comments to all the code.
90% of the work here exists in the Scripts category. You will need to be in Advanced Mode to access half of the tools I've provided.

Note that this is not a full-fledged game engine. It's a starting point, which Game Maker doesn't provide by itself (and for good reason). This is not the only way to do things, its just my way of doing things, which I'm sharing with you. I imagine it would be useful to people that haven't yet figured out things like menus, guis, title screens, and the like. It's not very drag-and-drop friendly- while you can use the drag-and-drop system to build your game, you will have to go codeside to adjust what I've already done.

If anyone has any questions, please ask. I'd be happy to answer them.

Last edited by aphadeon on Wed Nov 20, 2013 10:25 pm, edited 1 time in total.

Top Top

  Wed Nov 20, 2013 10:24 pm
User avatar

Generic Townsperson
Updated the starter kit.
Added some title screen stuff, like a configurable background, title. See the script "config" to set up these preferences.
Added support for RPG Maker XP windowskins, to demonstrate how scripts can make complicated tasks easy to use. See the "panel" group of scripts for the implementation code, or the event_handlers->on_draw script for the usage.

Top Top

  Thu Nov 21, 2013 4:31 pm
User avatar

Generic Townsperson
Updated the demo again.

I implemented an object based "Message Window". This shows how to abstract technical devices, like the previous Panel system, into an object oriented wrapper.

I also implemented an "ez actions" set of scripts - these basically work like the Interpreter in RPG Maker. Once the technical lifting is done, these make it outright simple to use the more advanced functionality. While only a convenience, they are a tremendous one, especially as things get more complicated.

In the message window, I implemented a couple of extra goodies - specifically, text with a drop shadow (to improve readability), and an optional letter-by-letter mechanic.

For usage on the ez actions set, just look at any of the scripts in the group. They all have headers outlining their purpose, arguments, and return values.

Added a couple technical shortcut snippets under the Utility group. Specifically, a custom word wrap that is able to cut off large words, and one example of a shadow text wrapper.

To view a demo of the message box in action, press M while on the map.

Top Top

  Thu Nov 21, 2013 7:46 pm
User avatar

Omnipresent Merchant
That backup on save function is an amazing idea, especially saving a set number of backups. Never knew it existed, thanks. That's one thing that really annoyed me about RPG Maker: not only is there no backup on save, but there's no "save as..." to begin with, leaving you having to copy the data folders to back anything up, and anything that makes backing up lengthy will stop people from doing so.

I haven't used game maker in a while but your ez scripts sounds pretty nifty, the Interpreter is great in RPG Maker.

Will try this out when I've got a computer that can run it again..

Top Top

  Fri Nov 22, 2013 6:44 am
User avatar

Generic Townsperson
Glad someone found it useful! I was beginning to wonder if I was just THAT BAD at it, haha.
I'll add more stuff as time goes on. This isn't a "collection of ez action" scripts, so much as an idea of how to organize your script's features to be easy to use.
Next addition will be RM*-style map events without creating a crapton of Objects for them (seems to be a commonly misunderstood issue).

Top Top
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

Who is online

Users browsing this forum: No users and 4 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

We are an independent, not-for-profit game making community.
Board Index
About Us
Downloadable Games
Free Browser Games
Games in Development
RPG Maker Support
Game Maker Support
Construct 2 Support
HBGames the eZine
Advanced RPG Maker
Site Announcements
Powered by phpBB © phpBB Group