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.

Global Variables

Anonymous

Guest

Hello everyone. What I'm doing right now, is making a platformer script. I've organized my variables into classes. For example,

Code:
class Jump
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :multiplier_x  # Jump Multiplier (X)
  attr_accessor :multiplier_y  # Jump Multiplier (Y)
  #--------------------------------------------------------------------------
  # * X multiplier
  #--------------------------------------------------------------------------
  def initialize
    @multiplier_x = 0
    @multiplier_y = 0
  end
  def multiplier_x
    return @multiplier_x.to_i
  end
  def multiplier_y
    return @multiplier_y.to_i
  end
end
Now, what I want to do, is access these from the Interpreter. So, I was wondering, how would I do this? I've tried $jump.multiplier_y, but that returns Nil:nilclass, i.e. nil. I noticed that in the ATS, the class is Advanced_Time, but to access it, you use $ats.variable. So how would I assign a Global variable to a class? Thanks for trying to help! :)
 

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