Tetris 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/shape.rb +1 -1
  3. data/lib/tetris.rb +11 -2
  4. metadata +5 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c424ad531190659c50649d57b2fb564cc77f5c0e
4
- data.tar.gz: 0aeaa132f69651e0da58aeaa069d748cc8f927e5
3
+ metadata.gz: d5b254f5c5fc8c79c2ed46c95a1bc70fbad2ee99
4
+ data.tar.gz: 828f435ff817735f7eba9dcf31f578f7427145a5
5
5
  SHA512:
6
- metadata.gz: 3d4a7c1c1343fe6301503aadadd62e8c71e76e783de9e66ca40ff4ffa802390b64530743160b2446cf8b8334d5543dd0e0d5afcd62fbea4e05df155c5754bf95
7
- data.tar.gz: b93889efd142f39aadb142d7ad9b695fc2f41f1ad2ea427e7714eb8e124f68f141ae10b425f2f7d5a51bf1a7b9401bcaf573d8e97217d993e068b6e582be3f39
6
+ metadata.gz: 85568e16bc787bca5a4d40b1654c8e4c741ea4ad2f853e8e9801f0b70d4a8d4b722f6a0ccece5ce5629d09abbef7c78768bfa06f489424fbb30fbc4282a90e93
7
+ data.tar.gz: eb0407bf8aa22cbb39a504c5a44eeca369ab271218a101a7ac45789ddd8a91c25633dfc897b99ae49d8ff5262fb3b1cdbae807d97dc718dd46aaeb9a24ed193f
@@ -89,7 +89,7 @@ class Shape
89
89
  if @game.button_down?(Gosu::KbDown)
90
90
  @game.game_speed *= 0.2
91
91
  else
92
- @game.game_speed = 1
92
+ @game.update_score
93
93
  end
94
94
 
95
95
  return unless @game.elapsed_seconds > @game.last_move_y + @game.game_speed
@@ -15,7 +15,7 @@ class Game < Gosu::Window
15
15
  attr_accessor :game_speed, :screen_width, :screen_height, :elapsed_seconds
16
16
  attr_accessor :last_move_x, :last_move_y
17
17
 
18
- attr_reader :shape
18
+ attr_reader :shape, :init_speed
19
19
 
20
20
  STATE_PLAYING = 1
21
21
  STATE_END = 2
@@ -28,7 +28,8 @@ class Game < Gosu::Window
28
28
  @score = 0
29
29
  @blocks = []
30
30
  @game_state = STATE_END
31
- @game_speed = 1 # the lower, the faster
31
+ @init_speed = 1.0
32
+ @game_speed = 1.0 # the lower, the faster
32
33
 
33
34
  @game_over_text = Gosu::Image.from_text(self, 'Game Over', 'Arial', 40)
34
35
  @press_space_text = Gosu::Image.from_text(self, 'Press SPACE to start a new game', 'Arial', 15)
@@ -65,6 +66,7 @@ class Game < Gosu::Window
65
66
  @blocks = []
66
67
  @score = 0
67
68
  @shape = nil
69
+ @game_speed = @init_speed
68
70
  self.caption = "Tetris! (#{@score} Points)"
69
71
  @game_state = STATE_PLAYING
70
72
  @music.stop
@@ -95,6 +97,7 @@ class Game < Gosu::Window
95
97
 
96
98
  update_score(lines_to_delete)
97
99
  move_blocks_down(lines_to_delete)
100
+ update_speed
98
101
 
99
102
  lines_to_delete
100
103
  end
@@ -107,6 +110,11 @@ class Game < Gosu::Window
107
110
  self.caption = "Tetris! (#{@score} Points)"
108
111
  end
109
112
 
113
+ # updates game speed
114
+ def update_speed
115
+ @game_speed = @init_speed - 0.01 * @score
116
+ end
117
+
110
118
  # moves appropriate blocks down (typically after lines removal)
111
119
  def move_blocks_down(lines)
112
120
  return if lines.empty?
@@ -153,6 +161,7 @@ class Game < Gosu::Window
153
161
  delete_lines
154
162
  end
155
163
 
164
+ # pick a random shape
156
165
  shapes = [ShapeJ.new(self), ShapeL.new(self), ShapeI.new(self), ShapeO.new(self), ShapeT.new(self), ShapeZ.new(self), ShapeS.new(self)]
157
166
  @shape = shapes.sample
158
167
 
metadata CHANGED
@@ -1,17 +1,19 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: Tetris
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Filip Vondrášek
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-10 00:00:00.000000000 Z
11
+ date: 2015-02-11 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A simple Tetris game created as a semestral project for Programming in
14
- Ruby course at FIT CTU.
14
+ Ruby course at FIT CTU. Use your Space key to rotate shapes, left and right arrows
15
+ to move shapes and down arrow to speed up falling. The game automatically alters
16
+ the speed with relation to your score.
15
17
  email: filip@vondrasek.net
16
18
  executables: []
17
19
  extensions: []