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.

[Review] Press Space

I am very new to scripting, and this is my very first attempt at ruby scripting. I am trying to make a script that shows a image
saying "Press the space bar" Just like "Press Start" from other games. I know this is my first post, and I haven't been a member for very long, but I hope you other members can help me.

Code:
#------------------------------------------------------------------------

 # Press Space

 # By Wingish

 # Press Space to enter the title screen

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

 class Scene_Space

  

     # Load the System database & create a new game   

  $data_system = load_data("Data/System.rxdata")

  $game_system = Game_System.new

   

     # Initialize some stuff

  @show = true

  @n = 0

  @picture_numb = 1

   

  # Define info about the image

  @sprite1 = Sprite.new

  @sprite1.bitmap = RPG::Cache.picture("Press-Space")

  @sprite1.opacity = 0

   

  

   # If SPACEBAR is pressed the player is sent to the title screen

     if Input.trigger?(Input::C)

       @show = false

       @n = 0

       @picture_numb -= 1

       end

      

       # Makes Press-Space visable 

         if @show == true

           @n = 255

       

            # Chooses the action required at the time

                     case @picture_numb         

            when 0

               $scene = Scene_Title.new

            when 1

               @sprite1.opacity = @n

         end         

           

  end

  

end  

 

Using this script I get an error with main on line 17 $scene.main

Thanks!
~Wingish
 
Code:
  #------------------------------------------------------------------------

  # Press Space

  # By Wingish

  # Press Space to enter the title screen

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

  class Scene_Space

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

  # Initialize the scene

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

  

  def main

        # Load the System database & create a new game  

     $data_system = load_data("Data/System.rxdata")

     $game_system = Game_System.new

      

        # Initialize some stuff

     @show = true

     @n = 0

     @picture_numb = 1

      

     # Define info about the image

     @sprite3 = Sprite.new

     @sprite3.bitmap = RPG::Cache.picture("Press-Space")

     @sprite3.opacity = 0

   

       # Update graphics and input

  Graphics.transition

  loop do

     Graphics.update

     Input.update

     update

     if $scene != self

        break

    end

end

       # Discard your graphics when you leave this scene

  Graphics.freeze

  @sprite3.dispose

  end

      

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

  # ● Update the contents in this scene

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

  

  def update

     

      # If SPACEBAR is pressed the player is sent to the title screen

        if Input.trigger?(Input::C)

          @show = false

          @n = 0

          @picture_numb -= 1

          end

  

     

     # Update graphics

     @sprite3.update

     

  end

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

  # Uhmmmm some stuff

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

    def transition

        

          # Makes Press-Space visable

            if @show == true

              @n = 255

          

               # Chooses the action required at the time

                        case @picture_numb        

               when 0

                  $scene = Scene_Title.new

               when 1

                  @sprite3.opacity = @n

            end        

              

     end

    

   end  

end    


EDIT
The only thing wrong is the image doesn't show.
 
Didn't you say you got an error? O_o

And well, the sprite (not a picture!) is shown, it's just not visible - here's your "error":
Code:
@sprite3.opacity = 0
You never set the opacity back to anything above 0.
 
Note that THIS is what happens when you press the confirm button:
Code:
if Input.trigger?(Input::C)

  @show = false

  @n = 0

  @picture_numb -= 1

end
And this is what happens after the keypress check (wheather or not you pressed it):
Code:
if @show == true

  @n = 255

  case @picture_numb        

  when 0

    $scene = Scene_Title.new

  when 1

    @sprite1.opacity = @n

  end

end
So, to get to the title scene, @show would have to be true (you disable that with the confirm key input) and @picture_numb would have to be 0 (which, again, you kind of coutnerwork with your input check. Another suggestion: since you don'T really need a substraction here, use '= 0' instead of '-= 1' for the picture_numb setting.)
 

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