Module: GamesAndRpgParadise::Input

Defined in:
lib/games_and_rpg_paradise/gui/gosu/books/input.rb

Constant Summary collapse

@@buttons =
{
  down:        Gosu::KbDown,
  left:        Gosu::KbLeft,
  right:       Gosu::KbRight,
  up:          Gosu::KbUp,
  esc:         Gosu::KbEscape,
  q:           Gosu::KbQ,
  enter:       Gosu::KbEnter,
  return:      Gosu::KbReturn,
  spacebar:    Gosu::KbSpace,
  left_alt:    Gosu::KbLeftAlt,
  right_alt:   Gosu::KbRightAlt,
  left_shift:  Gosu::KbLeftShift,
  right_shift: Gosu::KbRightShift,
  left_ctrl:   Gosu::KbLeftControl,
  right_ctrl:  Gosu::KbRightControl,
  gp_down:     Gosu::GP_DOWN,
  gp_left:     Gosu::GP_LEFT,
  gp_right:    Gosu::GP_RIGHT,
  gp_up:       Gosu::GP_UP,
  gp_l1:       Gosu::GP_BUTTON_4,
  gp_r1:       Gosu::GP_BUTTON_5,
  gp_l2:       Gosu::GP_BUTTON_6,
  gp_r2:       Gosu::GP_BUTTON_7,
  gp_ok:       Gosu::GP_BUTTON_1,
  gp_cancel:   Gosu::GP_BUTTON_2
}
@@down_id =
@@down_ticks = @@up_ticks = 0
@@ticks_max =
3

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.[](sym) ⇒ Object



54
# File 'lib/games_and_rpg_paradise/gui/gosu/books/input.rb', line 54

def self::[](sym) @@buttons[sym] end

Instance Method Details

#button_down(id) ⇒ Object



33
34
35
36
37
# File 'lib/games_and_rpg_paradise/gui/gosu/books/input.rb', line 33

def button_down(id)
  @@last_down_id = @@down_id
  @@down_id = id
  @@down_ticks = @@ticks_max if @@down_ticks == 0 or @@last_down_id != id
end

#button_down?(id) ⇒ Boolean

@@ticks_max / 2 end#@@ticks_max == 4

Returns:

  • (Boolean)


52
# File 'lib/games_and_rpg_paradise/gui/gosu/books/input.rb', line 52

def button_down?(id) @@buttons[id] == @@down_id and @@down_ticks > 1 end

#button_up(id) ⇒ Object



53
# File 'lib/games_and_rpg_paradise/gui/gosu/books/input.rb', line 53

def button_up(id) @@down_id = nil end

#hold_down?Boolean

hold_down?

Returns:

  • (Boolean)


57
58
59
60
61
# File 'lib/games_and_rpg_paradise/gui/gosu/books/input.rb', line 57

def hold_down?
  press = button_down?(:down) or button_down?(:gp_down)
  press ? @@down_ticks += 2 : return
  press = button_down?(:down) or button_down?(:gp_down)
end

#press_down?Boolean

Returns:

  • (Boolean)


46
# File 'lib/games_and_rpg_paradise/gui/gosu/books/input.rb', line 46

def press_down?() button_down?(:down) or button_down?(:gp_down) end

#press_enter?Boolean

Returns:

  • (Boolean)


39
40
41
42
43
# File 'lib/games_and_rpg_paradise/gui/gosu/books/input.rb', line 39

def press_enter?
  return if Gosu::button_down?(@@buttons[:left_alt]) or Gosu::button_down?(@@buttons[:right_alt])
  return true if button_down?(:enter) or button_down?(:return)
  return true if button_down?(:spacebar) or button_down?(:gp_ok)
end

#press_kb_right?Boolean

Returns:

  • (Boolean)


49
# File 'lib/games_and_rpg_paradise/gui/gosu/books/input.rb', line 49

def press_kb_right?() button_down?(:right) or button_down?(:gp_right) end

#press_L1?Boolean

Returns:

  • (Boolean)


50
# File 'lib/games_and_rpg_paradise/gui/gosu/books/input.rb', line 50

def press_L1?() button_down?(:gp_l1) end

#press_left?Boolean

Returns:

  • (Boolean)


47
# File 'lib/games_and_rpg_paradise/gui/gosu/books/input.rb', line 47

def press_left?() button_down?(:left) or button_down?(:gp_left) end

#press_quit?Boolean

Returns:

  • (Boolean)


44
# File 'lib/games_and_rpg_paradise/gui/gosu/books/input.rb', line 44

def press_quit?() button_down?(:esc) or button_down?(:q) or button_down?(:gp_cancel) end

#press_R1?Boolean

Returns:

  • (Boolean)


51
# File 'lib/games_and_rpg_paradise/gui/gosu/books/input.rb', line 51

def press_R1?() button_down?(:gp_r1) end

#press_right?Boolean

Returns:

  • (Boolean)


48
# File 'lib/games_and_rpg_paradise/gui/gosu/books/input.rb', line 48

def press_right?() button_down?(:right) or button_down?(:gp_right) end

#press_up?Boolean

Returns:

  • (Boolean)


45
# File 'lib/games_and_rpg_paradise/gui/gosu/books/input.rb', line 45

def press_up?() button_down?(:up) or button_down?(:gp_up) end