Computer Simulation Template

This is a guide for installing and using the Computer Simulation Template in your own GameMaker projects. Created by Deklaration.

The template mimics a computer desktop environment with draggable windows, resizable folders, scrollbars, and interactive software.

You can purchase the asset from itch.io.

Installing the Template
  • Download the template package from itch.io.
  • Import it into your GameMaker project (via Tools ➜ Import Local Package or by dragging the .yymps into the IDE).
  • There has been a case where this gives you the error message: Cannot find function to change GMAudioGroup version from v1 to v0 If it does, go to tools ➜ project tool and manually convert it there.
  • Once imported, change the starting room to rSetup. It will run the initializing scripts before jumping over to rDesktop.
The demo
  • While the global variable global.demo is set to true, the demo will be active. Run the game and play with the functions.
  • There are two folders and a few icons with different features. There is also an icon called Settings where you can adjust the shader.
  • When you are ready to create your own game, go into the create code in rInit and switch global.demo to false.
Creating an Icon
  • To create a new icon in your game, copy the oBase_icon object and give it your own name.
  • Assign it a suitable sprite. I use FatalBlend's wonderful icon pack in this template.
  • Go to the Create event to find the scrCreateIcon() function
  • scrCreateIcon() will be filled with arguments for you to swap out.
  • This is how it should look: scrIconCreate(name, nextwindow, 0, 0, folder, global.array)
  • Name: argument0. Give it a string to display below the icon. It could be something like "My Computer" or "Secrets".
  • Nextwindow: argument1. Replace this with the object index of the window you want this icon to open.
  • 0: argument2. If you want the window to open somewhere else than on top of the icon, you can change this X value. Swap it to room_width/2 to open it in the middle of the room.
  • 0: argument3. This is the same as argument2, but for the Y value. Swap it with room_height/2 to open it in the middle of the room, vertically.
  • folder: argument4. Is this a folder? If the window it opens will contain other icons, swap this to true. Otherwise, change this to false
  • global.nameArray: argument5. If this is NOT a folder, you can just swap this to 0. It doesn't need an array. If it IS a folder, you have to change this to a global array that you will setup in a second, in the script scrSetupYourFoldersHere. This array will contain the objects the window will create when opened. Give it a readable name, such as global.nameArray. For example global.gameArray
  • If you want the icon to be placed on the desktop, create it in rDesktops Creation code
  • Give the icon these structs: {newparent : oDesktop,parentwindow : oDesktop, oldparentwindow : oDesktop}
  • These are given to all icons from their windows, but since the Desktop doesn't have a window - we'll just add them here.
  • For example: instance_create_depth(96,64,global.depth,oFolder_icon,{newparent : oDesktop,parentwindow : oDesktop, oldparentwindow : oDesktop})
Creating a folder
  • To create a new window in your game, make sure you have an icon. See Creating an Icon for more info.
  • Go into the script scrSetupYourFoldersHere and follow the instructions.
  • In Setup() you will need to create a 2D array for the icons you want to be included in the folder. Use the global variable you used while creating your icon, then add three values to the array for each of your icons. Example: global.games[0] = [oGames_icon,75,120] Begin with 0 and add one for each icon. The first (oGames_icon) value in the array should be the icon you want to create. The second (75) is the X position of the icon within the folder window, and the third (120) is the Y position.
  • Then, create another array for your folder window. Every folder should be included here. Example: global.windows[0] = [oFolder_window,global.nameArray] where the first value (oFolder_window) should be the object index of your window. See Creating a Window The second value (global.nameArray) should be the array you just created.
  • Add to this array for each folder you create.
  • There are examples you can follow inside of the script, to make it easier. But basically, you want it to look something like this: global.games[0] = [oTyping_icon,55,25] global.games[1] = [oPong_icon,151,25] global.windows[0] = [oGames_window,global.games]
Creating a Window
  • To create a new window in your game, copy the oBase_window object and rename it.
  • Now, go to the Create event and look at the function there. scrWindowsCreate(icon,folder,resizable) Change the arguments in this function to create your window.
  • icon: argument0. You will display a small icon in the top left of your window. In most cases, this is the same sprite as the icon object that created this window. Such as, sGame_icon
  • folder: argument1. If this is a folder and will contain other icons, change this to true, otherwise to false
  • resizable: argument2. Should the player be able to resize the window? If so, change this to true. If you don't want the player to change the window size, change this to false.
Creating a software
  • This is the part where you can get creative. Every Computer Simulation game is based on software. In Her Story, it's the video bank. In Atomograd, it's the translator software. In After Hours, it's the email. So on, and so on. When the scrWindowCreate function is set, you can build your own software using this window. Add your own sprite and implement whatever functionality you’d like. You can build games within the window. Calculators, chat programs or whatever you feel like! The template includes a game of Pong and a calculator to show you how it works. This is where you make the game your own.
  • However, there are a few things to keep in mind:
  • Make sure to draw the content using the Draw event within the window. If you're using Draw End event, there might be some depth issues.
  • If you add clickable objects in the software, you need to make them compatible with scrTopInstance That way it's not clickable if it's covered by something. Give every clickable object in the software oClickParent as its parent. scrTopInstance checks for each instance of oClickParent to see which object is closest to the player, and only activates that one.
  • It is activated by turning the variable clicked true. So, you need to add this variable to the object in its Create event and use it however you'd like. For example:
  • if clicked = true { print_message("Hello world!"); clicked = false; }
  • Remember to turn clicked to false again when you're done with it. This can be done either like the example above, or in a End step event See the Calculator object in the template for a more in-depth example.
Creating a Typing Window
  • If you want to include a typing software, either for authenticity, puzzles or note taking, this is easily done. Copy oBase_typing_window object and rename it.
  • Go into the create event to find two functions. Look at scrWindowsCreate(icon,false,resizable)
  • Choose the icon you wish to draw in the top left corner of the window as argument0 and if you want the window to be resizable or not in argument2
  • Leave argument1 as false
  • Now look at the second function: scrTypingCreate
  • First, choose the text you wish to display in the window from the start, as argument0 If you wish to have it empty, change it to ""
  • And in argument1 choose if you want the window to have scroll bars. Either true or false
  • Go to the Draw event and look at the second function there, called scrTypingDraw()
  • Choose where you want the text to be drawn in your window. Its origin point is the top left corner of the surface inside the window. argument0 is the X position and argument1 is the Y position. argument2 is the color of your text.
  • It's possible to use this window in a puzzle, where the player has to type out a certain word and press enter to continue. Go and take a look at Key Press - Enter if this sounds interesting.
  • Right now, it will look for the password THE PASSWORD or a variant of this password (say "THEPASSWORD"), and then add text to the window. You do not have to use any of this, of course.
Creating a Password Protected File
  • To create a new password protected window in your game, copy the oBase_password_window object and rename it.
  • Go into the create event to find two functions. Look at scrWindowsCreate(icon,false,false)
  • Choose the icon you wish to draw in the top left corner of the window as argument0
  • Leave argument1 and argument2 as false
  • Now look at the second function: scrTypingCreate
  • First, choose the text you wish to display as the password from the start, as argument0 If you wish to have it empty, change it to ""
  • And in argument1 choose if you want the window to have scroll bars. This should be left on false
  • Now, there are two variables here you need to take a look at. nextwindow and password
  • Change nextwindow to the index of the window you want this to open, if the player enters the correct password.
  • Then change password to the password you wish the player to enter. Leave clicked and type as true
  • Now, look at the Draw event Here you can change where you want the players input to be drawn, and the prompt to enter the password.
  • Finally, look at Key Press - Enter to see what happens when the player inputs a password. If the password is correct, the new window is created, a happy sound plays and this window is destroyed.
  • If you wish the game to remember if the player has already entered the correct password, just create a global variable and set it to true. Then add something like || global.variable = true after if string_pos(password,lowercasetext) to let the player jump right to nextwindow
Window Resizing
  • Folders and windows are resizable if their resizable variable is set to true. This is done through the window's Create event
  • The window will clamp size and prevent shrinking below a certain size and getting too big. If a folder window gets wider than image_xscale = 4 icons may have issues being placed inside of it
  • There are three objects that handle resizing. oResizeWindowBottom oResizeWindowCorner and oResizeWindowSide
  • They function the same way, but change different values in their parent window. The mouse updates its cursor when hovering over these. You can change this in the oMouse object.
Scroll bars
  • There are two scroll bars, one controlling the x position of surface inside its parent window, and one controlling the y position.
  • The player can drag the handle, or roll the mouse wheel while hovering over the bar, to maneuver it.
Shader
  • A CRT shader is included in the template. Change its settings using the oShaderSettings object, or within the game by opening the Settings program.
  • Noise: The noise grain. 0.0 - 0.2 is recommended
  • Color tint: Change the color tint of the game, using RGB values. Max everything for no tint. Drag everything to 0 to get a fully black screen. This will make the game difficult to see.
  • Bending: Change the bending of the screen, to make it look like it's being played on an old CRT monitor. 0.0 - 0.3 is recommended.
  • Framesprite: Display a monitor as a frame around the screen. This will also adjust bend_strength
  • Scan lines: Lines going over the screen, to mimic a CRT monitor. 0.0 - 0.5 is recommended.
  • Frame_thickness: A frame around the screen. This is something I experimented with, and didn't like the result of. But, I kept it in the demo anyway. 0.0 is recommended.
  • The game is drawn onto the shader. Feel free to disable this in the Draw GUI event, within the oShaderSettings object.
Other settings
  • You can find the settings in the oSettings_icon on the desktop, while in-game.
  • Background: Change the background from a wallpaper to a flat color.
  • Text box: If you want a rectangle around the text under the icons on the desktop.
  • Text color: Color of the text of the icons on the desktop. c_white or c_black This also changes the color of the text boxes, if you have them activated.
  • Shader: CRT shader on or off
  • Frame counter: Display a frame counter in the top right corner. Using both fps and fps real