Game Development Reference
In-Depth Information
The message will move around as long as you keep arrow keys pressed.
Use arrow keys to move the message around
We could write a shorter version, but the point here is that if we wouldn't override
needs_redraw?
this program would be slower by order of magnitude, because it would
create
@message
object every time it wants to redraw the window, even though nothing
would change.
Here is a screenshot of
top
displaying two versions of this program. Second screen has
needs_redraw?
method removed. See the difference?
Redrawing only when necessary VS redrawing every time
Ruby is slow, so you have to use it wisely.