001 Game Creator Guide

Game Recipe #4 Make Game Fit the Game Window (Using Camera Zoom) for 001 Game Creator

Game Recipe #4 Make Game Fit the Game Window (Using Camera Zoom)

Overview

In this Game Recipe, we will be going over how to ensure your game is displayed correctly via the Camera Zoom Event.

Requirements

  • A main actor and a couple of maps to test on.

Setup

  1. From the editor’s main view, open the Players and Party Members menu.

    1. If you have multiple party members, make sure your main actor (the one the player will be controlling) is selected.
    2. Click the Edit Actor button.
      1. Click Add to add a new Changed trigger. Click the checkbox beside Expression, then copy one of the following use values into the field depending on how you want the zoom to work.
      2. For having the Zoom based on screen resolution.
        1. Click the checkbox next to Expression, then set the Expression to:
          Screen.SizeX & Screen.SizeY
        2. Click OK to confirm, this will bring up the script editor.
        3. Place a Camera > Change Zoom event (Ensure it’s the event under Camera, not Camera Views).
          1. If you want the zoom to be set based on window width
            1. Set the Zoom value to:
              Screen.SizeX / Screen.InterfaceX
          2. If you want the zoom to be set based on window height
            1. Set the Zoom value to:
              Screen.SizeY / Screen.InterfaceY
          3. Click OK to confirm, placing the event in the script.
        4. Now that your script has been created, using the left click on your mouse, click and drag to highlight your entire script.
        5. Press CTRL+C, or Right Click > Copy the script.
        6. Click OK to save and close the script.
      3. For having the Zoom based on map size.
        1. Click the checkbox next to Expression, then set the Expression to:
          Structure.IIf(Screen.FocusMap = “”, Actor(“main”).Map, Screen.FocusMap)
        2. Click OK to confirm, this will bring up the script editor.
        3. Place a Variable Operation event.
          1. Click Edit and select Local, then add a new variable called map. Close the Local Variables window when you’re done.
          2. Select map from the dropdown menu. (It should be near the bottom of the list.)
          3. Click the use value box next to the Value field and select (Value). (This should be near the top.)
          4. Copy the following into the Value field:
            Structure.IIf(Screen.FocusMap = “”, Actor(“main”).Map, Screen.FocusMap)
            Be sure to replace the “” characters when you paste, or remove them afterward. Don’t remove them before pasting or the color of the field will go back to normal (not gray). This means the field has reset and you’ll have to repeat the previous step.
          5. Once you’ve successfully copied the use value in, click OK to close the window.
        4. Place a Comparison Branch event.
          1. Set the Expression to:
            Map(map).SizeX
          2. Set the Operator to:
            <= (Less Than or Equal)
          3. Set the Value to:
            Map(map).SizeY
          4. Click OK to confirm, placing the event in the script.
        5. On the left side of the comparison branch, add a Change Zoom event (Specifically from the Camera category, not Camera Views).
          1. Set the Zoom to:
            Screen.SizeY / Map(map).SizeY
            This field will turn gray automatically.
          2. Click OK to close the window.
        6. On the right side of the comparison branch, add another Change Zoom event (Again, from the Camera category, not Camera Views).
          1. Set the Zoom to:
            Screen.SizeX / Map(map).SizeX
          2. Click OK to close the window.
        7. Your script should look like this:
        8. Now that your script has been created, using the left click on your mouse, click and drag to highlight your entire script, selecting every event.
        9. Press CTRL+C, or Right Click > Copy the script.
        10. Click OK to save and close the script.
      4. Click Add to add a new Loaded trigger.
      5. In the next window, press OK to open the script editor.
      6. For having zoom based on resolution.
        1. Paste your script by pressing CTRL+V or Right Click > Paste.
        2. Connect your script to the Start Node.
        3. Click OK to save and close your script
      7. For having zoom based on map size.
        1. Click the Edit Local Variables button in the bottom left of the scripting window.
        2. Click the Add to Local Variables button.
        3. Type map into the new empty entry that appears then close the Local Variables window.
        4. Place a Delay event.
          1. Leave Time blank and click OK to close the window.
        5. Paste your script by pressing CTRL+V or Right Click > Paste.
        6. Connect your script to the Delay event.
        7. Click OK to save and close your script
    3. Click OK to save and close your actor.
    4. Click OK to save and close the Players and Party Members menu.
  2. Test out your new script!

Notes

If your game uses pixel art, you might want to restrict the camera to only zoom in integer amounts. This means that instead of 2.5x zoom, which would distort pixel art, you would zoom to just 2.0x. If you want to try this, just replace the values in the Change Zoom events with the following:
Math.Max(Math.Int(Screen.SizeX / Screen.InterfaceX), 1) and
Math.Max(Math.Int(Screen.SizeY / Screen.InterfaceY), 1)
Or…
Math.Max(Math.Int(Screen.SizeX / Map(map).SizeX), 1) and
Math.Max(Math.Int(Screen.SizeY / Map(map).SizeY), 1).

SteamSolo.com