PasteRack.org
Paste # 15938
2021-04-08 07:51:59

Fork as a new paste.

Paste viewed 253 times.


Embed:

(require 2htdp/image)
(require 2htdp/universe)

(define (picture-of-rocket.v4 h)
  (cond
    [(<= h (- HEIGHT (/ (image-height ROCKET) 2))) ; "!!!"
     (place-image ROCKET 50 h (empty-scene WIDTH HEIGHT))]
    [(> h (- HEIGHT (/ (image-height ROCKET) 2)))
     (place-image ROCKET
                  50 (- HEIGHT (/ (image-height ROCKET) 2))
                  (empty-scene WIDTH HEIGHT))]))
 
(define WIDTH 100)
(define HEIGHT 400)
(define ROCKET .)

; -----------------
; the purpose of function is to stop rocket image 
; when it arrive on the bottom of the scene.
; -----------------
; QUESTION
; on the sixth line
; 
; What is the logic of dividing height by 2  
; of the ROCKET image (from a mathematical aspect) ?
; -----------------
; https://htdp.org/2020-8-1/Book/part_prologue.html#%28part._pro-many-def%29