i'm new to ruby and programming in general and i'm using a gem called ruby2D. Im trying to get a cube to jump, but when i press my jump key, my interpretor just crashes without any saying any errors
I've had problems actually identifying the problem, but i've tried with while instead of until and that didn't seem to work either
on :key_down do |jump|
if jump.key == 'j'
if player.y == 520
gravity = -15
player.y = 510
until player.y == 520
player.y += gravity
gravity += 1
end
end
end
end
i would want my cube to jump, and fall down again, but i just get crashes
In Ruby2D you must use
tickto do animation.The window also manages the update loop, one of the few infinite loops in programming you’ll encounter that isn’t a mistake. Every window has a heartbeat, a loop that runs 60 times per second, or as close to it as the computer’s performance will allow. Using the
updatemethod, we can enter this loop and make the window come to life!Try something like this: