-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtiro.rb
47 lines (37 loc) · 810 Bytes
/
tiro.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
class Tiro
attr_reader :x, :y, :labareda, :tiro, :player, :window
def initialize(window)
@tela = window
@x = @tela.player.x
@y = @tela.player.y+80
@labareda = Gosu::Image.new(@tela, "img/flame.png", true)
@som = Gosu::Sample.new(@tela, "mus/smp/shot.wav")
@tirosample = @som.play(vol = 1, speed = 1, looping = false)
$t = 0
$tir = 0
end
def update
if $t<1000
$t += 1
end
if $t==1000
$tir+=1
$t = 0
end
if $tir>=1000
$tir = 0
end
@tirosample
@x = @x + 10
@tela.bichos.each {|bicho| bicho.levou?(self)}
if @x >= 400 + @tela.player.x
morrer
end
end
def morrer
@tela.tiros.delete(self)
end
def draw
@labareda.draw(@x, @y, 4)
end
end