Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Scrolling through pictures?

Yo. I'm trying to set up an event where a player reads a letter and a nice picture of said letter comes up, and the player can scroll through the letter's pages at his/her leisure. I've already made the pictures, so I thought the event would be easy. Sadly it was not.

What I tried was something kind of like this:

Code:
>Events fading in the picture

>Conditional Branch- If Right is pressed

 >Show next picture

 >Erase Old one

 >Conditional Branch- If Left is Pressed

  >Show old picture

  >Erase new one

 >end

>end

But that didn't work at all for scrolling through them, and then proceeding string of events to go back and forth through the pictures would be infinite. So what's another way I could do this? I really don't want to just use text bubbles for this.

Thanks in advance!
 
Well, since I like scripts, I made you a script :biggrin: (Hope you're cool with that)

The customization is in the module at the beginning of the script. You can change what pictures and how many pictures you want in the "Bitmaps" array. To call the script, put in an event :

$scene = Scene_Book.new

And without further delay, here's the script:
Code:
 

module Pictures

  Bitmaps = ["Picture1", "Picture2"]

end

 

 

#==============================================================================

# ** Sprite_Book

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

#  This sprite is used to display the timer.It observes the $game_system

#  class and automatically changes sprite conditions.

#==============================================================================

 

class Scene_Book

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

  # * Object Initialization

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

  def initialize

    @index = 0

    @size = Pictures::Bitmaps.size

  end

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

  # * Main Processing

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

  def main

    # Make graphic

    @sprite = Sprite.new

    @sprite.bitmap = RPG::Cache.picture(Pictures::Bitmaps[0])

    # Execute transition

    Graphics.transition

    # Main loop

    loop do

      # Update game screen

      Graphics.update

      # Update input information

      Input.update

      # Frame update

      update

      # Abort loop if screen is changed

      if $scene != self

        break

      end

    end

    # Prepare for transition

    Graphics.freeze

    # Dispose of graphic

    @sprite.bitmap.dispose

    @sprite.dispose

  end

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

  # * Frame Update

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

  def update

    if Input.trigger?(Input::RIGHT)

      next_page

    end

    if Input.trigger?(Input::LEFT) 

      previous_page

    end    

  end

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

  # * Next Page

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

  def next_page

    if @index != (@size - 1)

      @index += 1

      @sprite.bitmap = RPG::Cache.picture(Pictures::Bitmaps[@index])

    else

      # Play buzzer SE

      $game_system.se_play($data_system.buzzer_se)

    end

  end

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

  # * Previous Page

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

  def previous_page

    if @index != 0

      @index -= 1

      @sprite.bitmap = RPG::Cache.picture(Pictures::Bitmaps[@index])

     else

      # Play buzzer SE

      $game_system.se_play($data_system.buzzer_se)

    end

  end

end
 
TheScripter":3m1mb9ip said:
Well, since I like scripts, I made you a script :biggrin: (Hope you're cool with that)

The customization is in the module at the beginning of the script. You can change what pictures and how many pictures you want in the "Bitmaps" array. To call the script, put in an event :

$scene = Scene_Book.new

And without further delay, here's the script:
Code:
 

module Pictures

  Bitmaps = ["Picture1", "Picture2"]

end

 

 

#==============================================================================

# ** Sprite_Book

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

#  This sprite is used to display the timer.It observes the $game_system

#  class and automatically changes sprite conditions.

#==============================================================================

 

class Scene_Book

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

  # * Object Initialization

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

  def initialize

    @index = 0

    @size = Pictures::Bitmaps.size

  end

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

  # * Main Processing

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

  def main

    # Make graphic

    @sprite = Sprite.new

    @sprite.bitmap = RPG::Cache.picture(Pictures::Bitmaps[0])

    # Execute transition

    Graphics.transition

    # Main loop

    loop do

      # Update game screen

      Graphics.update

      # Update input information

      Input.update

      # Frame update

      update

      # Abort loop if screen is changed

      if $scene != self

        break

      end

    end

    # Prepare for transition

    Graphics.freeze

    # Dispose of graphic

    @sprite.bitmap.dispose

    @sprite.dispose

  end

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

  # * Frame Update

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

  def update

    if Input.trigger?(Input::RIGHT)

      next_page

    end

    if Input.trigger?(Input::LEFT) 

      previous_page

    end    

  end

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

  # * Next Page

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

  def next_page

    if @index != (@size - 1)

      @index += 1

      @sprite.bitmap = RPG::Cache.picture(Pictures::Bitmaps[@index])

    else

      # Play buzzer SE

      $game_system.se_play($data_system.buzzer_se)

    end

  end

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

  # * Previous Page

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

  def previous_page

    if @index != 0

      @index -= 1

      @sprite.bitmap = RPG::Cache.picture(Pictures::Bitmaps[@index])

     else

      # Play buzzer SE

      $game_system.se_play($data_system.buzzer_se)

    end

  end

end

Hot damn you are awesome.

I'll edit this post when I get a chance to try this out with my results. Thank you very much!

EDIT: Works great. I have a few questions though:
1. Is there an easy edit I can do (think you've done enough work) to make it so that when you press right on the last page, the event continues and the letter goes away?

2. How can I use this for more than just one event? i.e- Another letter found later on?

3. When I call the book, the events I have after the 'call script' event keep going. Is there a way I can tell the events to wait until after the player exits from the letter to proceed?
Thanks again.

4. How do I exit? >.>

EDIT EDIT: I pseudo-solved 2. If I copy and paste the script into another location and change the class name, then call that instead, would that work fine or would that eventually cause problems?
 
1. Well, what I did is that if you press right on the last page, a self switch occurs that brings the event to the next page.

2. That'll take a little longer to do, and I don't advise you to make a bunch of code with different class names (true, it would work) because that would be way to much code when I'm nearly 100% there's a more practical way to do it. I'll just have to find out lol

3. The self switch method I talked about earlier would work, just tested it out. On line 69 of the new script I'm about to provide change the first value in the brackets to the map where your event resides. In the second value, change the value to the event ID. Then the third value is the actual switch.

Code:
module Pictures

  Bitmaps = ["Picture1", "Picture2"]

end

 

 

#==============================================================================

# ** Sprite_Book

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

#  This sprite is used to display the timer.It observes the $game_system

#  class and automatically changes sprite conditions.

#==============================================================================

 

class Scene_Book

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

  # * Object Initialization

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

  def initialize

    @index = 0

    @size = Pictures::Bitmaps.size

  end

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

  # * Main Processing

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

  def main

    # Make graphic

    @sprite = Sprite.new

    @sprite.bitmap = RPG::Cache.picture(Pictures::Bitmaps[0])

    # Execute transition

    Graphics.transition

    # Main loop

    loop do

      # Update game screen

      Graphics.update

      # Update input information

      Input.update

      # Frame update

      update

      # Abort loop if screen is changed

      if $scene != self

        break

      end

    end

    # Prepare for transition

    Graphics.freeze

    # Dispose of graphic

    @sprite.bitmap.dispose

    @sprite.dispose

  end

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

  # * Frame Update

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

  def update

    if Input.trigger?(Input::RIGHT)

      next_page

    end

    if Input.trigger?(Input::LEFT) 

      previous_page

    end    

  end

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

  # * Next Page

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

  def next_page

    if @index != (@size - 1)

      @index += 1

      @sprite.bitmap = RPG::Cache.picture(Pictures::Bitmaps[@index])

    else

      $scene = Scene_Map.new 

      $game_self_switches = {[1, 1, "A"] => true} 

      $game_map.need_refresh = true 

    end

  end

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

  # * Previous Page

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

  def previous_page

    if @index != 0

      @index -= 1

      @sprite.bitmap = RPG::Cache.picture(Pictures::Bitmaps[@index])

     else

      # Play buzzer SE

      $game_system.se_play($data_system.buzzer_se)

    end

  end

end

Just make sure this all works than I'll get to number 2. And to exit, just press right on the last page lol
 

Ares

Member

Number 2 isn't that hard to do, I may give it a shot tomorrow.

@TheScripter: You didn't need to create a whole module for 1 variable, instead you can do:

[rgss]BITMAPS=["bitmap1","bitmap2"]
 
class Scene_Book
 
  def initialize
    @index = 0
    @size = BITMAPS.size
 
# [...]
[/rgss]

That will keep it shorter and theoreticly faster (but in such a small amount it is impossible to notice :P)
 
You guys are ****ing awesome (I don't remember if you can swear here or not >__>). Thanks a lot, the script works wonders.

I have one more script related question though.

I don't know how to call sound effects. So far whenever I've wanted to add a sound to something (like changing the sound when New Game is pressed or the pages are flipped), I just use something like $data_system.buzzer_se, only I change it to something like $data_system.battle_start_se, or use another system sound that I won't be using and have changed to fit the need. Obviously, this isn't the most efficient thing to do, nor will it work well when I make other genres of games where those sounds are needed >_>

EDIT: I'm not sure if this is a problem with the script. or something I'm just not seeing, but after the letter event, all of the games self switches reset.
 
@Ares: Yea that's definitely true, I didn't need a module for just one constant lol, thanks :biggrin:

@Rathalos: Yea, I don't know why it does that, so I went around it and stopped using self_switches, instead I had to play around with the event set up. How you set up your event is that, go to your event commands and choose the move route command (I believe its on the second page), then the last option in this event command should say "script...", click that and put in:

$scene = Scene_Book.new

then after that put a 20 second wait, and then after that put in the command "Wait for Move's completion".

True, its probably not the best method, but it works lol, so for now, try using this.

Oh yea, and here's the modified script, almost forgot:

Code:
Bitmaps = ["Picture1", "Picture2"]

 

 

#==============================================================================

# ** Sprite_Book

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

#  This sprite is used to display the timer.It observes the $game_system

#  class and automatically changes sprite conditions.

#==============================================================================

 

class Scene_Book

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

  # * Object Initialization

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

  def initialize

    @index = 0

    @size = Bitmaps.size

  end

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

  # * Main Processing

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

  def main

    # Make graphic

    @sprite = Sprite.new

    @sprite.bitmap = RPG::Cache.picture(Bitmaps[0])

    # Execute transition

    Graphics.transition

    # Main loop

    loop do

      # Update game screen

      Graphics.update

      # Update input information

      Input.update

      # Frame update

      update

      # Abort loop if screen is changed

      if $scene != self

        break

      end

    end

    # Prepare for transition

    Graphics.freeze

    # Dispose of graphic

    @sprite.bitmap.dispose

    @sprite.dispose

  end

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

  # * Frame Update

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

  def update

    if Input.trigger?(Input::RIGHT)

      next_page

    end

    if Input.trigger?(Input::LEFT) 

      previous_page

    end

  end

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

  # * Next Page

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

  def next_page

    if @index != (@size - 1)

      @index += 1

      @sprite.bitmap = RPG::Cache.picture(Bitmaps[@index])

    else

      $scene = Scene_Map.new

    end

  end

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

  # * Previous Page

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

  def previous_page

    if @index != 0

      @index -= 1

      @sprite.bitmap = RPG::Cache.picture(Bitmaps[@index])

     else

      # Play buzzer SE

      $game_system.se_play($data_system.buzzer_se)

    end

  end

end
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top