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@velisnil. You want the opposite, either use[email protected]?or use theunlesskeyword instead of theifkeyword before@vel.nil?.