Pixel Game Maker MV

Pixel Game Maker MV

46 ratings
The Mechanics behind Saving and Loading in Pixel Game Maker MV
By Maxim
In the beginning, I struggled with how to get saving and loading working properly in Pixel Game Maker (PGM).
After some time of playing around with it, I finally figured out the mechanics.

I want to share my discoveries with people who are struggling to get this working
and present a step by step guide to get it done.
I envision this as an ongoing guide to eventually evolve into creating a working title screen
and save system with multiple save slots from scratch.

Change Log:

1/23/2020:
-Added supplementary video explanation.

12/13/2019:
-Updated branded image.

11/24/2018:
-Added section on creating a multi-slot save system. (Chapter 3)

10/17/2018:
-Start of the guide.
-Basic Mechanics are explained. (Chapter 2)
-Basic Save and Load In Game Explained. (Chapter 2)
3
   
Award
Favorite
Favorited
Unfavorite
Foreword
Creating the save system in PGM is fairly straightforward in concept. You take all flags and variables that you want to save at that present moment in time and simply "save" them using a switch. My goal is to help everyone set up save systems quickly with the default built in system. At the same time, I'm using this as an opportunity to learn more about the software myself.

I'm merely presenting the way I currently do this. There may be different ways to do this that I haven't thought of. Either way, onward with the guide!
Chapter 1: Pixel Game Maker Interface Basics


Before you get started on working out how to get saving and loading working properly, It's highly recommended to at least skim over the help manual in some capacity. I'll cover some of the basics of the PGM interface (in no specifc order) you need to know in order to get started with this.




Objects
Objects are the basis of how things in Pixel Game Maker works. This area allows you to create interactible events and much more. If you're familiar with RPG Maker in any capacity, think of this are as the place where you create "events". Want your main character controlled by the player? Want enemies? Setting up the save system will involve work here.



Scenes
Scenes are where the action of your game will take place. These are where your game world exists.
If you are familiar with RPG Maker, this is the map screen.



Animations
This is where you're going to set hitboxes for your animations as well as setting up their motions.



Resources
This is where all your images are inserted and organized into your project.



Transitions
This controls the flow of scenes. Essentially, this is how the player will be taken
through various areas.

Get familiar with the above areas, as we'll be using them to set everything up.
Chapter 2: Basic Save and Load System
The following sections here in chapter two is dedicated to breaking down the process and giving you a working example to use.

I've made some simple save and load icons for the purpose of this tutorial. You can grab them here:
Load Icon[drive.google.com]
Save Icon[drive.google.com]

Additionally, if you want to directly follow along step by step (to also save some time), I used the demo project "[material]Explorer 女探検家素材" created by @Dot_Zo_Games in PGM version 0.8.7 as the basis of me setting things up.
Chapter 2-1: Adding Resources
With the save and load icons obtained in the previous section (or you can use your own), Import them into the project via the "Resources" section. You'll need to play around with the Horizontal and Vertical values of the sprite sheet's values in order to have the resource import correctly. The save and load icons I created are to be imported as images.

Examples of the Image setups:



You'll notice that there are variables and Switches (also known as flags) that you can add, modify and remove. The majority of the default flags (player position, etc.) are set to be saved each time you save the game. However, when you're adding variables & switches to the project, you can also specify them to not be saved by enabling the check mark, "Don't Keep on Game Save". Below is an example of one of those "default" variables and this cannot be excluded from saving.

Chapter 2-2: Setting up and Creating Animations
Initial Preparation

Now that we've imported our images, let's get these icons animated. Head over to the Animations area and import a new animation by right clicking the file tree and select "Add Animation".



Next, you'll be brought to the "Animation Settings" screen. Name the animation "Save/Load". Make sure this animation is set as a "Motion Animation". Then click the "+" icon to add one of the images to this animation.



Next, you'll be brought to the "Resgister Resource" screen. In the "Images" dropdown, select your save icon image.



Once done, this will add the icon to the list. To save space, we're also going to repeat the above last steps starting from the "Animation Settings" screen to add the load icon image. Below is a screenshot of what this should look like (I edited a previously setup animation).




Creating the Animations

Now that we have the animation images set up, we're ultimately going to create two motions. I like to save time where possible, so we're going to create the save icon motion first, and simply copy it to create the load icon animation afterward.

You'll notice that animations are divided on the right between "Motion", "Direction" and "Frames".

In the motion section, make sure you set up your frame count to display and loop count as desired. If you're using my resources, simply copy the below settings and ensure it's named "Save Disk".



In the direction section, configure the settings to what's desired. If you're using my resources, simply copy the below settings (to ensure that we're selecting the proper resource for the motion.



In the frame section, click the "+" icon to make as many frames as needed for the animation and then use the section "Select Image for Frame" to select the appropriate image to be displayed in that frame. If you're using my save and load icon images, frame 1 starts in the upper left part of the image in the top row and frame 7 (the last display frame) in the second to the right of the second row.





After you're finished, you can simply copy and paste the motion for the save disk and create the "load" disk. From there, all you'll do in go through and swap the images out from the direction and frame areas. In the end, your animation should be setup as such:

Chapter 2-3: Creating The Save and Load Objects
Here's where the setup and execution of saving and loading comes into play. From this point, we're going to focus on how to set up the "save point" object. Setting up the "load" object will be similar but there are key differences that I'll explain later in this section.

Setting up the Objects and Nodes

Head over to the "Objects" area and right click in the file tree on the right and select "Add Object".



In Object settings, do the following:
  • Set the name of the object.
  • Select the animation we created in the previous section.
  • Set the Object Type as part of the "Player Group".
  • Attack Settings doesn't matter since it's a save point.
  • Enable all Wall Detection Impact Settings.
  • Don't enable it to be controller by an input device.



For the next part, we'll need to create the nodes. If you're familiar with RPG Maker, think of nodes as pages of an event. Right click in the empty space and select "Add Action" to create a node. You're going to create 2 nodes; I named mine "Save Idle" and "Save Active".

Click on "Save Idle" and on the right you'll have options. For "Select Motion to Assign", assign the object the Save Disk animation. Scroll down near the end and you'll see "Runtime Actions" and "Other Runtime Actions". For Runtime Actions, you're going to check off "Not Affected by Gravity" and leave it at 100%.



Next, click on "Save Active". For Runtime Actions, you're going to check off "Not Affected by Gravity" and leave it at 100%. In the "Other Runtime Actions" Area, this is where you'll set your flags and variables to save the game.

Click the "+" Icon to assign a new action under "Other Runtime Actions".



In the Other Runtime Actions window, you'll want to head over to Page 2 at the time of this writing. The option you're going to use the most here is "Change Switch/Variable".



Use the radial selection to place it on "Change Variable". Right below that, you'll have some options for where you want to draw the variable from. Select your project name. Mine is called "Save Project Common". In the next drop down below, locate "File Slot" and select it. In the "Constant" field, just put in "1".



Afterward, you'll just make a new "Other Runtime Action", and follow the steps above. Except, you're going to choose "Change Switch", and select the "Save File" switch and set it to "On"



I also made a message event that signified that the game was being saved. This is optional, but highly recommended.


Creating and configuring Links between nodes

You'll want to left click on your "Save Idle" node, and then right click it to see the option to add a new link. This will then draw out a line for you to connect nodes. Simply left click on the "Save Active" node to connect the links. Repeat this step except you'll start by left clicking, and right clicking on "Save Active". Your nodes should be connected and look somewhat similar to the below image.



Notice how the arrows point to each respective node? Click on the node pointing to "Save Active" and you'll see the following settings.



Think of these links as triggers to activate the various nodes you set up. We're going to set this up so that when you press the "A" button (or X if you're using a PS4 controller) near this object, it will trigger the save event. First, change the "Condition to Change Actions" selection to "Change if All Conditions are Met".

From there, go to "Input Related Settings" and select "The Following Has Been Input". Then click the "+" button to open the "Input Condition" window. Select "Control Key for Input". Select the "A" button (or X if you're using a PS4 controller). Then in the sub-option next to it, select "Pressed". In my example, the sample project mapped an "Ok" action to the A Button. So, I just used that. Click "Ok" when finished.



Next, head to "Other Condition Settings" and press the "+" button. We're going to make sure that this Save point can only be used if you're near it.

From the "Other Condition Settings" window, head to page 2 and select "Distance with Other Objects". Under "Set Direction and Distance from Other Objects", leave "Other Than Specified Direction" un-checked; And select "Distance From Detected Attack" while leaving all arrows green (enabled). (You can also select "All Directions".)

For "Distance with Other Objects", select "Set Distance" and set it to an appropriate dot (pixel) count for your project, then select "Less Than Specified Distance". The sample project's tilesize is 16x16 at a resolution of 384x288. So, setting it to less than 30 works for me in this project. Finally, under "Set Other Targets", select "Set by Object" and through the dropdown list, select your player character.



For the link that connects over from "Save Active" to "Save Idle", you're only setting 1 condition. Go to "Input Related Settings" and select "The Following Has Been Input". Then click the "+" button to open the "Input Condition" window. Select "Control Key for Input". Select the "A" button (or X if you're using a PS4 controller). Then in the sub-option next to it, select "On Release".


Setting up the Load Object

The majority of setting up the Save Object applies here. Except, you should name your nodes "Load Idle" and "Load Active". Then in the "Load Active" node, ensure that you set the "File Slot" to the appropriate one, and use the flag "Load Game" instead.
Chapter 2-4: Placing the Objects in the Scene
For this next part, we'll place the Save and Load objects in the scene. The scene can be divided into many layers. For best results, you should place these objects on the same scene "layer" as your player character.

Select the scene and layer you want to place these objects. Then select the "Object" tab up top.


Next, click on the Save Object you created and place it on your scene using your mouse cursor. Do the same with your Load Object.


And, that's it! Save your project and test play and try it out!
Chapter 3: Implementing a multi-slot Save System with a Title Screen
So, now that we have an idea of how the save system in PGM works, it's now time to implement these ideas into a working save system. I will warn that this section will assume you have some familiarity with the program as a whole. So, I won't be re-explaining certain functions (like how Objects, and the like work), but I will go over anything that wasn't previously covered.

Things you're going to need to have together is a Title Image ready to go for whatever resolution your game is going to be. You're also going to need graphics to represent the various stages of selecting an option (New Game, Continue, etc.).

Additionally, to help ease certain aspects, I'd recommend importing the plugin "Show Choices" through the plugin menu (right click, select "Add Official Plugin"). I'd also recommend making a new variable "Game Selection" in your resources area so you have something to track for player selections to push a new scene; More on that later.

Also, again, I will note that this is how I've implemented this system. There may be more efficient ways to do so.
Chapter 3-1: Creating the Title Menu Selections via Animation
Creating the title menu selection is done through animations and objects. You'll need to set up your animation for selecting different aspects of the menu beforehand.

For example, I created a quick sprite sheet that contains the options for "New Game", "Continue" and "Exit" and created an animation first using that sprite sheet. It's nothing complicated as we're just going to use each selection as a constant 1 frame animation. Depending on your design needs, you might want more (and design more) for a flashier selection.

Animation Example:


Chapter 3-2: That section about the "Show Choices" plugin.
The "Show Choices" plugin is a plugin made by the PGM developers to provide a similar functionality to the "Show Choices" option in RPG Maker. Though this does have some differences from RPG Maker that I'll dive into here (so that way other sections aren't bogged down).

Object Runtime Actions

Once the plugin is loaded into your project from the "Plug-ins" menu, you can access the functions of this plugin via "Other Runtime Actions" whenever you create a new runtime action. You'll see this plugin and it's functions in the "Plug-ins1" tab.



From here, you can set up the text for each of the 6 choices you can display at once. You can set the font to be displayed (if you loaded your own fonts there), what sort of background you want to display for the choices, screen position of those choices, and if you can use the "Cancel" button to make the screen go away or not.

Object Link Conditions

To make an action occur based off what choice was selected, the Object Link option for "Choice Selected" can be used to acheive this. You can set the link to activate the next node based off the choice selected. Of course, if you select choices that don't exist, then it goes no where. So, be careful when setting choices up.

Chapter 3-3: Title Object Design
You only need one object to create this menu and the load handling needed. Near the end of this, your Object will look something near to this:



However, this is all based on personal organization of this object. If you want to follow along, you can use the above to keep track.
Chapter 3-4: Initial Menu Selection Design
So, before we even get started, we need to setup the menu and make it work properly!

Create 3 nodes for each selection, and assign the animation for said selection for that node (Select the "New Game" frame of your aninmation and so on).



Object Animation setting Example:


Between each node will be the links that will help cycle through the options based on controller input. Since I want my menu to be controlled by cycling through the "Up" and "Down" directions, I've set the links between "New Game" > "Continue" > "Exit" to the follwoing condition parameters:



For "Exit" > "Continue" > "New Game", I've set the condition parameters to the opposite direction.

Chapter 3-4: Creating the "Exit Game" Object Node
We'll start out light.

Create a new node called "End Game". Inside of the node, you don 't have to set an animation to it if you don't want to. However, you will need set the "Other Runtime Actions" to call the "End Game" flag command and set that flag to "On". This will shut the game down for the player.



Next, you create a link between the "Exit" node and the "End Game" node and set the condition that the "A" button (or whatever button you want) is pressed while "Exit" is displaying.

Chapter 3-5: Creating the "New Game" Object Nodes
In this chapter, we'll cover how to setup the handling of starting a new game. We'll have the player select a save slot they'll want to lock themselves to for this save file.

Group Boxes

Before you begin, I highly suggest making a node group or "Group Box" to organize things. Right click anywhere in the grid and select the option "Add Group Box".



Once done, you can rename the group box on the right to whatever you want. You can also register nodes via this menu as well (or simply add them by dragging them with the mouse).

Save Slot Selection Node setup

With that out of the way, create a new node. I named mine "New Game: Select Save File". For the other runtime actions, I set the following:



I use "Show Text" to essentially show a dialogue box and "Show Choices" to provide the slots the player can choose to have their game save into for that particular save session. I've set up 3 options to display 3 different slots and a choice to go back to the initial menu.



Since we're creating 3 Slots, create 3 additional nodes named "New Slot 1", "New Slot 2", & "New Slot 3".

Save Slot Node Setup

With the 3 Slot nodes we created, we're going to set up the following runtime actions for each one:



We're setting the "File Slot" Variable to the appropriate file slot per the choice the player makes. So, if they select "Slot 1", then we set the variable to "1", and so on.

Game Start Node Setup

Create a "Game Start" node with the following parameters:



With this node, we're setting our "Game Selection" variable to "1". That way, we can use this to trigger the new game.

Chapter 3-6: Creating the "New Game" Object Links
We'll tie everything together for the New Game Object nodes here.

Link: "New Game" > "New Game: Select Save File"

This link will activate when the "New Game" option is selected and the player presses "A" under the input related condition settings. The conditions to change action can be set to "Change if all conditions are met".

Link: "New Game: Select Save File" > "New Game"

This link will activate when the "Cancel"/"Back" choice is selected and the player selects the option. Here, you set the condition settings to "Choice selected", and it's activated when the "Cancel"/"Back" choice is selected. The conditions to change action can be set to "Change if all conditions are met".

Link: "New Game: Select Save File" > "New Slot x" (1, 2 or 3)

These links will activate when the appropriate save slot choice is selected by the player. Here, you set the condition settings to "Choice selected" for whatever save slot is to be selected. The conditions to change action can be set to "Change if any conditions are met".

Link: "New Slot x" (1, 2 or 3) > Game Start"

These links will activate when the appropriate save slot choice is selected by the player. Here, you set the condition settings to "Choice selected" for whatever save slot is to be selected. This will essentially continue on after setting the File Slot to the appropriate choice and then start the game. The conditions to change action can be set to "Change if any conditions are met".

Your links should look something like (or close to) this when finished.

Chapter 3-7: Creating the "Continue" Object Nodes
Setting up the save slot selection for the "Continue" option is similar to how we created the "New Game" node, with some additions. Basicallyu, we're going to create some handling for when there's no save file that exists to load from and start everything again.

Save Slot Selection Node setup

With that out of the way, create a new node. I named mine "Select Existing Save File". For the other runtime actions, I set the following:



Again, I use "Show Text" to essentially show a dialogue box and "Show Choices" to provide the slots the player can choose to have their game save into for that particular save session. I've set up 3 options to display 3 different slots and a choice to go back to the initial menu.



Since we're creating 3 Slots, create 3 additional nodes named "Slot 1", "Slot 2", & "Slot 3".

Save Slot Node Setup

With the 3 Slot nodes we created, we're going to set up the following runtime actions for each one:



We're setting the "File Slot" Variable to the appropriate file slot per the choice the player makes. So, if they select "Slot 1", then we set the variable to "1", and so on. Following that, we're turning the "Load File" switch to "On" to have PGM load the appropriate and selected file slot.

No Save File Exists

PGM will fail to load a game file if the file slot selected has no save game to pull and load the data from. So, for this Node, we have a simple Show text event to display a message to the player telling them there's no save file to load from, then a delay, and then we set the "Load File" switch back off.

Chapter 3-8: Creating the "Continue" Object Links
Again, a good amount of what was covered for the "New Game" links will apply here with some changes.

Link: "Continue" > "Select Existing Save File"

This link will activate when the "Continue" option is selected and the player presses "A" under the input related condition settings. The conditions to change action can be set to "Change if all conditions are met".

Link: "Select Existing Save File" > "Continue"

This link will activate when the "Cancel"/"Back" choice is selected and the player selects the option. Here, you set the condition settings to "Choice selected", and it's activated when the "Cancel"/"Back" choice is selected. The conditions to change action can be set to "Change if all conditions are met".

Link: "Select Existing Save File" > "Slot x" (1, 2 or 3)

These links will activate when the appropriate save slot choice is selected by the player. Here, you set the condition settings to "Choice selected" for whatever save slot is to be selected. The conditions to change action can be set to "Change if any conditions are met".

Link: "New Slot x" (1, 2 or 3) > "No File Exists!"

These links will activate when the appropriate save slot choice is selected by the player. Here, you set the condition settings to "Choice selected" for whatever save slot is to be selected. If the file slot has no save data to load, then this will continue onto the "No File Exists!" node. The conditions to change action can be set to "Change if all conditions are met".

Link: "No File Exists!" > "Select Existing Save File"

This link will activate when the node has been activate due to the lack of a save file present. Here, you set the condition settings to "Switch/Variable Changes" and set it to activate when the "Lad File" switch has been turned off by the "No File Exists!" node. The conditions to change action can be set to "Change if all conditions are met".

When finished, your nodes should look something (or close to) the following:

Chapter 3-9: Creating a Title Screen, then setting the Transition
To create a title screen, you'll need to create the appropriate Scene and then place your Title Options Object there.

Once your appropriate scene has been placed, go to your "Transitions" area. You'll need to ensure that the link between "Start" and your title screen is established. From here, create another link from your Title screen to the first area of your game. Your link settings to your starting area should be something like this:



This way, the change of the "Game Selection" variable will trigger the change and then you can officially start the game! From here, you can establish save points and the like for the player to save the game. If you're really savvy, you can enable a menu for them to save whenever they want.
Conclusion
I hope I was able to help some of you out there who might be struggling with understanding how to set up a proper save and load system inside your games.

Please leave a comment below if there's anything you'd like me to try and cover that I haven't stated that I would cover in the future, or is currently missing from this guide. I always appreciate constructive feedback.

If you liked this, consider pursuing my work and other projects on my various social media accounts! Thank you for reading.

Abstract the Origin - Social Media[linktr.ee]
BONUS: Supplement Video
Here's a YouTube video to accompany this guide to give you some "visuals".

7 Comments
Maxim  [author] Aug 10, 2020 @ 5:33pm 
You're quite welcome, 碧蓝千雪!
ZyphyrX Aug 10, 2020 @ 7:26am 
Thanks for the guide!
Maxim  [author] Jan 9, 2020 @ 5:45pm 
Thank you, Hyblitz!
hyblitz.s Jan 9, 2020 @ 5:42pm 
Very useful guide big up to you Abstract keep it on !!
Maxim  [author] Jun 30, 2019 @ 10:57am 
You're welcome. :) I'm glad this helped.
转塘你宇哥 Jun 30, 2019 @ 8:41am 
thanks!!!!!!!
转塘你宇哥 Jun 30, 2019 @ 8:41am 
so uesful!!!!