Yes, if the drawing of the projectile is not triggered from paint-callback
(or another function/method called from it), it will not be displayed in the canvas when the canvas is refreshed.
One possibility is to have a list of existing projectiles (possibly an attribute in player-ship%
), and paint-callback
should trigger (possibly via player-ship%
's render
method, or via a different method in player-ship%
like render-projectiles
that is called from the paint-callback
) the display of all these projectiles in the canvas. When a new projectile is shot from the ship, it should be added to the list of existing projectiles and when the projectile hits something or escapes the board, it should be removed from this list.