class R2D::Window

Attributes

bg[RW]
cursor[RW]
fs[RW]
h[RW]
keys_down[R]
objects[R]
on_keys[R]
title[RW]
update_proc[R]
w[RW]

Public Class Methods

add(o) click to toggle source
# File lib/r2d/window.rb, line 24
def self.add(o)
  @@current.add(o)
end
new(options = {}) click to toggle source
# File lib/r2d/window.rb, line 9
def initialize(options = {})
  options = options.merge({w: 640, h: 480, title: "R2D", bg: nil, cursor: true, fs: false})
  @w, @h, @title, @bg, @cursor, @fs, =
    options[:w], options[:h], options[:title], options[:bg], options[:cursor], options[:fs]
  
  @objects = []
  @on_keys = {}
  @keys_down = {}
  @update_proc = Proc.new {}
  
  Adapters.create(self, :gosu)
  
  @@current = self
end
remove(o) click to toggle source
# File lib/r2d/window.rb, line 28
def self.remove(o)
  @@current.remove(o)
end

Public Instance Methods

add(o) click to toggle source
# File lib/r2d/window.rb, line 32
def add(o)
  if !@objects.include?(o)
    @objects.push(o)
    true
  else
    false
  end
end
add_key_down(key, proc) click to toggle source
# File lib/r2d/window.rb, line 64
def add_key_down(key, proc)
  @keys_down[Adapters.key_lookup(key)] = proc
  true
end
add_on_key(key, proc) click to toggle source
# File lib/r2d/window.rb, line 54
def add_on_key(key, proc)
  @on_keys[Adapters.key_lookup(key)] = proc
  true
end
clear() click to toggle source
# File lib/r2d/window.rb, line 50
def clear
  @objects.clear
end
key_down?(key) click to toggle source
# File lib/r2d/window.rb, line 59
def key_down?(key)
  button_down?(Adapters.key_lookup(key))
  true
end
mouse_x() click to toggle source
# File lib/r2d/window.rb, line 79
def mouse_x
  Adapters.mouse_x
end
mouse_y() click to toggle source
# File lib/r2d/window.rb, line 83
def mouse_y
  Adapters.mouse_y
end
on_key(key, block) click to toggle source
# File lib/r2d/window.rb, line 74
def on_key(key, block)
  add_on_key(key, block)
  true
end
remove(o) click to toggle source
# File lib/r2d/window.rb, line 41
def remove(o)
  if i = @objects.index(o)
    @objects.slice!(i)
    true
  else
    false
  end
end
show() click to toggle source
# File lib/r2d/window.rb, line 87
def show
  Adapters.show
end
update(block) click to toggle source
# File lib/r2d/window.rb, line 69
def update(block)
  @update_proc = block
  true
end