MENUS - Animated backdrops

Ask and answer questions about making games and related topics. Unrelated topics go in that other forum.

Moderators: marionline, SDHawk

Post Reply
User avatar
Greenyel
Slime
Posts: 23
Joined: Mon Jan 16, 2017 2:58 pm
Location: Tubarao/SC - Brazil

MENUS - Animated backdrops

Post by Greenyel »

Hi

I was searching and found a script for making a loop animation backdrop on the title screen on OHR.
So I want to make a title screen were a menu is showed up and you can choose the options. Like new game, load, etc.. Is that possible? (with The animated background offcourse).

The script i found in hamsterrepublic is this

Code: Select all

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 (keyispressed(key:alt) || keyispressed(key:esc)) then (
          fadescreenout
          gameover
        )

        # Continue when a key is pressed
        if (keyispressed(key:enter) || keyispressed(key:space) || keyispressed(key:ctrl) || lastascii) then (break(2))
      )
    )
  )

  # Show the load game menu if there are any games to load
  variable (slot)
  for (slot, 1, 32) do (
    if (save slot used (slot)) then (
      # There's at least one save, show load menu
      load menu
      break
    )
  )

  # Hide the backdrop
  show map
  resume player

  # Call your real new-game script here, if any
end
Thanks
Last edited by Greenyel on Wed Jan 18, 2017 1:25 am, edited 2 times in total.
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

Hello, welcome!

Here's one way to do this. Use a 'newgame' script (in the "Special Plotscripts" editor) which opens the menu (which you've defined in the menu editor) and then animates the backdrop behind the menu. The menu items should have the "Close menu if selected" bitset turned on. The items in the menu will be:
-Load: set to "Special screen -> Quit"
-Quit: set either to a plotscript which just calls "fade screen out, game over", or alternatively use the builtin "Special screen -> Quit"
-New game: just make this a 'Caption', so it does nothing aside from closing the menu. The script will then continue.
-Anything else.

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):

Code: Select all

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 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
  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 while loop 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

Since you have disabled the title screen and load menu, you will need to use the "reset game" instead of "game over" command to go back to your custom title menu. (Dying in battle or using Quit from the main menu will work fine, though).

BTW, I see you're from Brazil. We used to have a number of Brazilian users for some reason, someone even translated the HOWTO into Portuguese long ago. Haven't heard anything for a long time. How did you find the OHRRPGCE?

(Edit: I added this script to the wiki)
Last edited by TMC on Tue Jan 17, 2017 4:25 am, edited 4 times in total.
User avatar
Greenyel
Slime
Posts: 23
Joined: Mon Jan 16, 2017 2:58 pm
Location: Tubarao/SC - Brazil

It worked!

Post by Greenyel »

It worked like a charm! :D
Thanks a lot TMC!

Image

BTW I wandering what to do with the game over script, since it wont come back to the title screen anymore. Just closes the game screen.

As a symbol of my gratitude
Answering your question:
I find OGHRPGCE when I was a teenager, the year was 2000, the internet conection was a 56kb/s dial up, and I found a Brazilian site about Rockman (Megaman) were the webmaster uploaded a litle OHRRPG game he made about Megaman from NES.
I was a great fan of Megaman games, and Final Fantasy games too, so when I discovered that engine I was very excited about making my own game. I used that site game as reference and started my PROTOMAN RPG. Protoman is the Blues in EUA version of Megaman games and one of my favorite heroes. I never heard about he had his own game, so I started to do it by myself.
Some time later I met the Ramster Republic site... Now my game has about 16 years old. But not so big thing since a lot of things happened, like childs, marriage, etc... But now Im trying to finish the games history, and maybe making a english version of it.
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

Cool, looks good! Wow, completing a game 16 years later, that's pretty remarkable!

So do you still have a problem with the "game over" command, or did I already answer your problem?
Since you have disabled the title screen and load menu, you will need to use the "reset game" instead of "game over" command to go back to your custom title menu. (Dying in battle or using Quit from the main menu will work fine, though).
"game over" will quit the program totally. "reset game", dying, or the Quit option will reset and run the new game (title screen) script.
Last edited by TMC on Wed Jan 18, 2017 2:38 am, edited 2 times in total.
User avatar
Greenyel
Slime
Posts: 23
Joined: Mon Jan 16, 2017 2:58 pm
Location: Tubarao/SC - Brazil

Solved

Post by Greenyel »

Sorry, I missed that part you wrote. And yes, it solved my problem.

Just one thing: The only menu item that should have the "Close menu if selected" bitset turned on was the "New Game". Otherwise chosing de other opitions started a new game too.
Choosing the "Quit" option ("special screen" type menu) aways closes the game. Even in the main menu during the game. But its not really a problem, since its possible to make a custon "Quit" menu that just use the "reset game" command.

Thank you very much! It was all very well explaned.
Congratulations!
Better than this?
...only if it was in portuguese, my first language! lol
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Re: Solved

Post by TMC »

greenyel wrote:Just one thing: The only menu item that should have the "Close menu if selected" bitset turned on was the "New Game". Otherwise chosing de other opitions started a new game too.
Hmm, I guess you mean that if you select Load or Quit (or a textbox or anything else) and then cancel out of those screens, you should still be on the title menu. I hadn't thought of that. Thanks, I'll update the wiki.
Choosing the "Quit" option ("special screen" type menu) aways closes the game. Even in the main menu during the game.
Oh, yes, you're right. (I got that wrong when I mentioned it earlier). Dying in a battle will also cause the game to totally quit. To fix that you just have to set an On-death Script in the Special Plotscripts menu:

Code: Select all

plotscript, death script, begin
  fade screen out(63, 0, 0)  # fade to red (same as default)
  # add an extra fade to black (0,0,0) here if desired
  reset game
end
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

I might as well link to the wiki article, although I don't think it has any extra explanation: How do I make an animated title screen?

Hmm, creating a custom title screen really isn't straightforward, because it screws up the main menu default Quit option and dying in battle and the behaviour of "game over". Maybe what we need is a dedicated "title screen script" trigger which you can set without disabling the titlescreen (it would be compatible with either disabling or leaving the load menu). Then using a newgame script as title screen would be obsolete. Unfortunately, adding more options ALWAYS increases total complexity, although my aim is to decrease it :(
Post Reply