Tag: Extension

z3d Engine for GameMaker Studio

z3d is a fake-3d engine designed for simplicity, efficiency, performance, and ease of use. Full documentation + demo included.

In a 2D GameMaker room, x and y coordinates are used for positions in the 2D space. 3D requires a third variable for the third dimension, z. In the z3d engine, x and y are used to represent the “floor” plane as viewed from a top-down perspective, from a forced perspective that gives the viewer a full view of one side and top of objects, while z is used for altitude.

GameMaker Marketplace

Full Documentation

iMprOVE_WRAP extension for GameMaker Studio

Today I’ve released a new asset on the YoYoGames Marketplace, called iMprOVE_WRAP.

Many video games have the feature that exiting one side of the screen will “wrap” you around to the opposite side — notable examples of this include the smash hit classics Asteroids and Pac Man. GameMaker: Studio has a GML function, move_wrap(), which is intended to provide this feature easily, but it has a few limitations. iMprOVE_WRAP addresses these limitations, resulting in a more powerful, flexible implementation.

iMprOVE_WRAP improvements over move_wrap()

Wrap behavior is no longer based on the built-in GML speed variables.

One of the most troublesome limitations of move_wrap() is that it only works for instances that have a speed. In standard GML, the variables speed, hspeed, and vspeed are used to move instances. But you can also “move” an instance by changing it’s x and y position in the room, without setting a speed. Many GM:S users will implement their own movement systems that eschew these variables, in order to give themselves complete control over the movement engine. When they do so, they are often confused when they discover that move_wrap() doesn’t do what they expect.

iMprOVE_WRAP eliminates this dependency, so that an instance no longer need to use the GML speed variables in order to wrap; wrap behavior in iMprOVE_WRAP is based entirely on an instance’s x,y position.


Wrap region no longer limited to room borders

Another problem with move_wrap() is that it is intended to work with the Outside Room or Intersect Boundary GML Events. This means that move_wrap() is only useful when an instance moves outside the room, or encounters the edge of a room. But in many games, the “play field” may not be synonymous with the entire room — the room might have a border, or “dashboard” or “heads up display” which ideally should be considered “out of bounds” with regard to the play field.

iMprOVE_WRAP allows you to define a “wrap region” — a rectangular area inside the room, which instances wrap around the borders of, rather than the borders of the room.

Independent horizontal, vertical margins

With move_wrap() the margin argument which determines the margin by which the instance must be outside of the room is the same for both horizontal and vertical travel; with iMprOVE_WRAP the horizontal and vertical margins may be set independently of each other.

Wrapping instances can (optionally) draw themselves on both sides of the border

With move_wrap(), an instance still draws its sprite in the default draw in only one location: at (x,y). If the instance is off the edge of the wrap boundary, but hasn’t yet crossed over, the instance draws on the “pre-wrap” side of the room; after the instance progresses by margin pixels over the border, then the instance’s position is moved over to the “post-wrap” side of the room, and the instance is drawn there. This is not a big deal if the instance crosses the wrap boundary quickly, and has a relatively small sprite; but for slower-moving instances, or instances with larger sprites, it creates a jarring “jump” effect, where suddenly the instance appears on the “post-wrap” side of the boundary, with no real warning, rather than gradually entering the room.

iMprOVE_WRAP solves this by providing a new function, iw_draw_self_wrap(). This new function augments the default draw by drawing the calling instance four additional times, at positions left, right, up, and down from the actual instance, the width or height of the wrap region away from the actual instance. Thus, when your wrapping instance is moving off the edge of the wrap region, one of these extra drawings is poking out on the opposite side, creating an illusion of continuity as the instance leaves one side and emerges from the other.

For a wrap region that is smaller than the room itself, it’s best to do your drawing on a surface that is sized to the area of the wrap region; otherwise the parts of the drawing that should be outside of the region will be visible outside of the wrap region. Alternately, if drawing to a surface is not something you want to do, you can “mask off” the portions of the room outside of the wrap region by layering objects at a higher depth around the border, like a picture frame or dashboard.

Collision detection on both edges of the border

To compliment the iw_draw_self_wrap() function, I’ve added a new collision function, iw_collision_wrap(). This function checks for collisions at the four places occupied by the four drawings drawn by iw_draw_self_wrap(). There are actually two iw_collision_wrap() functions.

The more basic, iw_collision_wrap() sets five instance variables in the calling instance to store the id of any instance in collision: other_center, other_up, other_down, other_left, and other_right.

The more advanced, iw_collision_wrap_map(), returns the id of a ds_map, which holds those same five instance variables as keys, which you can access using ds_map_find_value().

Which to use is up to you, and the style of programming you prefer. iw_collision_wrap() is easier to use, and if you don’t mind the instance variable names, is probably slightly faster at runtime. iw_collision_wrap_map() is for programmers who get pedantic about “correctness” and want their functions to return something, not cause side effects in the application state. Since it’s not possible in GML to have a function return 5 separate values, we return a data structure that stores the five values. The downside of this is that you have some overhead, namely a need to clean up the ds_map when it is no longer needed. Fortunately, it’s not hard. The example project will demonstrate how to do this properly, so don’t worry.

iMprOVE_WRAP is available at the YoYoGames Marketplace for $2.99; however I am making it free for the first 10 downloads. Please rate it and review it if you give it a try!


scrollsnap extension for GameMaker: Studio

My latest GameMaker extension, scrollsnap, is published!

Asset listing at the YoYoGames Marketplace


Demo video:

What’s scrollsnap?

Scrollsnap is a way of setting up a View in your room so that it “snaps” to the next screen’s worth of space when the followed instance moves outside the view. Simply put, it’s a view that stays put, but if you walk off the edge of the view, the view updates, giving the appearance that you walked off the edge of one screen and on to another.

Old-school video games such as Adventure, Pitfall!, and Berzerk used this approach to provide a larger game world to explore and play in, before programmers figured out how to make the hardware support scrolling.

mmap mini maps is back in the GameMaker Marketplace

I’ve re-published the mmap mini maps over at the GameMaker Marketplace. The new version, 1.1.6, fixes the bug of the missing mmap constants — this time the right way, replacing the earlier workaround that I had supplied a few days ago.

Building the asset package the way I needed it was not obvious, but with the help from some GameMaker Community Forums users, I was able to learn the correct method to get the constants added to the package.

Two ways to build a Marketplace Asset

GM:S has two ways to build an Asset.

The more visible method of the two, and the one I had used at first when building my Asset, is to use the Package Manager, located in the Marketplace Menu.

Using this method, you can only build an asset which includes “project resources” — Sprites, Sounds, Backgrounds, Paths, Scripts, Shaders, Fonts, Time Lines, Objects, Rooms, or Included Files.

NOT include-able are Extensions, Macros, Game Information, or Global Game Settings. It’s a good idea to understand the rationale for not including these, and how YYG intends for GM:S users to work around these limitations:

  • It makes sense not to be able to include Extensions, because building an Asset is building an Extension, and Extensions are not designed to be nested.
  • Macros cannot be included, but I’m not clear on why. Perhaps because it’s not easy to separate built-in Macros such as GM_version and GM_build_date, and importing these would create conflicts?
  • Game Information is a deprecated legacy feature which YYG seems to be phasing out. No longer can Game Information be displayed at runtime when a game is playing. So it really only serves to exist as a readme file that you can access from within the GM:S IDE, when working on the project. The same information you might put in here is better added to an Included File.
  • Global Game Settings includes a number of fields that are developer-specific, and should not be shared, such as advertising account credentials, Facebook App ID, etc. There are some settings that would be nice if they could be included in an Asset package, such as HTML5 graphics settings, and options for Use New Audio Engine and Short-Circuit Evaluations, but if your Asset depends on such settings, the only option is to document that in your user manual so that users of the Asset can be informed of how they will need to set up their project.

The other way to create an Asset for the marketplace is to build an Extension. Right click on the Extensions folder in the Resource tree of a project, and Create Extension. Then right-click the newly created extension and Add Placeholder. The purpose of a “placeholder” is vague, but what it allows you to do is define Macros which reside at the extension level,which is done one at a time, in an interface that is different from the project-level Macros editor, and even more of a pain to use.

You can also add Functions to the Extension placeholder. You can add a code file, such as exported scripts in .gml format, or a .dll, .js, .dy-lib, etc. and then define Functions which hook up to the code file.

Once the Extension is defined, you can create an Asset out of it, by logging into Marketplace, and then right-clicking the Extension, and choosing the Create Asset Package option. Creating the Asset Package this way is much the same process as creating an Asset Package from the Marketplace menu, with the exception that the Extension that you right-clicked on will be included with the Asset Package.

Why there isn’t a simple way to include an Extension in the Package Manager build process, I don’t know. I guess the answer ultimately is that this is a new feature in GameMaker, and still in beta. The UI design is rough, inconsistent and not as obvious as it could be. Hopefully this will be addressed as the features are refined. But, for now, it is what it is, and game developers who use GM:S will just need to be aware and familiarize themselves with the differences between these two methods of building an Asset Package.

mmap mini maps asset temporarily withdrawn from GameMaker Marketplace

Well, they SAID it’s in beta.

I’ve been struggling with updating my mmap mini maps asset pack in order to fix a bug that I discovered with it. Since I’ve been unable to do so, I’ve elected to temporarily withdraw the product, rather than continue selling a broken asset. I’ll have it back up as soon as I can get it fixed, but I don’t know how long that may take, due to problems I’m having with the tools.

First, the bug. In the mmap mini maps package, there was supposed to have been a collection of Macros (what used to be known until recently as “Constants”), which I used to assist with programming the Mmap object. When I built the Asset Package, I failed to realize that these Macros did not get included. Without the Macros defined, the project doesn’t work.

One workaround would be to add the macros manually. They are documented completely in the user manual that I wrote. I can also furnish a .txt file that can be imported, to save the data entry. If I can’t get the tools to cooperate, that may end up being the solution I go with for the short term.

It was not obvious due to the way the package builder works, and I didn’t notice it in testing because I tested it by bringing the package into the same project that I had used to build it in the first place.

Lesson learned: Build the package in one project. Import the package into a fresh project to test.

Betas gonna beta

When you build an asset package in GameMaker: Studio, you start by taking some project that you’ve been working in, and then going through the Marketplace Package Manager to build a Marketplace Asset using resources from the project. However, the interface that YoYoGames have built is still very beta. It is unstable, resulting in error messages and crashes. But the greater issue is that the design of the interface, and the workflows it supports, is also rather poor and unrefined at the moment.

When you build your Marketplace Asset Package, you are presented with a Package Builder that allows you to select resources from the project and add them to the package. But the resource selection options are not complete. You can’t select Macros. They just aren’t even there.

So how do you add Macros to a Package? By adding them to an Extension, supposedly. There’s an Extension Builder built into the GM:S IDE, as well as this new Marketplace Package builder. I’m presently unclear as to the relationship between Extension builder and Package builder, but the end result of a Package is that you get a package that is ready to be uploaded to the Marketplace as an Asset, and when you download Assets that you’ve purchased from the Marketplace, it installs itself in your Library, where you can add it to a project, where it… becomes an extension.

The Marketplace asset-extension has whatever resources you had added to the Package — sprites, scripts, objects, sound effects, fonts, included files, timelines, shaders, you name it… just no macros.

But if you build an GMEZ extension using the Extension Builder interface, things are very different. I can create an Extension, add a “placeholder” to it, where I can define Macros (one at a time, which is horrible, like each Macro is its own asset in the tree), and I can add a code file, which can be .gml, javascript, a dll, a dy-lib, or java. And I can define Functions which access the code residing in the code file, providing an interface between GM:S and the functions provided by the extension.

And the documentation shows a similar resource picker for handling both importing resources from a completed Extension into the Project, and for moving project resources into an Extension that you’re authoring. But, for some reason when I am in the Extension Builder, it’s one-way only, I can import from the Extension to the project, but not from the project to the extension.

So when I build an Extension, the only things I can put in it are Macros and Functions and Code files. And when I build a Package, the only things I can put into it are project resources other than Macros and Extensions. So I can’t add Macros to an Extension, then add the Extension to the Package. And I can’t add project resources to the Extension Builder. So there’s this impasse that I can’t figure out how to work around.

It could be the documentation is just out of sync with the version of GM:S I’m running, or it could be there’s some serious design bugs in GM:S currently, or it could be I completely misunderstand both the documentation and the user interface, and am missing something that will become apparent to me eventually.

I’m a bit frustrated now, and very tired of banging my head against a wall trying to figure out how to make it work, so I need to step away from it for a short bit.