-
Notifications
You must be signed in to change notification settings - Fork 0
Setup
Setting up FrostJolt for your GameMaker Project is fairly simple. All we need to do is change some macros and add some objects, and you'll be ready to start using FrostJolt to spice up your game with Game Jolt's Game API!
To start, we need to tell FrostJolt what game it will be making calls for. To do this, look for the ext_frostjolt
Extension in the FrostJolt Library Folder. This was automatically imported alongside the rest of the library when you imported the Local Package.
When you get inside that Extension, it should have a number of Extension Options.
All of these options control how FrostJolt will behave at runtime and how it will send and log requests and responses. For now, we only need to focus on the first two options: Game ID and Private Key. Both of these are located on your Game's Dashboard under Game API >> API Settings. (Note: All of these options have different tooltips that you can view by hovering over them with your mouse cursor.)
Warning
It's important to know that you should NEVER give your private key to anyone! Your game's key is used to validate that API requests are coming from your game. If any third parties get a hold of it, they can send in fake requests pretending to be your game.
Copy and paste your Game ID and Private Key into their respective extension options, and you should have something that looks like this:
The last thing we need to do to finish setting up FrostJolt is to add the obj_gjloader
Object into our starting room. If you do not know what room is
your starting room, it will be marked with a House Symbol.
(rm_level is the starting room in my case, but it will be different for you)
Go to the gjloader object and mark it as persistent. This way, when we switch rooms, it wont be destroyed.
Lastly, place the gjloader object into your starting room.
Congratulations! You have successfully set up FrostJolt with your GameMaker Project! From here, it's recommended to check out pages that go more in-depth on FrostJolt's other Functions. Before you do however, keep these few things in mind:
-
All responses are stored in a Global DS List as a Backlog. This variable is named "fj_response_backlog". If you need to access a previous response, check this DS List.
-
Remember that DS Lists are Dynamic Resources, so they do NOT destroy themselves at the end of a room or game session. Luckily, FrostJolt comes with a function to destroy all Data Structures that it uses. "fj_deinitialize". Run this in the Game End event. This is automatically run at the end of the game for you by the Extension, but for some platforms it may not work as you expect. In this case, you should run this function in the Game End event if you are affected by this issue. See the following from the GameMaker Manual:
Note
All platforms support the Init function call, but not all platforms will perform the Final function call. This is because certain platforms will simply close the app without giving any notice or time for this function to be called. The platforms mostly affected by this are iOS, Android, HTML5, PlayStation and Xbox.
-
Keep in mind that running fj_deinitialize will destroy the backlog, essentially erasing all of your saved responses! Make sure there's nothing you need for another session in that backlog before running this function.
-
Be wary that the server may refuse to accept your request for different reasons, ranging from sending too many requests in a short time span, or missing parameters.
-
The response will be spat into the Output Console of GameMaker, and stored in different variables. If you have a custom in-game Developer Console, you can alter the code to make it log the response in there too!
-
Lastly, do not spam the API with requests! It may choose to kick you out of it temporarily or block you from sending requests entirely.