ruby_terminal_games 0.0.2 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/ruby_terminal_games +4 -1
- data/lib/ruby_terminal_games.rb +1 -2
- data/lib/ruby_terminal_games/hangman.rb +5 -0
- data/lib/ruby_terminal_games/hangman/board.rb +38 -0
- data/lib/ruby_terminal_games/hangman/game.rb +55 -0
- data/lib/ruby_terminal_games/hangman/word.rb +36 -0
- data/lib/ruby_terminal_games/hangman/words.txt +58109 -0
- data/lib/ruby_terminal_games/keyboard.rb +12 -3
- data/lib/ruby_terminal_games/snake/game.rb +1 -1
- data/lib/ruby_terminal_games/version.rb +1 -1
- metadata +8 -3
@@ -2,14 +2,14 @@ module RubyTerminalGames
|
|
2
2
|
class Keyboard
|
3
3
|
attr_reader :thread
|
4
4
|
|
5
|
-
def capture(detect_direction: false, &block)
|
5
|
+
def self.capture(detect_direction: false, &block)
|
6
6
|
Curses.noecho
|
7
7
|
Curses.stdscr.keypad(true)
|
8
8
|
Curses.curs_set(0)
|
9
9
|
Curses.cbreak
|
10
10
|
Curses.raw
|
11
11
|
|
12
|
-
Thread.new do
|
12
|
+
@capture_thread = Thread.new do
|
13
13
|
loop do
|
14
14
|
key = Curses.getch
|
15
15
|
command = direction(key) || key
|
@@ -20,9 +20,18 @@ module RubyTerminalGames
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
+
def self.stop_capture
|
24
|
+
Thread.kill(@capture_thread)
|
25
|
+
Curses.echo
|
26
|
+
Curses.stdscr.keypad(false)
|
27
|
+
Curses.curs_set(1)
|
28
|
+
Curses.crmode
|
29
|
+
Curses.noraw
|
30
|
+
end
|
31
|
+
|
23
32
|
private
|
24
33
|
|
25
|
-
def direction(key)
|
34
|
+
def self.direction(key)
|
26
35
|
case key
|
27
36
|
when Curses::KEY_UP; then UP;
|
28
37
|
when Curses::KEY_DOWN; then DOWN;
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_terminal_games
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Alves
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: curses
|
@@ -78,6 +78,11 @@ files:
|
|
78
78
|
- lib/ruby_terminal_games.rb
|
79
79
|
- lib/ruby_terminal_games/board.rb
|
80
80
|
- lib/ruby_terminal_games/game.rb
|
81
|
+
- lib/ruby_terminal_games/hangman.rb
|
82
|
+
- lib/ruby_terminal_games/hangman/board.rb
|
83
|
+
- lib/ruby_terminal_games/hangman/game.rb
|
84
|
+
- lib/ruby_terminal_games/hangman/word.rb
|
85
|
+
- lib/ruby_terminal_games/hangman/words.txt
|
81
86
|
- lib/ruby_terminal_games/keyboard.rb
|
82
87
|
- lib/ruby_terminal_games/snake.rb
|
83
88
|
- lib/ruby_terminal_games/snake/apple.rb
|
@@ -105,7 +110,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
105
110
|
version: '0'
|
106
111
|
requirements: []
|
107
112
|
rubyforge_project:
|
108
|
-
rubygems_version: 2.
|
113
|
+
rubygems_version: 2.4.5
|
109
114
|
signing_key:
|
110
115
|
specification_version: 4
|
111
116
|
summary: Ruby Terminal Games
|