How do I add screens before my title game screen?

From OHRRPGCE-Wiki
Jump to: navigation, search

You'd like to replace or show something before the title screen? Guess what? You can do that! Isn't the OHRRPGCE the world's best rpg engine? ^______^

Now, you need to think about what you want to show up when the game starts. You might have "An XYZ production", or "Created with the OHRRPGCE" or something. Here are a few example screens (by Mike Caron and members of the Castle Paradox community.) that one might theoretically use (free to use, although not recommended):

Foobar-studios.png

Created-with-the-ohr.png

Once you've created your screens, launch Custom and open your game.

Now, go into Edit General Game Data, and choose Preference Bitsets.... Then, enable the "skip title screen" bitset. If you also want to implement your own loading screen, also enable the "skip load screen" bitset. However, this will not be covered in this tutorial (but it is in How do I make title options like Start Game, Continue Game, etc.?)

Next, import your screens as backdrops. This should be a no-brainer. It doesn't really matter what order you import them, but for your own sake, do it in order. Also, note which numbers each screen has, for use in the upcoming plotscript. Let's pretend that the two screens shown above are #1 and #2, while the title screen itself is #3. Also, if possible, import an all-black screen. We'll assume you did this first, and it's numbered #0.

Now, you need to open up your plotscript file.

Include the following scripts in your code:

#change this if you already have a script #1

#-------------------------------------------

plotscript, title screen, begin

  suspend player #the player shouldn't be able to move during the title, duh...
  
  show backdrop (0) #show absolutely nothing
  fade screen out
  wait(1) #this is to avoid the initial fade-in

  do, begin
    if(skippable wait(15)) then (break)  #waiting a few seconds before displaying anything never hurts
    show backdrop (1)#  FooBar Studios
    wait(1)
    fade screen in
    if(skippable wait(30)) then (break)
    fade screen out
    show backdrop (2)# created with the OHR
    wait(1)
    fade screen in
    if(skippable wait(30)) then (break)
  end
  
  fade screen out

  show backdrop (3) #title screen
  play song(song:title) #play the title theme
  wait(1)

  fade screen in

  while(true) do, begin #these simulate the regular behaviour of the title screen
    wait (1) #don't delete the wait (1) command here! I would prevent the player from pressing the keys
    if(key is pressed(28)) then (break) #ENTER
    if(key is pressed(57)) then (break) #SPACE
    if(key is pressed(1)) then (fade screen out, game over) #ESCAPE
  end 

  variable (s)

  #display the load-game menu
  #if you were implementing your own, you'd do it here
  
  s := load menu(false) #show it, but don't actually do anything
  if(s > 0) then, begin
    load from slot (s)
    # The game was loaded, so this script ends now.
  end  

  if(s == -1) then, begin
    game over #they chose quit
  end

  if(s == 0) then, begin
    introduction #game intro begins, this is your old new-game script
  end #end of the load menu  
  

end #end of plotscript
#-------------------------------------------

script, skippable wait, ticks, begin
  # Returns true if the wait was cancelled by a keypress.
  variable(i)
  for(i, 1, ticks) do, begin
    wait(1)
    if(key is pressed(key:ENTER)) then(exit returning(true))
    if(key is pressed(key:SPACE)) then(exit returning(true))
    if(key is pressed(key:CTRL)) then(exit returning(true))
    if(key is pressed(key:ALT)) then(exit returning(true))
    if(key is pressed(key:ESC)) then(exit returning(true))
    if(key is pressed(joy:button 1)) then(exit returning(true))
    if(key is pressed(joy:button 2)) then(exit returning(true))
  end
  exit returning(false)
end

Import your scripts, and set the new-game script (under General Game Data->Special Plotscripts) to title screen

Notes about the scripts:

  1. skippable wait is copied from the Scripts:skippable wait article. It's just like wait, can be interrupted by pressing a key to interrupt it. This is used so that we display a given screen for the proper amount of time, but still allow the player to skip right to the title.
  2. If there are no saved games, load game will automatically choose "new game" for you. That is why the title-screen section listens for "escape", so the player has a chance to quit if they choose to do so.