class CyberarmEngine::GameState

Attributes

game_objects[R]
global_pause[RW]
options[RW]

Public Class Methods

new(options = {}) click to toggle source
# File lib/cyberarm_engine/game_state.rb, line 8
def initialize(options = {})
  @options = options
  @game_objects = []
  @global_pause = false
  $window.text_input = nil unless options[:preserve_text_input]

  @down_keys = {}
end

Public Instance Methods

add_game_object(object) click to toggle source
# File lib/cyberarm_engine/game_state.rb, line 93
def add_game_object(object)
  @game_objects << object
end
button_down(id) click to toggle source
# File lib/cyberarm_engine/game_state.rb, line 77
def button_down(id)
  @down_keys[id] = true

  @game_objects.each do |o|
    o.button_down(id)
  end
end
button_up(id) click to toggle source
# File lib/cyberarm_engine/game_state.rb, line 85
def button_up(id)
  @down_keys.delete(id)

  @game_objects.each do |o|
    o.button_up(id)
  end
end
destroy() click to toggle source
# File lib/cyberarm_engine/game_state.rb, line 72
def destroy
  @options.clear
  @game_objects.clear
end
draw() click to toggle source
# File lib/cyberarm_engine/game_state.rb, line 25
def draw
  @game_objects.each(&:draw)
end
draw_bounding_box(box) click to toggle source
# File lib/cyberarm_engine/game_state.rb, line 33
def draw_bounding_box(box)
  x = box.x
  y = box.y
  max_x = box.max_x
  max_y = box.max_y

  color = Gosu::Color.rgba(255, 127, 64, 240)

  # pipe = 4
  # Gosu.draw_rect(x-width, y-height, x+(width*2), y+(height*2), color, Float::INFINITY)
  # puts "BB render: #{x}:#{y} w:#{x.abs+width} h:#{y.abs+height}"
  # Gosu.draw_rect(x, y, x.abs+width, y.abs+height, color, Float::INFINITY)

  # TOP LEFT to BOTTOM LEFT
  $window.draw_line(
    x, y, color,
    x, max_y, color,
    Float::INFINITY
  )
  # BOTTOM LEFT to BOTTOM RIGHT
  $window.draw_line(
    x, max_y, color,
    max_x, max_y, color,
    Float::INFINITY
  )
  # BOTTOM RIGHT to TOP RIGHT
  $window.draw_line(
    max_x, max_y, color,
    max_x, y, color,
    Float::INFINITY
  )
  # TOP RIGHT to TOP LEFT
  $window.draw_line(
    max_x, y, color,
    x, y, color,
    Float::INFINITY
  )
end
post_setup() click to toggle source

Called immediately after setup returns. GuiState uses this to set current_theme for ToolTip

# File lib/cyberarm_engine/game_state.rb, line 22
def post_setup
end
setup() click to toggle source
# File lib/cyberarm_engine/game_state.rb, line 17
def setup
end
update() click to toggle source
# File lib/cyberarm_engine/game_state.rb, line 29
def update
  @game_objects.each(&:update)
end