ruby_terminal_games 0.0.1 → 0.0.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: e7fc58451957c43c34d3b0b50ce03ec8ce1ac778
4
- data.tar.gz: 576e6a57b18cb64b30038afb63b1ad5578a0a48e
3
+ metadata.gz: 9774eb8d88de85447adbc2f20a836a599431ae54
4
+ data.tar.gz: 8f9bab9e0d7082f134cbda20b10ddfc41a1b6ab1
5
5
  SHA512:
6
- metadata.gz: 12a135fd8c7e67f6c792356908ad875fd595df99662f67f6cbb672d78f467afe58eddc9c1883ab71ae1ed166b5eff093ccbac499fa5f8fd7bf7fa56a052eccf5
7
- data.tar.gz: d9a8537ed71df86ce045aa40617c34e69d9ca17ae2a5ef37642d83be6a1364b1470e12e56e582ab4052916f7170a483ded3d9e8fabcfda3dc4a383761af2041d
6
+ metadata.gz: e4d3b0ddbb56c63c43f8feb68ca97fbc26fd3bf81695d519acedbb73ecb77cb7abe8bd3fd49b9850c07084956681569d4b9d50ee0b7ee68e292c6f33d789d5e3
7
+ data.tar.gz: 8f75f774d941de0158c0d266d9c02a115a2201a3258e183f089ab16e0470ee1ac18bead9e40ad88f1502994c6061527aa3b2a1ee893ddd36d4c6d14eda903fb6
@@ -15,6 +15,7 @@ module RubyTerminalGames
15
15
  command = direction(key) || key
16
16
  command = key unless detect_direction
17
17
  block.call(command)
18
+ sleep(0.15)
18
19
  end
19
20
  end
20
21
  end
@@ -32,7 +32,7 @@ module RubyTerminalGames
32
32
  def died?
33
33
  _, position = state.last
34
34
  row, col = position
35
- across_rows_limit?(row) || across_cols_limit?(col)
35
+ across_rows_limit?(row) || across_cols_limit?(col) || collision_with_self?
36
36
  end
37
37
 
38
38
  def eat?(apple)
@@ -75,6 +75,10 @@ module RubyTerminalGames
75
75
  def used_positions
76
76
  state.map { |s| s.last }
77
77
  end
78
+
79
+ def collision_with_self?
80
+ used_positions.uniq.size != used_positions.size
81
+ end
78
82
  end
79
83
  end
80
84
  end
@@ -1,3 +1,3 @@
1
1
  module RubyTerminalGames
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.2'
3
3
  end
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.1
4
+ version: 0.0.2
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-16 00:00:00.000000000 Z
11
+ date: 2015-07-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: curses