i am trying to make aan animation for my game in DrRacket, when i press the left button i want my image to do a running animation (legs open --> legs closed). Is there a way i can delay the image swap? The computer does the swap soo fast that you dont see the swap happening. -->
(define (keyboard-function key)
(cond ((eq? key 'left) (tekenaar 'mario-next!)
((mario-adt 'move) 'left)
(tekenaar 'mario-next!))
((eq? key 'right) ((mario-adt 'move) 'right)
(tekenaar 'mario-next!))
(else (void))))
Thanks
You can't really make the computer delay the swap itself. What you can do is delay it yourself.
You could do this by keeping a counter you increment every frame. When that counter reaches a certain number, you swap the images. This way, instead of swapping them every frame, you swap them every x frames.
An easy way to do this is as follows:
(define counter 0)
(set! counter (modulo (+ counter 1) 50))
(if (= counter 0)
; start drawing the other image)