terminal_game_engine 0.1.1 → 0.1.2

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: 0be590ed4404250137dac28e4ccff4fb950666a3
4
- data.tar.gz: 786ed6e6b242a0779567e0460a8236157f479264
3
+ metadata.gz: f6c929b4edebdc771f660f1d814c1487018e813f
4
+ data.tar.gz: 2fa244fc2b24b6759283a87545e4b8c473a0112d
5
5
  SHA512:
6
- metadata.gz: e98ed69fa34991790df4fb26b0b3d6b7e98349370737e7fa797d0807c18894a249cfc3ed9d63346e9b3283d6a30b4ea42c70ada492c5af99376b8f27d8a80b47
7
- data.tar.gz: 98dc1efb3abd04aa941d9bc866b32cd8a92d23e60d6d760f150f7f773842462063dc1c28c5ed2218336133c850c49e48666c4707bc8b66b74d7e4a3c269d1b74
6
+ metadata.gz: 6145fa6de0cfb0d7eaa3b6bd951d2461612c77d65ba45ca8d5f8858acec5541da0dac7c0bb9b22915ef0c095dd607c8d6db532db6cc8355f6e1e0e871ee0db38
7
+ data.tar.gz: 106a35ce83d7f4a01df5d6c66df5d878a87577c16bcb8eb80be4d31b17e386ce9898797c1d732b2a916f7f1480d39853c97edbda9773910bdd13b3e97be6a26f
data/README.markdown CHANGED
@@ -19,3 +19,7 @@ Or install it yourself as:
19
19
  ## License
20
20
 
21
21
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
22
+
23
+ ## Origins
24
+
25
+ Most of this code was originally written as part of [hrdlr](https://github.com/twe4ked/hrdlr) at Railscamp by [@jasoncodes](https://github.com/jasoncodes), [@nathanaelkane](https://github.com/nathanaelkane), and [@twe4ked](https://github.com/twe4ked). It was then mostly copied into [snek](https://github.com/twe4ked/snek) by [@twe4ked](https://github.com/twe4ked) and then extracted into this gem.
@@ -1,21 +1,24 @@
1
1
  module TerminalGameEngine
2
2
  class Engine
3
- attr_accessor :tick
3
+ DEFAULT_TICK_SLEEP = 0.1
4
4
 
5
- def self.tick(&block)
6
- self.new(&block).tap(&:call)
5
+ attr_accessor :tick, :tick_sleep
6
+
7
+ def self.tick(*args, &block)
8
+ self.new(*args, &block).tap(&:call)
7
9
  end
8
10
 
9
- def initialize(&block)
11
+ def initialize(tick_sleep: DEFAULT_TICK_SLEEP, &block)
10
12
  @tick = 0
11
13
  @block = block
14
+ @tick_sleep = tick_sleep
12
15
  end
13
16
 
14
17
  def call
15
18
  loop do
16
19
  @block.call @tick
17
20
  @tick += 1
18
- sleep 0.1
21
+ sleep tick_sleep
19
22
  end
20
23
  end
21
24
  end
@@ -1,11 +1,19 @@
1
+ require 'open3'
2
+
1
3
  module TerminalGameEngine
2
4
  class Sound
3
- def self.play(sound)
5
+ def self.play(path, logger: Logger.new('/dev/null'))
4
6
  case RUBY_PLATFORM
5
7
  when /darwin/
6
- system "afplay assets/sounds/#{sound} &"
8
+ stdin, stdout, stderr, wait_thr = Open3.popen3('afplay', path)
7
9
  when /linux/
8
- system "command -v mplayer >/dev/null 2>&1 && mplayer -msglevel all=-1 -nolirc assets/sounds/#{sound} &"
10
+ stdin, stdout, stderr, wait_thr = Open3.popen3('command -v mplayer >/dev/null 2>&1 && mplayer -msglevel all=-1 -nolirc', path)
11
+ end
12
+
13
+ Thread.new do
14
+ while line = stderr.readline
15
+ logger.error line.chomp
16
+ end
9
17
  end
10
18
  end
11
19
  end
@@ -1,3 +1,3 @@
1
1
  module TerminalGameEngine
2
- VERSION = '0.1.1'
2
+ VERSION = '0.1.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: terminal_game_engine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Odin Dutton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-11 00:00:00.000000000 Z
11
+ date: 2016-07-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler