How do I make an animated title screen?

From OHRRPGCE-Wiki
Jump to navigation Jump to search

An animated title screen can be created by importing some backdrops (put them all in sequence) and using a script like this one to switch between them. You have to go Preference Bitsets menu in General Game Data, and turn on the Skip title screen and Skip load screen bitsets! Then edit this script to the right backdrop numbers and delay amount, import it, and set it as the new game plotscript in General Game Data, Special Plotscripts.

Afterwards, the builtin title screen and title music options will do nothing.

Note: turning on both of the Skip title/load screen bitsets causes dying in battle and the built-in Quit menu option to both immediately quit out of the game entirely instead of going back to your custom title screen. To fix this:

  • Replace the 'Quit' option in the default main menu with a script:
  plotscript, quit, begin
    reset game
  end
  • Set an On-Death script (in the Special Plotscripts menu)
  plotscript, death script, begin
    fade screen out (63, 0, 0)  # Fade to red
    fade screen out (0, 0, 0)   # Fade to black
    reset game
  end

(See below for a variant with a menu.)

A plain animated titlescreen[edit]

plotscript, animated title, begin
  #### If you want title music, add a line like this here:
  #play song(4)

  suspend player
  while (true) do (
    variable (backdrop, tick)
    ##### Change 2 and 8 to first and last backdrop
    for (backdrop, 2, 8) do (
      show backdrop (backdrop)

      variable(delay)
      ##### Change to the desired delay between backdrops (2 ticks = 1/9th second)
      delay := 2

      for (tick, 1, delay) do (
        wait

        # Quit game if esc/alt pressed
        if (key is pressed(menu key)) then (
          fade screen out
          gameover
        )

        # When any other is key is pressed, exit (break out of) all 3 for and while loops
        if (key is pressed(any key)) then (break(3))
      )
    )
  )

  # Show the load game menu if there are any games to load (the menu won't appear if there are no saves)
  load menu

  # Hide the backdrop
  show map
  resume player

  # Call your real new-game script here, if any
end

An animated title screen with a menu on top[edit]

You can display a menu on top of the animated title screen (or even use the following script without the animation) by using the script below which opens the menu and then animates the backdrops. Start by following the instructions above, then create a new menu in the menu editor and add the following menu

which opens the menu (which you've defined in the menu editor) and then animates the backdrop behind the menu. Add the following menu items:

  • New game: make this type "Caption -> Selectable", and turn on the "Close menu if selected" bitset, so it does nothing aside from closing the menu. The script will then continue to a new game.
  • Load game: set to "Special screen -> Load"
  • Quit: set either to a plotscript which just calls "fade screen out, game over", or alternatively use the builtin "Special screen -> Quit"
  • Anything else you want, such as Help, Credits, etc. These can bring up textboxes, submenus, or scripts.

The menu must have the following bitsets turned on: "Allow gameplay & scripts", "Prevent Main Menu Activation". Beware that if the starting map is some blank map NPCs will be walking around. Make sure they can't bump into the hero and activate, or use a blank starting map.

Also, you should either disable ESC to close the menu ("Disable cancel button" bitset), or set an on-close script which quits the game (calls "game over"). Otherwise pressing ESC will start a new game.

You might want to only show the 'Load' option if there's at least one saved game. That can be accomplished by setting a tag and putting a tag condition on the menu item (uncomment the code for that at the start of the script):

plotscript, animated title, begin
  #### If you want title music, add a line like this here:
  #play song(4)

  # Set a tag to show the load game menu item if there are any games to load
  #variable (slot)
  #for (slot, 1, 32) do (
  #  if (save slot used (slot)) then (
  #    set tag(tag:show load option, on)
  #  )
  #)

  suspend player
  #### Set the correct menu number here:
  open menu (1)

  # Show an animated backdrop while any menu is open
  while (true) do (
    variable (backdrop)
    ##### Change 2 and 8 to first and last backdrop
    for (backdrop, 2, 8) do (
      show backdrop (backdrop)
      ##### Change to the desired delay between backdrops (2 ticks = 1/9th second)
      wait(2)
      if (top menu == false) then (break(2))  # Exit for and while loops when no menu open
    )
  )

  # When the menu is closed the above loop ends, so continue to a new game.
  # Hide the backdrop.
  show map
  resume player

  # Call your real new-game script here, if any
end

See Also[edit]