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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b7883349a48e97c78a018fd5b5ffc4a90b0e2bb4
4
- data.tar.gz: bdf023c3abe695541fcefc1eeb2f0bb520fe43fd
3
+ metadata.gz: 0be590ed4404250137dac28e4ccff4fb950666a3
4
+ data.tar.gz: 786ed6e6b242a0779567e0460a8236157f479264
5
5
  SHA512:
6
- metadata.gz: d8cfcb5e6e8f809d2a1c855bea5c971dfc84beda8bcf2564bfb6029f833c70f567f1053a50da5f1076e06bd64b929037769351afcb18ff693a23c031585be519
7
- data.tar.gz: 661d372b1dced48dd0a6338387eebb8f56ed260bbe714a09f55e15b0805743f3d3b355546bee79c0e681a1be0bb19a3357970bed2779eade07ce31bd1f32c079
6
+ metadata.gz: e98ed69fa34991790df4fb26b0b3d6b7e98349370737e7fa797d0807c18894a249cfc3ed9d63346e9b3283d6a30b4ea42c70ada492c5af99376b8f27d8a80b47
7
+ data.tar.gz: 98dc1efb3abd04aa941d9bc866b32cd8a92d23e60d6d760f150f7f773842462063dc1c28c5ed2218336133c850c49e48666c4707bc8b66b74d7e4a3c269d1b74
@@ -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
@@ -1,5 +1,10 @@
1
1
  module TerminalGameEngine
2
2
  class Input
3
+ module Keys
4
+ CTRL_C = 3
5
+ ESCAPE = 27
6
+ end
7
+
3
8
  def self.call(&block)
4
9
  begin
5
10
  loop do
@@ -1,3 +1,3 @@
1
1
  module TerminalGameEngine
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  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.0
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