Class: Burn::Generator::Telnet::Screen
- Inherits:
-
Object
- Object
- Burn::Generator::Telnet::Screen
- Includes:
- Debug
- Defined in:
- lib/burn/generator/telnet/screen.rb
Constant Summary collapse
- ESC =
equal to “033”
27.chr
- CLEARSCREEN =
ESC + "[2J"
- JUMPTOHOME =
ESC + "[H"
- RESETALLATTR =
ESC + "[0m"
- CRLF =
13.chr + 10.chr
Instance Attribute Summary collapse
-
#activated_sprite_objects ⇒ Object
Returns the value of attribute activated_sprite_objects.
-
#bg_color ⇒ Object
Returns the value of attribute bg_color.
-
#display ⇒ Object
Returns the value of attribute display.
-
#fg_color ⇒ Object
Returns the value of attribute fg_color.
Instance Method Summary collapse
- #flush_screen ⇒ Object
-
#initialize(conf) ⇒ Screen
constructor
A new instance of Screen.
- #is_pressed(key, user_input) ⇒ Object
- #to_terminal ⇒ Object
Methods included from Debug
Constructor Details
#initialize(conf) ⇒ Screen
Returns a new instance of Screen.
14 15 16 17 18 19 20 |
# File 'lib/burn/generator/telnet/screen.rb', line 14 def initialize(conf) @fg_color = 37 @bg_color = 40 @activated_sprite_objects = [] # activated sprite objects by #sprite method call during main_loop will be contained @conf = conf flush_screen end |
Instance Attribute Details
#activated_sprite_objects ⇒ Object
Returns the value of attribute activated_sprite_objects.
12 13 14 |
# File 'lib/burn/generator/telnet/screen.rb', line 12 def activated_sprite_objects @activated_sprite_objects end |
#bg_color ⇒ Object
Returns the value of attribute bg_color.
12 13 14 |
# File 'lib/burn/generator/telnet/screen.rb', line 12 def bg_color @bg_color end |
#display ⇒ Object
Returns the value of attribute display.
12 13 14 |
# File 'lib/burn/generator/telnet/screen.rb', line 12 def display @display end |
#fg_color ⇒ Object
Returns the value of attribute fg_color.
12 13 14 |
# File 'lib/burn/generator/telnet/screen.rb', line 12 def fg_color @fg_color end |
Instance Method Details
#flush_screen ⇒ Object
34 35 36 37 38 |
# File 'lib/burn/generator/telnet/screen.rb', line 34 def flush_screen @display = Array.new @conf.app.height.times{ @display << Array.new(@conf.app.width){' '}.join } @activated_sprite_objects = [] end |
#is_pressed(key, user_input) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/burn/generator/telnet/screen.rb', line 40 def is_pressed(key, user_input) log " ** program is waiting for:" + key.to_s if !user_input.nil? then log " **** confiremd user input:" + user_input.class.to_s, user_input.chr, user_input.to_s if [*'0'..'9', *'a'..'z', *'A'..'Z'].include?(user_input.chr) && key.to_s == user_input.chr then log "****** is_pressed() returned true" return true end end false end |
#to_terminal ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/burn/generator/telnet/screen.rb', line 22 def to_terminal #CLEARSCREEN + escape_color(@fg_color) + escape_color(@bg_color) + @display.join("\r\n") + JUMPTOHOME + RESETALLATTR #JUMPTOHOME + RESETALLATTR + CLEARSCREEN + escape_color(@fg_color) + escape_color(@bg_color) + @display.join("\r\n") + ESC + "[#{@conf.app.height};2H" + RESETALLATTR #CLEARSCREEN + escape_color(@fg_color) + escape_color(@bg_color) + @display.join("\r\n") + ESC + "[#{@conf.app.height};2H" + RESETALLATTR #JUMPTOHOME + crlf + crlf + crlf + crlf + crlf + crlf + @display.join(crlf) #JUMPTOHOME + crlf + crlf + crlf + crlf + crlf + crlf + @display.join(crlf) + crlf #JUMPTOHOME + @display.join(CRLF) + CRLF JUMPTOHOME + escape_color(@fg_color) + escape_color(@bg_color) + ppu_emulate + CRLF + RESETALLATTR #JUMPTOHOME + @display.join(CRLF) + CRLF end |