def update
if button_down?(Gosu::KB_SPACE) && !@pressed
@y -= 30
@pressed = true
elsif !button_down?(Gosu::KB_SPACE)
@pressed = false
end
if @vel.nil?
@vel *= 4
@y += @vel * 0.05
end
end
everytime i add an operator for @vel it gives me this error. Why's that?
tried checking if the variable is nil to run but none worked for me
The conditional
@vel.nil?
only returns true when@vel
isnil
. You want the opposite, either use[email protected]?
or use theunless
keyword instead of theif
keyword before@vel.nil?
.