Guest User

Untitled

a guest
May 16th, 2018
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scheme 2.62 KB | None | 0 0
  1. (define draw-game
  2.   (lambda (g)
  3.     (letrec ((newgame ((game-behaviour g) g))
  4.              (pc (game-pacman g))
  5.              (f (game-field g))
  6.              (offs (round (/ (- tile-width (* 2 (pacman-r pc))) 2)))
  7.              ; böse, aber aus Performancegründen leider notwendig
  8.              (_ (set! draw-field (if (= (score-lives (game-score newgame)) 0)
  9.                                      (field-image start-field)
  10.                                      (freeze
  11.                                       (draw-tile " "
  12.                                                  (tile-x (field-tile f))
  13.                                                  (tile-y (field-tile f))
  14.                                                  draw-field))))))
  15.       (place-image (draw-score g)
  16.                    200 30
  17.                    (fold  
  18.                     (if (and (= (pacman-col pc) 0)
  19.                             (= (pacman-row pc) 17)
  20.                             (string=? (pacman-current-dir pc) "left"))
  21.                        
  22.                         (underlay/xy      
  23.                          draw-field
  24.                          0
  25.                          (+ (+ (* tile-width (pacman-row pc)) (span (pacman-offset-row pc))) offs)
  26.                          (crop-left (abs (pacman-offset-col pc)) (draw-pacman pc)))
  27.                        
  28.                         (underlay/xy      
  29.                          draw-field
  30.                          (+ (+ (* tile-width (pacman-col pc)) (span (pacman-offset-col pc))) offs)
  31.                          (+ (+ (* tile-width (pacman-row pc)) (span (pacman-offset-row pc))) offs)
  32.                          (draw-pacman pc)))
  33.                        
  34.                        
  35.                     (lambda (gh img)
  36.                       (if (and (= (ghost-col gh) 0)
  37.                                (= (ghost-row gh) 17)
  38.                                (string=? (ghost-dir gh) "left"))
  39.                          
  40.                           (underlay/xy
  41.                            img
  42.                            0
  43.                            (+ (+ (* tile-width (ghost-row gh)) (span (ghost-offset-row gh))) offs)
  44.                            (crop-left (abs (ghost-offset-col gh)) (draw-ghost gh)))
  45.                        
  46.                           (underlay/xy
  47.                            img
  48.                            (+ (+ (* tile-width (ghost-col gh)) (span (ghost-offset-col gh))) offs)
  49.                            (+ (+ (* tile-width (ghost-row gh)) (span (ghost-offset-row gh))) offs)
  50.                            (draw-ghost gh))))
  51.                      
  52.                       (game-ghosts g))))))
Add Comment
Please, Sign In to add comment