Simple Online Content in GameMaker using text files
One way to connect with fans of your game is to add simple online content that changes from day to day. Today we’re sharing how to do that in the most basic way in GameMaker.
By using the http_get function and some carefully placed text files on your website, you can make your game feel more alive by adding things like:
- Automatic version checking, to notify users of new updates
- A news feed showing the latest updates from your website
- Downloadable levels and other text-based content
For this example, create a single object and place it in an empty room. Then add the following code:
The Create Event
Here we’re just going to set up some variables for using later, and then set off an alarm to trigger the online checks.
// The current version of the build of the game that you could update each time you make a release
current_version = 1.0;
// Some placeholder text to show the connection status
connection_status = "Loading... ";
// Some information we're going to grab from our online text files
newest_version = current_version;
current_news = "";
// Set some default values for our http requests to avoid crashes
request_version = -1;
request_news = -1;
// Set an alarm to trigger the online checks
alarm[0] = 60;
The Alarm 0 Event
Check if the player is connected to the internet and then use http_get to request some information from your website. You can check the text files we’re using in our example here: version number and news feed.
if (os_is_network_connected()) {
// if the game is connected to the internet, say so and then load the things we want to load
connection_status = "Connected. ";
// Request the latest version number from an online text file
request_version = http_get("https://chequered.ink/nonwp/online/version.txt");
// Request the latest news from an online text file
request_news = http_get("https://chequered.ink/nonwp/online/latest-news.txt");
} else {
// If the game isn't connected to the internet, show an error message
// and then try again
connection_status = "No internet connection.";
alarm[0] = 60;
}
The Async – HTTP Event
Here is where GameMaker listens for the response from the http_get request. This code checks for the result and updates our variables accordingly.
// If this http request was to get the version number
if (async_load[? "id"] == request_version) {
if (async_load[? "status"]==0 && async_load[? "http_status"]==200) {
// The request was successful, update the version number
newest_version = real(async_load[? "result"]);
} else {
// The request failed, show an error message of some kind.
connection_status += "\nUnable to get latest version number.";
}
}
// If this http request was to get the latest news
if (async_load[? "id"] == request_news) {
if (async_load[? "status"]==0 && async_load[? "http_status"]==200) {
// The request was successful, update the version number
current_news = async_load[? "result"];
} else {
// The request failed, show an error message of some kind.
connection_status += "\nUnable to get latest news.";
}
}
The Draw Event
Finally, for this example, we’re just drawing some simple text to the screen to show the result of our online checks.
// Draw the connection status
draw_text(16,16,connection_status);
// Draw the current game version
draw_text(16,96,"Current version: "+string(current_version));
// If there was an update waiting, tell the player so they can go and download it
if (newest_version>current_version) {
draw_text(16,128,"Update "+string(newest_version)+" available");
}
// Draw the latest news
draw_text_ext(16,240,current_news,-1,1280);
The Result

You can see from this extremely simple example how you can use basic text files to connect with your players.
Of course, you can make the system more complex than this. For example, your text file could be formatted as a json or ini file, which could allow the news feed to have separate “posts” like a true blog.
And you can also include content that affects the actual game play, like downloadable levels. If the levels in your game are text-based, it’d be pretty easy to create daily, weekly or seasonal levels to keep your players entertained without having to update your whole game.
We hope you enjoyed this simple tutorial, you can download a full working example from the button below!



