-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscoreboard.rb
62 lines (55 loc) · 1.04 KB
/
scoreboard.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
class Scoreboard
attr_reader :level, :score
def initialize(gameboard_width, gameboard_height)
@score = 0
@lines_cleared = 0
@level = 1
# x_pos = Window.width / 2
@text = Text.new(
'',
x: 0, y: 0,
size: 27,
color: 'black',
z: 10
)
@boom_text = Text.new(
'',
x: 290, y: 0,
size: 27,
color: 'black',
z: 10
)
@prev_tetris = false
end
def reset_boom_text
@boom_text.text = ""
end
def update
@level = @lines_cleared/5 + 1 # Update level
@text.text = "Level: #{@level} Score: #{@score}" # Update text
end
def score_acceleration
@score += 1*level
update
end
def score_hard_drop(dis)
@score += 2*dis*level
update
end
def score_row
@score += 100*level
@lines_cleared += 1
update
@prev_tetris = false
end
def score_tetris
@score += 800*level
if @prev_tetris
@score += 200*level
end
@lines_cleared += 8
update
@boom_text.text = "TETRIS!"
@prev_tetris = true
end
end