From 2ca4a07d60357c3b32625a706f7411997b6258c0 Mon Sep 17 00:00:00 2001 From: Tom Black Date: Wed, 12 Dec 2018 01:58:37 -0800 Subject: Add an interactive console Also moves `bin/ruby2d` functionality to new `lib/ruby2d/cli` dir --- test/console.rb | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 test/console.rb (limited to 'test') diff --git a/test/console.rb b/test/console.rb new file mode 100644 index 0000000..c7d29c4 --- /dev/null +++ b/test/console.rb @@ -0,0 +1,25 @@ +require 'ruby2d' + +s1 = Square.new(x: 0, y: 0, size: 100, color: 'white') +s2 = Square.new(x: 100, y: 100, size: 50, color: 'green') +c = 0.0 +switch = true + +update do + + if switch + c += 0.01 + if c > 1.0 + switch = false + end + else + c -= 0.01 + if c < 0.0 + switch = true + end + end + + s1.color = [1, 1, 1, c] +end + +show -- cgit v1.2.3