pentix 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -12,6 +12,13 @@ least level 15 in this game :)
12
12
  You'll need `Ruby` and `gem install gosu`, after that just run
13
13
  the `pentix.rb` file in the console
14
14
 
15
+ You also can install the `pentix` gem
16
+
17
+ gem install pentix
18
+ pentix
19
+
20
+
21
+
15
22
 
16
23
  ## The Purpose
17
24
 
@@ -51,7 +51,7 @@ class Finish
51
51
  text = @text_input.text.slice(0, 32) + (@window.text_input == @text_input ? '_' : '')
52
52
  @text_font.draw(
53
53
  text.ljust(43 - score.size, '.') + score,
54
- X_OFFSET, 9 * Block::SIZE, 0, 1.0, 1.0, TEXT_FONT[2])
54
+ X_OFFSET, 9 * Block::SIZE, 0, 1.0, 1.0, Color::WHITE)
55
55
 
56
56
  @hiscores.each_with_index do |record, i|
57
57
  score = record[1].to_s
@@ -66,6 +66,7 @@ class Finish
66
66
  def score=(score)
67
67
  @score = score
68
68
  @hiscores = Records.top(14)
69
+ @text_input.text = Records.last_name if @text_input.text == ''
69
70
  @window.text_input = @text_input
70
71
  end
71
72
 
@@ -82,8 +82,8 @@ class Glass
82
82
  distance = HEIGHT - lowest_point
83
83
 
84
84
  # checking if it interescts with any existing blocks
85
- @matrix.each_with_index do |row, y|
86
- if nil != row[x]
85
+ (lowest_point..HEIGHT-1).each do |y|
86
+ if @matrix[y][x] != nil
87
87
  distance = y - lowest_point
88
88
  break
89
89
  end
@@ -18,12 +18,16 @@ class Records < Array
18
18
  list.save
19
19
  end
20
20
 
21
+ def self.last_name
22
+ self.new.last_name
23
+ end
24
+
21
25
  def initialize(*args)
22
26
  super *args
23
27
 
24
28
  File.read(FILENAME).split("\n").each do |line|
25
29
  if match = line.match(/^\s*(.*?)\s+(\d+)\s*$/)
26
- self << [match[1].strip, match[2].to_i]
30
+ self << [@last_name = match[1].strip, match[2].to_i]
27
31
  end
28
32
  end if File.exists?(FILENAME)
29
33
  end
@@ -37,4 +41,8 @@ class Records < Array
37
41
  end
38
42
  end
39
43
  end
44
+
45
+ def last_name
46
+ @last_name || ''
47
+ end
40
48
  end
@@ -132,6 +132,22 @@ describe Glass do
132
132
  @figure.size_y - @stack_height - @figure.pos_y + @glass.pos_y
133
133
  end
134
134
  end
135
+
136
+ describe "inside of an enclosed structure" do
137
+ before do
138
+ Glass::WIDTH.times do |x|
139
+ @glass.matrix[Glass::HEIGHT - 9][x] = Color::WHITE # the top row
140
+ @glass.matrix[Glass::HEIGHT - 1][x] = Color::WHITE # the bottom row
141
+ end
142
+
143
+ @figure.pos_x = 2
144
+ @figure.pos_y = Glass::HEIGHT - 6
145
+ end
146
+
147
+ it "should calculate the distance correctly" do
148
+ @glass.spaces_below(@figure).should == Glass::HEIGHT - @figure.pos_y - @figure.size_x - 1
149
+ end
150
+ end
135
151
  end
136
152
 
137
153
  describe "#glue_in" do
@@ -253,6 +269,48 @@ describe Glass do
253
269
  })
254
270
  end
255
271
  end
272
+
273
+ describe "with enclosed blocks structure in the glass" do
274
+ before do
275
+ (Glass::WIDTH - 2).times do |x|
276
+ @glass.matrix[Glass::HEIGHT - 9][x] = Color::WHITE # the top row
277
+ @glass.matrix[Glass::HEIGHT - 1][x] = Color::WHITE # the bottom row
278
+ end
279
+
280
+ @figure.move_to(@glass.pos_x + 3, @glass.pos_y + Glass::HEIGHT - 6)
281
+ end
282
+
283
+ it "should glue the figure inside of the structure" do
284
+ @glass.glue_in(@figure)
285
+
286
+ @glass.should have_matrix(%Q{
287
+ | . . . . . . . . . . . |
288
+ | . . . . . . . . . . . |
289
+ | . . . . . . . . . . . |
290
+ | . . . . . . . . . . . |
291
+ | . . . . . . . . . . . |
292
+ | . . . . . . . . . . . |
293
+ | . . . . . . . . . . . |
294
+ | . . . . . . . . . . . |
295
+ | . . . . . . . . . . . |
296
+ | . . . . . . . . . . . |
297
+ | . . . . . . . . . . . |
298
+ | . . . . . . . . . . . |
299
+ | . . . . . . . . . . . |
300
+ | . . . . . . . . . . . |
301
+ | . . . . . . . . . . . |
302
+ |x.x.x.x.x.x.x.x.x.x. . |
303
+ | . . . . . . . . . . . |
304
+ | . . . . . . . . . . . |
305
+ | . . . . . . . . . . . |
306
+ | . . . . . . . . . . . |
307
+ | . .x. . . . . . . . . |
308
+ | . .x.x. . . . . . . . |
309
+ | . . .x.x. . . . . . . |
310
+ |x.x.x.x.x.x.x.x.x.x. . |
311
+ })
312
+ end
313
+ end
256
314
  end
257
315
 
258
316
  describe "#has_space_for?" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pentix
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,12 +9,12 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-06-03 00:00:00.000000000 +04:00
12
+ date: 2011-06-18 00:00:00.000000000 +04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: gosu
17
- requirement: &2154487680 !ruby/object:Gem::Requirement
17
+ requirement: &2153415040 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,7 +22,7 @@ dependencies:
22
22
  version: '0'
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *2154487680
25
+ version_requirements: *2153415040
26
26
  description: A simple demo project for the Gosu gem
27
27
  email: nemshilov@gmail.com
28
28
  executables: