summaryrefslogtreecommitdiffhomepage
path: root/lib
diff options
context:
space:
mode:
authorTom Black <[email protected]>2015-11-13 00:47:07 -0500
committerTom Black <[email protected]>2015-11-13 00:47:07 -0500
commit05c80440cb1c0da84a479bfb4e6dbf9b894f7198 (patch)
tree73b99f9ba18b35d2379a7eb9a3f23cc23b5bb2c4 /lib
parent13c9614457e2b4694e67962b83967de0f808e8db (diff)
downloadruby2d-05c80440cb1c0da84a479bfb4e6dbf9b894f7198.tar.gz
ruby2d-05c80440cb1c0da84a479bfb4e6dbf9b894f7198.zip
Adding mouse button input, key input refining
Diffstat (limited to 'lib')
-rw-r--r--lib/ruby2d/window.rb48
1 files changed, 29 insertions, 19 deletions
diff --git a/lib/ruby2d/window.rb b/lib/ruby2d/window.rb
index 200a1e9..a56e8d5 100644
--- a/lib/ruby2d/window.rb
+++ b/lib/ruby2d/window.rb
@@ -48,13 +48,6 @@ module Ruby2D
end
end
- def on(mouse: nil, key: nil, &proc)
- puts "mouse: #{mouse}"
- puts "key: #{key}"
- # proc.call
- key(key, &proc)
- end
-
def add(o)
case o
when nil
@@ -83,12 +76,26 @@ module Ruby2D
@objects.clear
end
- # Register key string with proc
- def key(key, &proc)
- @keys[key] = proc
+ def update(&proc)
+ @update_proc = proc
true
end
+ def on(mouse: nil, key: nil, key_down: nil, controller: nil, &proc)
+ unless mouse.nil?
+ case mouse
+ when 'click'
+ end
+ end
+
+ unless key.nil?
+ reg_key(key, &proc)
+ end
+
+ unless key_down.nil?
+ reg_key_down(key_down, &proc)
+ end
+
unless controller.nil?
reg_controller(controller, &proc)
end
@@ -101,12 +108,6 @@ module Ruby2D
end
end
- # Register key string with proc
- def key_down(key, &proc)
- @keys_down[key] = proc
- true
- end
-
def key_down_callback(key)
key.downcase!
if @keys_down.has_key? key
@@ -114,9 +115,6 @@ module Ruby2D
end
end
- def update(&proc)
- @update_proc = proc
- true
end
def update_callback
@@ -134,6 +132,18 @@ module Ruby2D
end
end
+ # Register key string with proc
+ def reg_key(key, &proc)
+ @keys[key] = proc
+ true
+ end
+
+ # Register key string with proc
+ def reg_key_down(key, &proc)
+ @keys_down[key] = proc
+ true
+ end
+
# Register controller string with proc
def reg_controller(event, &proc)
@controller[event] = proc