-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathtimer.rb
46 lines (37 loc) · 949 Bytes
/
timer.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
$LOAD_PATH << '.'
require 'gosu'
class Timer
attr_accessor :x, :y, :width, :height, :min, :seg1, :seg2, :tempo
def initialize
@x = 124
@y = 13
@width = 8
@height = 14
@minutosreais = 4
@tempo = 3600 * @minutosreais
@images = Gosu::Image::load_tiles('images/tile_8x14.png', 8, 14)
end
# Método draw da Classe Timer
# Responsável por exibir os tiles com os números informando o tempo da fase.
def draw
@images[@min].draw(@x - @width / 2, @y - @height / 2, 2)
@images[@seg1].draw(@x + 16 - @width / 2, @y - @height / 2, 2)
@images[@seg2].draw(@x + 24 - @width / 2, @y - @height / 2, 2)
end
def relogio
if @tempo > 0
@tempo -= 1
end
@min = (@tempo / 60) / 60
@seg = (@tempo / 60)
while @seg >= 60
@seg -= 60
end
@seg1 = @seg.to_s[0].to_i
@seg2 = @seg.to_s[1].to_i
if @seg < 10
@seg1 = 0
@seg2 = @seg.to_s[0].to_i
end
end
end