Tetris 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/shape.rb +1 -1
- data/lib/tetris.rb +11 -2
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d5b254f5c5fc8c79c2ed46c95a1bc70fbad2ee99
|
4
|
+
data.tar.gz: 828f435ff817735f7eba9dcf31f578f7427145a5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 85568e16bc787bca5a4d40b1654c8e4c741ea4ad2f853e8e9801f0b70d4a8d4b722f6a0ccece5ce5629d09abbef7c78768bfa06f489424fbb30fbc4282a90e93
|
7
|
+
data.tar.gz: eb0407bf8aa22cbb39a504c5a44eeca369ab271218a101a7ac45789ddd8a91c25633dfc897b99ae49d8ff5262fb3b1cdbae807d97dc718dd46aaeb9a24ed193f
|
data/lib/shape.rb
CHANGED
data/lib/tetris.rb
CHANGED
@@ -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
|
-
@
|
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.
|
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-
|
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: []
|