Tips and Tricks

This page is a collection of notes to bear in mind when making games with PGMMV.

## Improving performance

* Pressing F1 and selecting Show Simple Draw Load from the Debug menu will show the FPS of the current game.
* GL verts is the number of vertices in the scene. Vertices make up a triangle (3 per triangle) which are used to render sprites. GL calls is the number of draw calls to the GPU. For medium-to-high end PCs, a GL Calls count below 80 should provide FPS at least above 50. GL Verts and GL Calls are generally not affected by the size of the sprite being used.
* Every 32x32 tile or object added to the scene, devoid of graphics or not, adds 6 GL Verts. Adding tiles to the scene does not increase the GL Calls count, irrespective of the number of tiles added to an individual layer. However, adding even a single tile to a new scene layer increases the GL Calls count by one; this number goes up for every new tileset used on the scene, whether Basic or Gimmick. Therefore, it is best to restrict specific tilesets to specific layers or use a single tileset wherever possible.
* Enlarging a 32x32 object by any amount does not change the amount of GL Verts or GL Calls it uses.
* Every instance of a simple object with RGB sprites when placed on the scene normally adds 1 - 2 GL Calls to the total GL Calls.
* Filters on objects or scenes have a relatively large performance hit. For instance, applying a colour and opacity filter to a layer in the Scene Settings can up the GL Calls count by at least two units.

## Scenes

* Applying a filter to the topmost layer in a scene will apply the effect to the entire screen, but applying a filter to other layers will apply it to the tiles present on the layer.
* Platforming cannot take place inside a Menu scene in a side-view project because wall detections will be ignored.

## Animating

* You can reduce the number of frames needed for some actions such as rotating objects, or stretch-and-squash by using interpolation in the animations tab.
* Enlarging an object in the animation will also enlarge its collision and wall detection boxes.
* You can bypass the Resource tab to import an image by simply clicking 'New' when adding a resource to an animation. It will automatically import the image and name it.
* Multiple spritesheets can be associated to the same animation and not all sprites need to be on the same spritesheet for them to be accessible by a single set of animations. Similarly, different versions of the same animations can be associated to a different animation set through the Animation Settings.

## Eventing

* Some child objects will not disappear when the parent object is destroyed and require their own destroy logic.
* The same object may have different unrelated logic trees and be used as different objects if the default action is changed on scene.
* The "maintain state at end of scene" function accessible in an object's Basic Settings does not apply to generated objects. If the object generating the object that should be persistent is stationary (such as a treasure chest), this may be circumvented by making the stationary object generate a field of view when triggered; the FOV will then be set to act as a trigger for the object of interest to make it visible and accessible by the player. In this case, the object of interest is already placed manually in the scene.
* To make a flexible switch and door you may set the door object to open if it is locked by the switch, and close if the switch is released. The door object will have a custom variable ID. The Switch object will need to be set to lock the door object if the door's custom ID is equivalent to a variable X, that may be changed on the scene. This allows the creation of multiple lock/switch relationships on the same scene with only two objects.
* FOV can be activated between different layers.
* For creating cutscenes, you can make use of the "move object" runtime action to move an object to location. For side-view projects, to make simulate objects moving along a platform set the vertical speed to zero so that the object does not appear to float. You can trigger the next event box when the object reaches its destination by setting a Gimmick Tile that changes the object's Area Detection variable. Set this variable as a trigger to jump to the next event box and trigger other actions.

## Tiles

* In version 1.0.5.5, changing a gimmick tile will make the new tile inherit the properties of the parent tile, therefore any colour changes or opacity effects will be transferred to the changed tile.
* For making moving platforms, these need to be objects on a path (not tiles) with wall detection for both the player and the platform object enabled, in the object settings. To make so that the player moves when standing on the platform, the player's "not pushed back by other objects" checkbox needs to be unchecked.

## Variables and Switches

* Objects and their variables / switches get reset on scene transfer unless "maintain at end of scene" is being used for the specific object.
* Objects connected to the player get generated anew at each scene transition, therefore their variables and switches will also be reset.
* In general only the player's switches and variables are conserved in-between scenes.
* It is best to set important switches and variables as Common switches and variables if these need to be conserved in-between scenes, such as for gaining skills, unlocking doors, keeping track of score, etc. This prevents their value being changed or set to default on scene transfer.

## Other items

* The Object Searchbox in the Objects tab is case sensitive.
* When layers are set with a scrolling speed below 100% their position might change automatically when exiting and re-entering the same scene. To prevent this the scene should be set with the camera position starting from the lower left corner in a side-view project.

## Optimization (lightweight)

Things that consume performance, listed in order.

* **1. Unlimited loop script**

The infinite loop script is the scariest resource monster, try not to use infinite loop.
If necessary, please add the switch variable to limit, or increase the delay time.

* **2. Too many scene objects**

Once there are too many objects on the scene, it will start to slow down.
Be sure to add recycling and destruction mechanisms to all objects, and don't let useless objects exist on the field.
You could try to use any of the following object recycling mechanisms:
i. Completely eliminate: bullets, objects that are no longer useful,
ii. Hidden display: non-enemy objects,
iii. Empty object transformation: enemy.

* **3. Physical operation**

Although it is not a problem to use it alone, once you put it in the game and other things together,Physics obviously slows down the game. Unfortunately, this thing consumes resources.
Even if I really like the physical effects, I have to delete a lot and only leave some.

* **4. Display after image / after-image**

This feature is unexpectedly quite performance-consuming, please use it with caution.

* **5. Create objects / bullets**

This is only at the moment of creation, it will slow down, and lightweight images will help.

* **6. Excessive number of particles**

Although too many particles will cause slowdown, as long as the total amount is controlled not too much,
The particles of PGM are unexpectedly lightweight and will not cause too much burden.

* **7. Too many nodes running at the same time**

Nodes that are not running consume no resources, while those that are running,
For the same AI, fast running is more resource intensive than slow running.
This is also the reason why the script should not loop indefinitely, and add conditional restrictions or delays.