Guest User

Untitled

a guest
Oct 16th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. require 'curses'
  2. require_relative 'logger'
  3.  
  4. include Curses
  5.  
  6. init_screen
  7.  
  8. begin
  9. curs_set(0)
  10.  
  11. x = cols / 2
  12. y = lines / 2
  13.  
  14. stdscr.keypad = true
  15. setpos(y,x)
  16. addstr("X")
  17.  
  18. while input = stdscr.getch
  19.  
  20. case input
  21. when Key::UP
  22. y -= 1
  23. when Key::DOWN
  24. y += 1
  25. when Key::LEFT
  26. x -= 1
  27. when Key::RIGHT
  28. x += 1
  29. end
  30.  
  31. stdscr.clear
  32. setpos(y,x)
  33. addstr("X")
  34. break if input == 'q'
  35. end
  36.  
  37.  
  38. ensure
  39. close_screen
  40. end
Add Comment
Please, Sign In to add comment