T
Teodor Carstea
hi, all! my compiler doesn't like the "minus" in line 21, it's like:
/home/cristi/NetBeansProjects/RubyApplication3/lib/helic.rb:21:
undefined method `-' for "":String (NoMethodError)
1 require "init.rb"
2
3 shots = 3
4 time = 1
5 speed = 0
6 x=y=1
7 while (shots!=0) do
8 #give entry data
9 puts "let's f*ck da su**er!"
10 puts "give speed:"
11 speed = gets
12 puts "give angle:"
13 angle = gets
14 #processing entry data
15 angle=(Math:I)/180*angle.to_f
16 xspeed=speed*Math.cos(angle)
17 yspeed=speed*Math.sin(angle)
18 #trajectory's loop
19 while (y>0) do
20 x=xspeed*time
21 y=yspeed*time-4.9*time**2
22 time+=0.01
23
24 #puts "x="+x.to_i.to_s+" y="+y.to_i.to_s
25 screen.fill_rect 0, 0, 640, 480, BGCOLOR
26 screen.draw_circle x, y, 5, SHELLCOLOR
27 screen.flip
28
29 end
30 shots-=1
31 puts "shots remaining"+ shots.to_s
32 end
help, please. thanks!
/home/cristi/NetBeansProjects/RubyApplication3/lib/helic.rb:21:
undefined method `-' for "":String (NoMethodError)
1 require "init.rb"
2
3 shots = 3
4 time = 1
5 speed = 0
6 x=y=1
7 while (shots!=0) do
8 #give entry data
9 puts "let's f*ck da su**er!"
10 puts "give speed:"
11 speed = gets
12 puts "give angle:"
13 angle = gets
14 #processing entry data
15 angle=(Math:I)/180*angle.to_f
16 xspeed=speed*Math.cos(angle)
17 yspeed=speed*Math.sin(angle)
18 #trajectory's loop
19 while (y>0) do
20 x=xspeed*time
21 y=yspeed*time-4.9*time**2
22 time+=0.01
23
24 #puts "x="+x.to_i.to_s+" y="+y.to_i.to_s
25 screen.fill_rect 0, 0, 640, 480, BGCOLOR
26 screen.draw_circle x, y, 5, SHELLCOLOR
27 screen.flip
28
29 end
30 shots-=1
31 puts "shots remaining"+ shots.to_s
32 end
help, please. thanks!