terminal_game_engine 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/examples/counter.rb +32 -0
- data/lib/terminal_game_engine/input.rb +5 -0
- data/lib/terminal_game_engine/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0be590ed4404250137dac28e4ccff4fb950666a3
|
4
|
+
data.tar.gz: 786ed6e6b242a0779567e0460a8236157f479264
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e98ed69fa34991790df4fb26b0b3d6b7e98349370737e7fa797d0807c18894a249cfc3ed9d63346e9b3283d6a30b4ea42c70ada492c5af99376b8f27d8a80b47
|
7
|
+
data.tar.gz: 98dc1efb3abd04aa941d9bc866b32cd8a92d23e60d6d760f150f7f773842462063dc1c28c5ed2218336133c850c49e48666c4707bc8b66b74d7e4a3c269d1b74
|
data/examples/counter.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
require_relative '../lib/terminal_game_engine'
|
2
|
+
|
3
|
+
TerminalGameEngine::Frame.setup
|
4
|
+
|
5
|
+
TerminalGameEngine::Engine.tick do |tick|
|
6
|
+
number = tick.to_s
|
7
|
+
|
8
|
+
height = 3
|
9
|
+
width = number.length + 2
|
10
|
+
|
11
|
+
frame = TerminalGameEngine::Frame.new width, height
|
12
|
+
|
13
|
+
# draw number
|
14
|
+
frame.draw_center 1, number
|
15
|
+
|
16
|
+
# draw corners
|
17
|
+
frame.draw 0, 0, '+'
|
18
|
+
frame.draw 0, height-1, '+'
|
19
|
+
frame.draw width-1, 0, '+'
|
20
|
+
frame.draw width-1, height-1, '+'
|
21
|
+
|
22
|
+
TerminalGameEngine::Input.call do |key|
|
23
|
+
case key
|
24
|
+
when 'q'.ord, TerminalGameEngine::Input::Keys::ESCAPE, TerminalGameEngine::Input::Keys::CTRL_C
|
25
|
+
exit
|
26
|
+
else
|
27
|
+
frame.draw_center 1, key.to_s
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
frame.render
|
32
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: terminal_game_engine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Odin Dutton
|
@@ -67,6 +67,7 @@ files:
|
|
67
67
|
- LICENSE.txt
|
68
68
|
- README.markdown
|
69
69
|
- Rakefile
|
70
|
+
- examples/counter.rb
|
70
71
|
- lib/terminal_game_engine.rb
|
71
72
|
- lib/terminal_game_engine/engine.rb
|
72
73
|
- lib/terminal_game_engine/frame.rb
|