Please send questions to st10@humboldt.edu .
; BEWARE -- in this text-version,
;    there are dots (.) below where the penguin images should be!

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

; starting animation for CS 131 - Week 3, Lecture 1
; by: Sharon Tuttle
; last modified: 09-07-10

(define WIDTH 200)
(define HEIGHT 250)
(define BACKDROP (empty-scene WIDTH HEIGHT))

; images are from
;http://wallofgame.com/free-online-games/arcade/231/Parachute_Penguin_Shootout.html
(define FLOATING-PENGUIN.)
(save-image FLOATING-PENGUIN "floating-penguin.png")
(define LANDED-PENGUIN.)
(save-image LANDED-PENGUIN "landed-penguin.png")

;-------------
; signature: get-1-bigger: number -> number
; purpose: expects a number, and produces the number
;     that is 1 bigger

(define (get-1-bigger a-number)
  (+ a-number 1)
)

; note -- this check-expect was written BEFORE get-1-bigger's
;    body was filled in!

(check-expect (get-1-bigger 15) 16)
(get-1-bigger 45)

;----------
; contract: draw-penguin: number -> scene
; purpose: expects a number, and if the number is less than 
;    (the scene's height minus 50), it draws a floating 
;    penguin with that as its y-coordinate;
;    otherwise, it draws the now-landed penguin on the 
;    "ground" (50 less than the height, so we see the whole 
;    penguin! 8-)

(define (draw-penguin a-number)
  (cond 
    ((< a-number (- HEIGHT 50))
        (place-image FLOATING-PENGUIN
                     (/ WIDTH 2) a-number
                     BACKDROP))
    (else
        (place-image LANDED-PENGUIN
                     (/ WIDTH 2) (- HEIGHT 50)
                     BACKDROP))
  )
        
)

(check-expect (draw-penguin 3)
              (place-image FLOATING-PENGUIN
                           (/ WIDTH 2) 3
                           BACKDROP))
(check-expect (draw-penguin HEIGHT)
              (place-image LANDED-PENGUIN
                           (/ WIDTH 2) (- HEIGHT 50)
                           BACKDROP))
(check-expect (draw-penguin (+ HEIGHT 27))
              (place-image LANDED-PENGUIN
                           (/ WIDTH 2) (- HEIGHT 50)
                           BACKDROP))

(big-bang 0
          (on-tick get-1-bigger)
          (on-draw draw-penguin)
          
          ; this option allows you to create an animated
          ;    gif from your animation...
          
          (record? true))

(save-image (draw-penguin 57) "penguin57.png")