Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module Tetris
- module Field
- WIDTH = 12
- HEIGHT = 12
- class << self
- def highline
- @highline ||= HighLine.new
- end
- def color(*args)
- highline.color(*args)
- end
- def clear_screen
- write "\e[2J"
- end
- def reset_cursor
- write "\e[2H"
- end
- def hide_cursor
- write "\e[?25l"
- end
- def move_cursor(x, y)
- write "\e[#{y};#{x}H"
- end
- # Gibt die übergebenen Argumente über $stdout.write aus.
- # $stdout wird im nachinein geflusht.
- def write(*args)
- $stdout.write(*args)
- $stdout.flush
- end
- def draw_border
- reset_cursor
- output = []
- output << [::Unicode::U2551, ' ' * WIDTH, ::Unicode::U2551]
- output << [::Unicode::U2551, ' ' * WIDTH, ::Unicode::U2551]
- output << [::Unicode::U2551, ' ' * WIDTH, ::Unicode::U2551]
- output << [::Unicode::U2551, ' ' * WIDTH, ::Unicode::U2551]
- output << [::Unicode::U2551, ' ' * WIDTH, ::Unicode::U2551]
- output << [::Unicode::U2551, ' ' * WIDTH, ::Unicode::U2551]
- output << [::Unicode::U2551, ' ' * WIDTH, ::Unicode::U2551]
- output << [::Unicode::U2551, ' ' * WIDTH, ::Unicode::U2551]
- output << [::Unicode::U255A, ::Unicode::U2550 * WIDTH, ::Unicode::U255D]
- puts output.map { |x| x.join('') }
- end
- def draw_fixed_stones
- # NOOP
- end
- def draw_at(chars, options = {})
- move_cursor(options[:x] || 0, options[:y] || 0)
- write(chars)
- end
- end
- end
- end
Add Comment
Please, Sign In to add comment